예제 #1
0
    private void GenerateChunk(int chunkSize)
    {
        chunkBlocks = new Block[chunkSize, chunkSize, chunkSize];
        Biome biome = BiomeUtils.SelectBiome(this.chunkObject.transform.position);

        for (int z = 0; z < chunkSize; z++)
        {
            for (int y = 0; y < chunkSize; y++)
            {
                for (int x = 0; x < chunkSize; x++)
                {
                    float     worldX     = x + chunkObject.transform.position.x;
                    float     worldY     = y + chunkObject.transform.position.y;
                    float     worldZ     = z + chunkObject.transform.position.z;
                    BlockType biomeBlock = biome.GenerateTerrain(worldX, worldY, worldZ);
                    chunkBlocks[x, y, z] = new Block(biomeBlock, this,
                                                     new Vector3(x, y, z));

                    if (biomeBlock == World.blockTypes[BlockType.Type.AIR])
                    {
                        this.status = chunkStatus.TO_DRAW;
                    }
                }
            }
        }

        if (status == chunkStatus.TO_DRAW)
        {
            string chunkName = (int)this.chunkObject.transform.position.x + "_" +
                               ((int)this.chunkObject.transform.position.y - 16) + "_" +
                               (int)this.chunkObject.transform.position.z;
            Chunk chunkBelow;

            if (World.chunks.TryGetValue(chunkName, out chunkBelow))
            {
                chunkBelow.status = chunkStatus.TO_DRAW;
            }
        }
    }