public static Texture2D GenerateTerrain(int width, int height)
{
var types = GenerateArray(width, height);
var typeData = types.Cast<Terrain.TerrainType>();
var colorData = typeData.Select(t => {
switch (t)
{
case Terrain.TerrainType.Air:
return Color.Black;
case Terrain.TerrainType.Earth:
return new Color(127, 64, 0);
case Terrain.TerrainType.Stone:
return new Color(127, 127, 127);
case Terrain.TerrainType.Sand:
return Color.Yellow;
case Terrain.TerrainType.Water:
return Color.Blue;
case Terrain.TerrainType.VegetationSeed:
return Color.Lime;
case Terrain.TerrainType.SpawnPoint:
return Color.Red;
default:
throw new ArgumentOutOfRangeException(nameof(t), t, null);
}
});
var t2D = new Texture2D(Ballz.The().GraphicsDevice, width, height);
t2D.SetData(colorData.ToArray());
return t2D;
}