예제 #1
0
파일: FollowPath.cs 프로젝트: Thaon/Chiara
    void BuildPathFromChunk(ChunkBuilder chunk)
    {
        //we take into consideration all the stone tiles that have at least 2 empty blocks above
        //z
        for (int z = 0; z < chunk.GetWorldXZ(); z++)
        {
            //y
            for (int y = 0; y < chunk.GetWorldY(); y++)
            {
                for (int x = 0; x < chunk.GetWorldXZ(); x++)
                {
                    //x
                    if (chunk.GetVoxelNameAtPosition(x,y,z) == "Stone")
                    {
                        if (chunk.GetVoxelNameAtPosition(x, y + 1, z) == "NULL" && chunk.GetVoxelNameAtPosition(x, y + 2, z) == "NULL")
                        {
                            //we add the chunk's position to the voxel's position in the chunk, plus the offset from the corner of the block to the center
                            Vector3 actualPosition = chunk.gameObject.transform.position + new Vector3(x, y + 1, z) + new Vector3 (.5f, .5f, .5f);
                            m_waypoints.Add(actualPosition);
                        }
                    }
                }

            }
        }
    }
예제 #2
0
파일: FollowPath.cs 프로젝트: Thaon/Chiara
 void BuildPathFromChunk(ChunkBuilder chunk)
 {
     //we take into consideration all the stone tiles that have at least 2 empty blocks above
     //z
     for (int z = 0; z < chunk.GetWorldXZ(); z++)
     {
         //y
         for (int y = 0; y < chunk.GetWorldY(); y++)
         {
             for (int x = 0; x < chunk.GetWorldXZ(); x++)
             {
                 //x
                 if (chunk.GetVoxelNameAtPosition(x, y, z) == "Stone")
                 {
                     if (chunk.GetVoxelNameAtPosition(x, y + 1, z) == "NULL" && chunk.GetVoxelNameAtPosition(x, y + 2, z) == "NULL")
                     {
                         //we add the chunk's position to the voxel's position in the chunk, plus the offset from the corner of the block to the center
                         Vector3 actualPosition = chunk.gameObject.transform.position + new Vector3(x, y + 1, z) + new Vector3(.5f, .5f, .5f);
                         m_waypoints.Add(actualPosition);
                     }
                 }
             }
         }
     }
 }