Esempio n. 1
0
 public bool SetBrick(byte brick, int x, int y, int z)
 {
     if ((x < 0) || (y < 0) || (z < 0) || (x >= width) || (y >= height || (z >= width)))
     {
         return(false);
     }
     if (map[x, y, z] == brick)
     {
         return(false);
     }
     map[x, y, z] = brick;
     StartCoroutine(CreateVisualMesh(false));
     if (x == 0)
     {
         Chunk chunk = FindChunk(new Vector3(x - 2, y, z) + transform.position);
         if (chunk != null)
         {
             StartCoroutine(chunk.CreateVisualMesh(false));
         }
     }
     if (x == width - 1)
     {
         Chunk chunk = FindChunk(new Vector3(x + 2, y, z) + transform.position);
         if (chunk != null)
         {
             StartCoroutine(chunk.CreateVisualMesh(false));
         }
     }
     if (z == 0)
     {
         Chunk chunk = FindChunk(new Vector3(x, y, z - 2) + transform.position);
         if (chunk != null)
         {
             StartCoroutine(chunk.CreateVisualMesh(false));
         }
     }
     if (z == width - 1)
     {
         Chunk chunk = FindChunk(new Vector3(x, y, z + 2) + transform.position);
         if (chunk != null)
         {
             StartCoroutine(chunk.CreateVisualMesh(false));
         }
     }
     return(true);
 }