84 lines
2.0 KiB
C#
84 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace TransportGame.Model
|
|
{
|
|
public class Map
|
|
{
|
|
private float[,] grid;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the water level
|
|
/// </summary>
|
|
public float WaterLevel { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the biome
|
|
/// </summary>
|
|
public Biome Biome { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the heights array
|
|
/// </summary>
|
|
public float[,] Heights
|
|
{
|
|
get
|
|
{
|
|
return grid;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes the map
|
|
/// </summary>
|
|
/// <param name="width"></param>
|
|
/// <param name="height"></param>
|
|
public Map(int width, int height)
|
|
{
|
|
grid = new float[width, height];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the cell at specified position
|
|
/// </summary>
|
|
/// <param name="x">X</param>
|
|
/// <param name="y">Y</param>
|
|
/// <returns>Cell</returns>
|
|
public float this[int x, int y]
|
|
{
|
|
get
|
|
{
|
|
return grid[x, y];
|
|
}
|
|
set
|
|
{
|
|
grid[x, y] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets width of map
|
|
/// </summary>
|
|
public int Width { get { return grid.GetLength(0); } }
|
|
|
|
/// <summary>
|
|
/// Gets height of map
|
|
/// </summary>
|
|
public int Height { get { return grid.GetLength(1); } }
|
|
|
|
/// <summary>
|
|
/// Returns true if specified cell is a water cell
|
|
/// </summary>
|
|
/// <param name="x">X</param>
|
|
/// <param name="y">Y</param>
|
|
/// <returns></returns>
|
|
public bool IsWater(int x, int y)
|
|
{
|
|
return grid[x, y] <= WaterLevel;
|
|
}
|
|
}
|
|
}
|