/* Add Cell To Chunk*/
        private void AddCellToChunk(int x, int z, ref HexCell cell)
        {
            int      chunkX = x / hexesPerChunkX;
            int      chunkZ = z / hexesPerChunkZ;
            HexChunk chunk  = m_chunks[chunkX + chunkZ * numberOfChunksX];

            int localX = x - chunkX * hexesPerChunkX;
            int localZ = z - chunkZ * hexesPerChunkZ;

            chunk.AddCell(localX + localZ * hexesPerChunkX, ref cell);
        }
        /* Generate Chunks */
        private void GenerateChunks()
        {
            m_chunks = new HexChunk[numberOfChunksX * numberOfChunksZ];

            for (int z = 0, i = 0; z < numberOfChunksZ; z++)
            {
                for (int x = 0; x < numberOfChunksX; x++)
                {
                    HexChunk chunk = m_chunks[i++] = Instantiate(chunkPrefab);
                    chunk.transform.SetParent(transform);
                }
            }
        }
Beispiel #3
0
        }                                               // remember the direction from the path



        /* Set Chunk */
        public void SetChunk(HexChunk chunk)
        {
            this.m_chunk = chunk;
        }