Esempio n. 1
0
        public void Generate(MapGenerationInfo info, int chunkX, int chunkZ, ChunkColumnStorage chunk, Biome biome)
        {
            int range = _range;

            _info = info;
            _rand = new Random(info.Seed);
            int rand1 = _rand.Next();
            int rand2 = _rand.Next();

            // 遍历周围(range*2+1)*(range*2+1)的区块,默认range=8
            for (int x = chunkX - range; x <= chunkX + range; ++x)
            {
                for (int z = chunkZ - range; z <= chunkZ + range; ++z)
                {
                    int randX = x * rand1;
                    int randZ = z * rand2;
                    _rand = new Random(randX ^ randZ ^ info.Seed);

                    // 调用子类方法
                    RecursiveGenerate(info, x, z, chunkX, chunkZ, chunk, biome);
                }
            }
        }
Esempio n. 2
0
 protected abstract void RecursiveGenerate(MapGenerationInfo info, int chunkX, int chunkZ, int centerChunkX, int centerChunkZ, ChunkColumnStorage chunk, Biome biome);
Esempio n. 3
0
 public MapGenerator(MapGenerationInfo info, int range = 8)
 {
     _range = range;
     _rand  = null;
     _info  = info;
 }