Пример #1
0
 public void GenerateSector(Vector3i Location)
 {
     Sector chunk = new Sector(Realm, Location);
     foreach (WorldGenerator gen in Generators) {
         gen.Generate(chunk);
     }
     Mappings.Add(Location, chunk);
 }
Пример #2
0
 private void GenerateWater(Sector current, int ChunkZ)
 {
     for (int x = 0; x < Sector.Size.X; x++) {
         for (int y = 0; y < Sector.Size.Y; y++) {
             for (int z = (int)current_heightmap.GetPixel(x, y).R - 100 + 1; z <= WaterLevel; z++) {
                 current[new Vector3i(x, y, z - (ChunkZ * Sector.Size.Z))] = new Block(WaterGuid);
             }
         }
     }
 }
Пример #3
0
        private void GenerateBase(Sector chunk, int ChunkZ)
        {
            Random ran = new Random();

            //Create Terrain
            for (int x = 0; x < Sector.Size.X; x++) {
                for (int y = 0; y < Sector.Size.Y; y++) {
                    for (int z = 0; z < Sector.Size.Z; z++) {
                        Vector3i Location = new Vector3i(x, y, z);
                        if (z + (ChunkZ * Sector.Size.Z) < current_heightmap.GetPixel(x, y).R - 100) {
                            if (z + (ChunkZ * Sector.Size.Z) > current_heightmap.GetPixel(x, y).R - 100 - (int)(5 + ran.Next(3))) {
                                chunk[Location] = new Block(DirtGuid);
                            } else {
                                chunk[Location] = new Block(GraniteGuid);
                            }
                        }

                        if (z + (ChunkZ * Sector.Size.Z) == current_heightmap.GetPixel(x, y).R - 100) {
                            chunk[Location] = new Block(GrassGuid);
                        }
                    }
                }
            }
        }
Пример #4
0
 public virtual void Generate(Sector chunk)
 {
     current_heightmap = HeightMap.GetHeightmap(chunk.ChunkLocation.X, chunk.ChunkLocation.Y);
     GenerateBase(chunk, chunk.ChunkLocation.Z);
     GenerateWater(chunk, chunk.ChunkLocation.Z);
 }