Exemplo n.º 1
0
 public ActiveTile(PersistentTile _persistentTile)
 {
     persistentTile       = _persistentTile;
     edgeTransitionData   = new Dictionary <ushort, byte>();
     cornerTransitionData = new Dictionary <ushort, byte>();
     transitionData       = new List <KeyValuePair <ushort, byte> >();
 }
Exemplo n.º 2
0
        private void DeserializeWorldChunks(WorldData worldData)
        {
            byte b; //represents 8 booleans compacted into a single byte

            int numChunks = reader.ReadInt32();

            Chunk[]          chunks = new Chunk[numChunks];
            PersistentTile[] tiles;

            for (int i = 0; i < numChunks; i++)
            {
                tiles = new PersistentTile[Config.CHUNK_SIZE * Config.CHUNK_SIZE];
                for (int j = 0; j < tiles.Length; j++)
                {
                    tiles[j] = new PersistentTile();

                    b = reader.ReadByte();
                    tiles[j].GroundTileId = reader.ReadByte();

                    if ((b & (byte)Masks.WallPresent) == (byte)Masks.WallPresent)
                    {
                        tiles[j].ObjectTileId = reader.ReadByte();
                    }
                }
                chunks[i] = new Chunk(tiles);
            }

            worldData.SetChunks(chunks);
        }
Exemplo n.º 3
0
        public Chunk()
        {
            activeTiles = new ActiveTile[Config.CHUNK_SIZE * Config.CHUNK_SIZE];
            tileData    = new PersistentTile[Config.CHUNK_SIZE * Config.CHUNK_SIZE];

            for (int i = 0; i < tileData.Length; i++)
            {
                tileData[i] = new PersistentTile();
            }
        }
Exemplo n.º 4
0
        public Chunk(GenerationData genData, int chunkX, int chunkY, int globalWidth)
        {
            activeTiles = new ActiveTile[Config.CHUNK_SIZE * Config.CHUNK_SIZE];
            tileData    = new PersistentTile[Config.CHUNK_SIZE * Config.CHUNK_SIZE];

            int localTileIndex = 0;
            int globalTileIndex;

            int startingTileY = (chunkY * Config.CHUNK_SIZE);
            int startingTileX = (chunkX * Config.CHUNK_SIZE);

            for (int y = startingTileY; y < (startingTileY + Config.CHUNK_SIZE); y++)
            {
                for (int x = startingTileX; x < (startingTileX + Config.CHUNK_SIZE); x++)
                {
                    globalTileIndex          = (y * globalWidth) + x;
                    tileData[localTileIndex] = new PersistentTile(genData.pointData[globalTileIndex]);
                    localTileIndex++;
                }
            }
        }