Added hud buttons, fixed river generation, v1.2.0

This commit is contained in:
Nicola Sovic
2022-04-08 17:15:48 +02:00
parent 16568360a0
commit 8266248281
20 changed files with 1399 additions and 1540 deletions

View File

@@ -155,7 +155,43 @@ public class NoiseGenerator
private float[] calculateSamplesRiver(GameObject tile)
{
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
float[] samples = calculateBasicSamples(tile);
bool isVertical = (rand.Next(0,2) == 0 ? true : false);
int startX = 0;
int startZ = 0;
if (isVertical)
{
startZ = (rand.Next(0, 2) == 0 ? 4 : -4);
startX = rand.Next(-4, 5);
}
else
{
startZ = rand.Next(-4, 5);
startX = (rand.Next(0, 2) == 0 ? 4 : -4);
}
for (int k = 0; k < vertices.Length; k++)
{
if (isVertical)
{
if (Mathf.Round(vertices[k].x) == startX && Mathf.Round(vertices[k].z) != 5 && Mathf.Round(vertices[k].z) != -5)
{
samples[k] = samples[k] - rand.Next(2, 4) + 0.5f;
}
}
else
{
if (Mathf.Round(vertices[k].x) != 5 && Mathf.Round(vertices[k].x) != -5 && Mathf.Round(vertices[k].z) == startZ)
{
samples[k] = samples[k] - rand.Next(2, 4) + 0.5f;
}
}
}
Debug.Log("River");
return samples;
}