Ejemplo n.º 1
0
        /// <summary>
        /// Saves the file to the specified stream.
        /// </summary>
        /// <param name="stream">The stream to save to.</param>
        public override void Save(Stream stream)
        {
            BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("us-ascii"));

            writer.Write(Width);
            writer.Write(Height);

            for (int h = Height - 1; h >= 0; h--)
            {
                for (int w = 0; w < Width; w++)
                {
                    TilePatch tile = tiles[h, w];
                    writer.Write(tile.Brush);
                    writer.Write(tile.TileIndex);
                    writer.Write(tile.TileSet);
                    writer.Write(tile.Tile);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("us-ascii"));

            int width  = reader.ReadInt32();
            int height = reader.ReadInt32();

            tiles = new TilePatch[height, width];

            for (int h = height - 1; h >= 0; h--)
            {
                for (int w = 0; w < width; w++)
                {
                    TilePatch tile = new TilePatch();
                    tile.Brush     = reader.ReadByte();
                    tile.TileIndex = reader.ReadByte();
                    tile.TileSet   = reader.ReadByte();
                    tile.Tile      = reader.ReadInt32();

                    tiles[h, w] = tile;
                }
            }
        }