Esempio n. 1
0
 public void CreateTreeAt(int x, int y, int z, Chunk chunk)
 {
     for(int i = 1; i < 6; i++){
         chunk.SetBlock(x, y + i, z, Block.log);
     }
     for(int X = -2; X <= 2; X++)
         for(int Y = 0; Y < 3; Y++)
             for(int Z = -2; Z <= 2; Z++)
                 chunk.world.SetBlockSilent(chunk.GetWorldLocation() + new OpenTK.Vector3(x+X,y+Y+4,z+Z), Block.leaf);
 }
Esempio n. 2
0
        public void Generate(Chunk chunk)
        {
            WorldQuad[,] quads = new WorldQuad[Chunk.scale, Chunk.scale];
            for (int x = 0; x < Chunk.scale; x++)
            {
                for (int z = 0; z < Chunk.scale; z++)
                {
                    //Generate quads to quad array
                    quads[x,z] = GenerateQuad((int)chunk.GetWorldLocation().X + x, (int)chunk.GetWorldLocation().Z + z);
                }
            }

            for (int x = 0; x < Chunk.scale; x++)
            {
                for (int z = 0; z < Chunk.scale; z++)
                {
                    float dist = GetNearestWaterDistance(x, z, quads);
                    quads[x,z].moisture = dist;
                    quads[x,z].heat *= dist;
                    //Do stuff based on surrounding quads
                }
            }

            for (int x = 0; x < Chunk.scale; x++)
            {
                for (int z = 0; z < Chunk.scale; z++)
                {
                    //Finally set blocks
                    int chunkYOffset = (int)chunk.GetWorldLocation().Y;
                    WorldQuad quad = quads[x,z];
                    Biome biome = Biome.simple;

                    foreach(Biome b in biomes)
                    {
                        if((quad.moisture <= b.moistureHigh) &&
                           (quad.moisture >= b.moistureLow) &&
                           (quad.heat <= b.heightHigh) &&
                           (quad.heat >= b.heightLow))
                        {
                            biome = b;
                            break;
                        }
                    }
                    chunk.SetBlock(x, quad.height - chunkYOffset, z, biome.topBlock);
                    if(quads[x,z].isOcean)
                        chunk.SetBlock(x, 30 - chunkYOffset, z, Block.water);
                }
            }
        }