Beispiel #1
0
        public void GenInitialChunks(long seed, int size)
        {
            UpdateCurChunkNoAdj();

            Console.WriteLine("new ChunkHandler");

            ChunkGenerator = new ChunkGenerator(this, seed);

            int numChunks = size / 16;

            ChunkArray = new Chunk[numChunks, numChunks];
            for (int x = 0; x < numChunks; x++)
            {
                for (int y = 0; y < numChunks; y++)
                {
                    int   chunkAdjX = (x * 16);
                    int   chunkAdjY = (y * 16);
                    Chunk newChunk  = new Chunk(x, y);
                    GetChunk(ref newChunk, newChunk.x, newChunk.y);

                    /*for (int bX = 0; bX < 16; bX++)
                     *      for (int bY = 0; bY < 128; bY++)
                     *              for(int bZ = 0; bZ < 16; bZ++) {
                     *      newChunk.blocks[(bY * 16 + bZ) * 16 + bX] = blocks[(bY * size + (bZ + chunkAdjY)) * size + (bX + chunkAdjX)];
                     * }*/
                    ChunkArray[y, x] = newChunk;
                }
            }
            DecorateChunks();
            UpdateCurChunk();
        }
Beispiel #2
0
        public ChunkHandler(BlockRaw[] blocks, int size, Game game)
        {
            this.game      = game;
            ChunkGenerator = new ChunkGenerator(this);

            int numChunks = size / 16;

            ChunkArray = new Chunk[numChunks, numChunks];
            for (int x = 0; x < numChunks; x++)
            {
                for (int y = 0; y < numChunks; y++)
                {
                    int   chunkAdjX = (x * 16);
                    int   chunkAdjY = (y * 16);
                    Chunk newChunk  = new Chunk(x, y);
                    for (int bX = 0; bX < 16; bX++)
                    {
                        for (int bY = 0; bY < 128; bY++)
                        {
                            for (int bZ = 0; bZ < 16; bZ++)
                            {
                                newChunk.blocks[(bY * 16 + bZ) * 16 + bX] = blocks[(bY * size + (bZ + chunkAdjY)) * size + (bX + chunkAdjX)];
                            }
                        }
                    }
                    ChunkArray[y, x] = newChunk;
                }
            }
        }
Beispiel #3
0
 public ChunkHandler(int size, Game game)
 {
     this.game      = game;
     ChunkArray     = new Chunk[size, size];
     ChunkGenerator = new ChunkGenerator(this);
 }