Exemplo n.º 1
0
        public void BuildHeight(INoise noise)
        {
            //Build the chunk blocks
            for (int x = 0; x < ChunkSizeX; x++)
            {
                for (int z = 0; z < ChunkSizeZ; z++)
                {
                    BiomeAttributes biome = m_owner.GetBiome(x, z);

                    for (int y = 0; y < ChunkSizeY; y++)
                    {
                        //Vector3 pos = ;
                        int worldX = (int)(x + m_gameObject.transform.position.x);
                        int worldY = (int)(y + m_gameObject.transform.position.y);
                        int worldZ = (int)(z + m_gameObject.transform.position.z);

                        float value = noise.Compute(worldX, worldY, worldZ);

                        //TODO: Apply the noise and the biome
                        if (y < value)
                        {
                            Blocks[x, y, z] = new Block(
                                biome.Block,
                                new Vector3(x, y, z),
                                m_owner,
                                this);
                        }
                        else
                        {
                            Blocks[x, y, z] = Block.Empty(
                                new Vector3(x, y, z),
                                m_owner,
                                this);
                        }
                    }
                }
            }

            State = ChunkState.Draw;
        }