Beispiel #1
0
        private void AddCellToChunk(int x, int z, HexCell cell)
        {
            int          chunkX = x / HexMetrics.chunkSizeX;
            int          chunkZ = z / HexMetrics.chunkSizeZ;
            HexGridChunk chunk  = chunks[chunkX + chunkZ * chunkCountX];

            int localX = x - chunkX * HexMetrics.chunkSizeX;
            int localZ = z - chunkZ * HexMetrics.chunkSizeZ;

            chunk.AddCell(localX + localZ * HexMetrics.chunkSizeX, cell);
        }
Beispiel #2
0
        private void CreateChunks()
        {
            chunks = new HexGridChunk[chunkCountX * chunkCountZ];

            for (int z = 0, i = 0; z < chunkCountZ; z++)
            {
                for (int x = 0; x < chunkCountX; x++)
                {
                    HexGridChunk chunk = chunks[i++] = Instantiate(chunkPrefab);
                    chunk.transform.SetParent(transform);
                }
            }
        }
Beispiel #3
0
        private void CreateChunks()
        {
            columns = new Transform[chunkCountX];
            for (int x = 0; x < chunkCountX; x++)
            {
                columns[x] = new GameObject("Column").transform;
                columns[x].SetParent(transform, false);
            }

            chunks = new HexGridChunk[chunkCountX * chunkCountZ];

            for (int z = 0, i = 0; z < chunkCountZ; z++)
            {
                for (int x = 0; x < chunkCountX; x++)
                {
                    HexGridChunk chunk = chunks[i++] = Instantiate(chunkPrefab);
                    chunk.transform.SetParent(columns[x], false);
                }
            }
        }