Ejemplo n.º 1
0
        private void AddCellToChunk(int x, int z, HexCell cell)
        {
            int          chunkX = x / HexMetrics.CHUNK_SIZE_X;
            int          chunkZ = z / HexMetrics.CHUNK_SIZE_Z;
            HexGridChunk chunk  = _chunks[chunkX + chunkZ * ChunkCountX];

            int localX = x - chunkX * HexMetrics.CHUNK_SIZE_X;
            int localZ = z - chunkZ * HexMetrics.CHUNK_SIZE_Z;

            chunk.AddCell(localX + localZ * HexMetrics.CHUNK_SIZE_X, cell);
        }
Ejemplo n.º 2
0
        private void CreateChunks()
        {
            _chunks = new HexGridChunk[ChunkCountZ * ChunkCountX];

            for (int z = 0, index = 0; z < ChunkCountZ; z++)
            {
                for (int x = 0; x < ChunkCountX; x++)
                {
                    HexGridChunk chunk = _chunks[index++] = Instantiate(ChunkPrefab);
                    chunk.transform.SetParent(transform);
                }
            }
        }