示例#1
0
        public static MapCellData FromByte(byte b)
        {
            MapCellData result = new MapCellData();

            result.Area          = (MapLevel)(b & 0x1C);
            result.UseAltPalette = (0 != (b & 0x2));
            int animation = (b >> 4) & 0xe;

            animation       |= (b & 1);
            result.Animation = animation;

            return(result);
        }
示例#2
0
        /// <summary>
        /// Sets the image to be used at a specified map position.
        /// </summary>
        private void SetMapLocationData(int x, int y, MapCellData area)
        {
            this.bltDest.X       = x * mapTileWidth;
            this.bltDest.Y       = y * mapTileHeight;
            this.bltSource.X     = (int)area.Area * 8;
            this.bltSource.Width = this.bltSource.Height = 8;

            this._gMapImage.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            this._gMapImage.DrawImage(this.ClassicTiles, this.bltDest, this.bltSource, GraphicsUnit.Pixel);

            this.MapData[x, y] = area;


            if (!isLoadingMapData && RoomSet != null)
            {
                RoomSet(this, x, y);
            }
        }
示例#3
0
        /// <summary>
        /// Loads a map from a stream.
        /// </summary>
        /// <param name="s">Stream containing map data.</param>
        /// <param name="hasHeader"></param>
        /// <returns>T boolean value that indicates success or failure.</returns>
        public bool TryLoadData(Stream s, bool hasHeader)
        {
            isLoadingMapData = true;
            try {
                if (hasHeader)
                {
                    for (int i = 0; i < MagicValue.Length; i++)
                    {
                        try {
                            if (s.CanRead == false)
                            {
                                return(false);
                            }

                            if (s.ReadByte() != MagicValue[i])
                            {
                                return(false);
                            }
                        }
                        catch (Exception) {
                            return(false);
                        }
                    }

                    Invalidate();
                }
                for (int i = 0; i < 0x20; i++)
                {
                    for (int j = 0; j < 0x20; j++)
                    {
                        this.SetMapLocationData(j, i, MapCellData.FromByte((byte)s.ReadByte()));
                    }
                }

                return(true);
            }
            finally {
                isLoadingMapData = false;
            }
        }