public void GenerateMap()
{
float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset);
Color[] colorMap = new Color[mapWidth * mapHeight];
for (int y = 0; y < mapHeight; y++)
{
for (int x = 0; x < mapWidth; x++)
{
float currentHeight = noiseMap[x, y];
for (int i = 0; i < regions.Length; i++)
{
if (currentHeight <= regions[i].height)
{
colorMap[y * mapWidth + x] = regions[i].color;
break;
}
}
}
}
MapDisplayScr display = GetComponent <MapDisplayScr>();
if (dMode == DrawMode.NoiseMap)
{
display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
}
else if (dMode == DrawMode.ColorMap)
{
display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
}
else if (dMode == DrawMode.Mesh)
{
display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, animationCurve), TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
}
}