Esempio n. 1
0
    void AddCellToChunk(int x, int z, SquareCell cell)
    {
        int             chunkX = x / GridMetrics.chunkSizeX;
        int             chunkZ = z / GridMetrics.chunkSizeZ;
        SquareGridChunk chunk  = chunks[chunkX + chunkZ * chunkCountX];

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

        chunk.AddCell(localX + localZ * GridMetrics.chunkSizeX, cell);
    }
Esempio n. 2
0
    void CreateChunks()
    {
        chunkCountX = sizeX / SquareMetrics.chunkSizeX;
        chunkCountY = sizeY / SquareMetrics.chunkSizeY;
        chunks      = new SquareGridChunk[chunkCountX * chunkCountY];

        for (int z = 0, i = 0; z < chunkCountY; z++)
        {
            for (int x = 0; x < chunkCountX; x++)
            {
                SquareGridChunk chunk = chunks[i++] = Instantiate(squareGridChunk);
                chunk.transform.SetParent(transform);
            }
        }
    }
Esempio n. 3
0
    void CreateChunks()
    {
        chunks  = new SquareGridChunk[chunkCountX * chunkCountZ];
        spheres = new BoundingSphere[chunkCountX * chunkCountZ];

        for (int z = 0, i = 0; z < chunkCountZ; z++)
        {
            for (int x = 0; x < chunkCountX; x++)
            {
                SquareGridChunk chunk = chunks[i] = Instantiate(chunkPrefab);
                spheres[i] = new BoundingSphere(new Vector3((x + 0.5f) * GridMetrics.chunkSizeX, 0, (z + 0.5f) * GridMetrics.chunkSizeZ), Mathf.Max(GridMetrics.chunkSizeX, GridMetrics.chunkSizeZ));
                i++;
                chunk.transform.SetParent(transform);
            }
        }
        chunkCuller.SetBoundingSpheres(spheres);
        chunkCuller.SetBoundingSphereCount(chunkCountX * chunkCountZ);
    }