Esempio n. 1
0
        internal TileLayer(ContentReader reader, TileRegistry registry)
            : base(reader)
        {
            _registry = registry;

            TileWidth  = reader.ReadInt16();
            TileHeight = reader.ReadInt16();
            Width      = reader.ReadInt16();
            Height     = reader.ReadInt16();

            _tiles = new TileGrid(Width, Height);

            int tileCount = reader.ReadInt32();

            for (int i = 0; i < tileCount; i++)
            {
                int dx     = reader.ReadInt16();
                int dy     = reader.ReadInt16();
                int tileId = reader.ReadInt32();

                if (_tiles[dx, dy] == null)
                {
                    _tiles[dx, dy] = new TileStack(_registry[tileId]);
                }
                else
                {
                    _tiles[dx, dy] = new TileStack(_tiles[dx, dy], _registry[tileId]);
                }
            }

            /*int stackCount = reader.ReadInt32();
             * for (int i = 0; i < stackCount; i++) {
             *  int dx = reader.ReadInt16();
             *  int dy = reader.ReadInt16();
             *
             *  int tcount = reader.ReadInt16();
             *  Tile[] st = new Tile[tcount];
             *
             *  for (int j = 0; j < tcount; j++) {
             *      st[j] = _registry[reader.ReadInt16()];
             *  }
             *
             *  _tiles[dx, dy] = new TileStack(st);
             * }*/
        }
Esempio n. 2
0
 internal TileStack(TileStack tiles, Tile tile)
 {
     _tiles = new Tile[tiles.Count + 1];
     tiles._tiles.CopyTo(_tiles, 0);
     _tiles[_tiles.Length - 1] = tile;
 }