예제 #1
0
        private void GenerateChunk(int chunkX, int chunkY)
        {
            IProgress <string> progress = new Progress <string>(message => Console.WriteLine(message));

            //_chunks[chunkY, chunkX] = new CavernChunkGenerator(_blocks, CHUNK_WIDTH, CHUNK_HEIGHT, "hello!").Generate(progress);
            //_chunks[chunkY, chunkX] = new DugoutDungeonChunkGenerator(_blocks, CHUNK_WIDTH, CHUNK_HEIGHT, null).Generate(progress);
            //_chunks[chunkY, chunkX] = new LabyrinthChunkGenerator(_blocks, CHUNK_WIDTH, CHUNK_HEIGHT, null).Generate(progress);
            //_chunks[chunkY, chunkX] = new BSPDungeonChunkGenerator( CHUNK_WIDTH, CHUNK_HEIGHT, null).Generate(progress);

            //_chunks[chunkY, chunkX] = new OverworldChunkGenerator(CHUNK_WIDTH, CHUNK_HEIGHT, null, chunkX, chunkY).Generate(progress);
            _chunks[chunkY, chunkX] = _generator.Generate(progress, chunkX, chunkY);
        }
예제 #2
0
 public void Generate(IChunkGenerator generator)
 {
     BlockType[,,] generatedBlocks = generator.Generate(ChunkPos);
     for (int x = 0; x < BlockSize; x++)
     {
         for (int y = 0; y < BlockSize; y++)
         {
             for (int z = 0; z < BlockSize; z++)
             {
                 blocks[x + 1, y + 1, z + 1] = generatedBlocks[x, y, z];
             }
         }
     }
 }
예제 #3
0
    public BlockType[,,] Generate(Point3D chunkPos)
    {
        int chunkIndex;

        if (hashToFileOffset.TryGetValue(chunkPos.ToString(), out chunkIndex))
        {
            UnityEngine.Debug.Log("Load: " + chunkPos);
            return(chunkStorer.Load(chunkIndex));
        }
        else
        {
            return(generator.Generate(chunkPos));
        }
    }
예제 #4
0
        public void GenerateChunks()
        {
            int chunkWidth  = _world.EngineConfiguration.ChunkWidth;
            int chunkHeight = _world.EngineConfiguration.ChunkHeight;
            int chunkLength = _world.EngineConfiguration.ChunkLength;

            for (int x = 0; x < _worldWidth; x++)
            {
                for (int y = 0; y < _worldHeight; y++)
                {
                    for (int z = 0; z < _worldLength; z++)
                    {
                        int index = ArrayUtil.Convert3DTo1D(x, y, z, _worldLength, _worldHeight);

                        Chunk c = new Chunk(_world, new Vector3I(x * chunkWidth, y * chunkHeight, z * chunkLength), chunkWidth, chunkHeight, chunkLength);
                        _chunkGenerator.Generate(c);

                        _chunks[index] = c;
                    }
                }
            }
        }
        /// <inheritdoc />
        Chunk IChunkLoader.Load(ChunkCoordinate location)
        {
            var chunk = _generator.Generate(location);

            return(chunk);
        }