Beispiel #1
0
 void GenerateTerrainData()
 {
     perlin = GetComponentInParent <PerlinNoiseGen>();
     //Debug.Log("Chunk " + Position + " generating blocks");
     for (int x = 0; x < blocks.GetLength(0); x++)
     {
         for (int z = 0; z < blocks.GetLength(2); z++)
         {
             var noise = Mathf.FloorToInt(perlin.PerlinNoise((x + Position.x) / Size.x, (z + Position.y) / Size.z) * Size.y);
             for (int y = 0; y < blocks.GetLength(1); y++)
             {
                 if (y > noise)
                 {
                     blocks[x, y, z] = 0;
                 }
                 if (y == noise)
                 {
                     blocks[x, y, z] = 1;
                 }
                 if (y < noise)
                 {
                     blocks[x, y, z] = 2;
                 }
             }
         }
     }
 }
Beispiel #2
0
 void GenerateTerrainData()
 {
     perlin = GetComponentInParent <PerlinNoiseGen>();
     //Debug.Log("Chunk " + Position + " generating blocks");
     for (int x = 0; x < blocks.GetLength(0); x++)
     {
         for (int z = 0; z < blocks.GetLength(1); z++)
         {
             var noise = Mathf.FloorToInt(perlin.PerlinNoise((float)(x + position.X) / size.X, (float)(z + position.Z) / size.Z) * size.Z);
             blocks[x, z] = (byte)noise;                             //FIXME: ugly cast
         }
     }
 }