Implemented eroder.

This commit is contained in:
2015-03-23 21:17:09 +02:00
parent 68140b11a7
commit 76527c2619
30 changed files with 470 additions and 212 deletions

View File

@ -20,5 +20,14 @@ namespace Assets.Scripts.Model.Config
[XmlElement("waterNonLinearPower")]
public float WaterNonLinearPower { get; set; }
[XmlElement("erodePoints")]
public int ErodePoints { get; set; }
[XmlElement("erodeIterations")]
public int ErodeIterations { get; set; }
[XmlElement("erodeAmountPercent")]
public float ErodeAmountPercent { get; set; }
}
}

View File

@ -24,7 +24,7 @@ namespace TransportGame.Model
public Biome Biome { get; set; }
/// <summary>
/// Gets the heights array
/// Gets the heights array in range [0,1]
/// </summary>
[XmlIgnore()]
public float[,] Heights
@ -102,7 +102,7 @@ namespace TransportGame.Model
}
/// <summary>
/// Gets or sets the cell at specified position
/// Gets or sets the cell at specified position in range [0, Biome.Height]
/// </summary>
/// <param name="x">X</param>
/// <param name="y">Y</param>
@ -112,11 +112,11 @@ namespace TransportGame.Model
{
get
{
return grid[x, y];
return grid[x, y] * Biome.Height;
}
set
{
grid[x, y] = value;
grid[x, y] = value / Biome.Height;
}
}
@ -140,7 +140,18 @@ namespace TransportGame.Model
/// <returns></returns>
public bool IsWater(int x, int y)
{
return grid[x, y] * Biome.Height <= WaterLevel;
return this[x, y] <= WaterLevel;
}
/// <summary>
/// Returns true if given coordinates is inside the map
/// </summary>
/// <param name="x">X</param>
/// <param name="y">Y</param>
/// <returns>True if coordinates are inside the map</returns>
public bool IsInside(int x, int y)
{
return x >= 0 && y >= 0 && x < Width && y < Height;
}
}
}