Ejemplo n.º 1
0
        public override bool CanMoveTo(Point2D newLocation, ref string err)
        {
            if ( ! base.CanMoveTo (newLocation, ref err) )
                return false;

            // Care only about absolutes for knights
            int dx = Math.Abs( newLocation.X - m_Position.X );
            int dy = Math.Abs( newLocation.Y - m_Position.Y );

            if ( ! ( ( dx == 1 && dy == 2 ) || ( dx == 2 && dy == 1 ) ) )
            {
                err = "Knights can only make L shaped moves (2-3 tiles length)";
                return false; // Wrong move
            }

            // Verify target piece
            BaseChessPiece piece = m_BChessboard[ newLocation ];

            if ( piece == null || piece.Color != m_Color )
                return true;
            else
            {
                err = "You can't capture pieces of your same color";
                return false;
            }
        }
Ejemplo n.º 2
0
        public override ArrayList GetMoves(bool capture)
        {
            ArrayList moves = new ArrayList();

            for ( int dx = -2; dx <= 2; dx++ )
            {
                for ( int dy = -2; dy <= 2; dy++ )
                {
                    if ( ! ( ( Math.Abs( dx ) == 1 && Math.Abs( dy ) == 2 ) || ( Math.Abs( dx ) == 2 && Math.Abs( dy ) == 1 ) ) )
                        continue;

                    Point2D p = new Point2D( m_Position.X + dx, m_Position.Y + dy );

                    if ( ! m_BChessboard.IsValid( p ) )
                        continue;

                    BaseChessPiece piece = m_BChessboard[ p ];

                    if ( piece == null )
                        moves.Add( p );
                    else if ( capture && piece.Color != m_Color )
                        moves.Add( p );
                }
            }

            return moves;
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Creates a new Move object without capturing a piece
		/// </summary>
		/// <param name="piece">The chess piece performing the move</param>
		/// <param name="target">The target location of the move</param>
		public Move( BaseChessPiece piece, Point2D target )
		{
			m_Piece = piece;
			m_From = m_Piece.Position;
			m_To = target;
			m_Captured = m_Piece.GetCaptured( target, ref m_EnPassant );
		}
Ejemplo n.º 4
0
		public static MahjongPieceDim GetDimensions( Point2D position, MahjongPieceDirection direction )
		{
			if ( direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down )
				return new MahjongPieceDim( position, 40, 20 );
			else
				return new MahjongPieceDim( position, 20, 40 );
		}
Ejemplo n.º 5
0
        public MultiComponentList( MultiComponentList toCopy )
        {
            m_Min = toCopy.m_Min;
            m_Max = toCopy.m_Max;

            m_Center = toCopy.m_Center;

            m_Width = toCopy.m_Width;
            m_Height = toCopy.m_Height;

            m_Tiles = new StaticTile[m_Width][][];

            for ( int x = 0; x < m_Width; ++x )
            {
                m_Tiles[x] = new StaticTile[m_Height][];

                for ( int y = 0; y < m_Height; ++y )
                {
                    m_Tiles[x][y] = new StaticTile[toCopy.m_Tiles[x][y].Length];

                    for ( int i = 0; i < m_Tiles[x][y].Length; ++i )
                        m_Tiles[x][y][i] = toCopy.m_Tiles[x][y][i];
                }
            }

            m_List = new MultiTileEntry[toCopy.m_List.Length];

            for ( int i = 0; i < m_List.Length; ++i )
                m_List[i] = toCopy.m_List[i];
        }
Ejemplo n.º 6
0
        private static void LoadLocations()
        {
            string filePath = Path.Combine(Core.BaseDirectory, "Data/treasure.cfg");

            ArrayList list = new ArrayList();
            ArrayList havenList = new ArrayList();

            if (File.Exists(filePath))
            {
                using (StreamReader ip = new StreamReader(filePath))
                {
                    string line;

                    while ((line = ip.ReadLine()) != null)
                    {
                        try
                        {
                            string[] split = line.Split(' ');

                            int x = Convert.ToInt32(split[0]), y = Convert.ToInt32(split[1]);

                            Point2D loc = new Point2D(x, y);
                            list.Add(loc);
                        }
                        catch
                        {
                        }
                    }
                }
            }

            m_Locations = (Point2D[])list.ToArray(typeof(Point2D));
        }
Ejemplo n.º 7
0
		public MahjongDealerIndicator( MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind )
		{
			m_Game = game;
			m_Position = position;
			m_Direction = direction;
			m_Wind = wind;
		}
Ejemplo n.º 8
0
			public TrackingInfo( Mobile tracker, Mobile target )
			{
				m_Tracker = tracker;
				m_Target = target;
				m_Location = new Point2D( target.X, target.Y );
				m_Map = target.Map;
			}
Ejemplo n.º 9
0
		public MahjongWallBreakIndicator( MahjongGame game, GenericReader reader )
		{
			m_Game = game;

			int version = reader.ReadInt();

			m_Position = reader.ReadPoint2D();
		}
Ejemplo n.º 10
0
		public TreasureMessage( int level, Map map )
		{
			Name = "a handwritten message";
			Hue = 0x2EF;
			m_Level = level;
			m_Map = map;
			m_MessageIndex = Utility.Random( MessageEntry.Entries.Length );
			m_Location = GetRandomLocation();
		}
Ejemplo n.º 11
0
		//----------------------------------------------------------------------
		//  Here, we are going to search the quadrant that it is ahead of the player, because
		//  he is running
		//----------------------------------------------------------------------
		public static bool FindAhead(
			PlayerMobile pm,
			Point3D centerPoint,
			ref Point3D spawnPoint,
			LandType landType,
			int distance,
			EffectType effectType,
			int effectHue
			)
		{
			Direction dir = (Direction)((int)pm.Direction & 0x0f);

			Point3D foundPoint = new Point3D();

			Tour tour = delegate( Map map, int x, int y )
			{
				if( Utility.RandomDouble() < .5 ) return false; // break it up a little.

				Point2D currentPoint = new Point2D( pm.Location.X + x, pm.Location.Y + y );

				if( FindSpawnTileInternal(
						pm,
						centerPoint,
						currentPoint,
						ref foundPoint,
						landType,
						effectType,
						effectHue
						)
					)
				{
					return true;
				}

				return false;
			};

			bool found = Search.Octant(
				pm.Map,
				dir,
				distance,
				SearchDirection.Inwards,
				tour
				);

			if( found )
			{
				spawnPoint.X = foundPoint.X;
				spawnPoint.Y = foundPoint.Y;
				spawnPoint.Z = foundPoint.Z;

				return true;
			}

			return false;
		}
Ejemplo n.º 12
0
		public MahjongDealerIndicator( MahjongGame game, GenericReader reader )
		{
			m_Game = game;

			int version = reader.ReadInt();

			m_Position = reader.ReadPoint2D();
			m_Direction = (MahjongPieceDirection) reader.ReadInt();
			m_Wind = (MahjongWind) reader.ReadInt();
		}
Ejemplo n.º 13
0
		public MahjongTile( MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel, MahjongPieceDirection direction, bool flipped )
		{
			m_Game = game;
			m_Number = number;
			m_Value = value;
			m_Position = position;
			m_StackLevel = stackLevel;
			m_Direction = direction;
			m_Flipped = flipped;
		}
Ejemplo n.º 14
0
        public void EndCastle( Point2D location )
        {
            m_HasMoved = true;

            m_Move = new Move( this, location );

            Point2D worldLocation = m_BChessboard.BoardToWorld( location );

            m_Piece.GoTo( worldLocation );
        }
Ejemplo n.º 15
0
		public StudyObjective( Point2D point, int range, Map map, string[] messages, int seconds ) : base( 1, seconds )
		{
			Point = point;
			Range = range;
			Map = map;
			Messages = messages;
			OnMessage = 0;

			CheckTimer();
		}
Ejemplo n.º 16
0
		public void Move( Point2D position )
		{
			MahjongPieceDim dim = GetDimensions( position );

			if ( !dim.IsValid() )
				return;

			m_Position = position;

			m_Game.Players.SendGeneralPacket( true, true );
		}
Ejemplo n.º 17
0
        public MahjongTile( MahjongGame game, GenericReader reader )
        {
            m_Game = game;

            int version = reader.ReadInt();

            m_Number = reader.ReadInt();
            m_Value = (MahjongTileType) reader.ReadInt();
            m_Position = reader.ReadPoint2D();
            m_StackLevel = reader.ReadInt();
            m_Direction = (MahjongPieceDirection) reader.ReadInt();
            m_Flipped = reader.ReadBool();
        }
Ejemplo n.º 18
0
		public ToolbarInfo(
			Point2D dimensions, List<string> entries, int skin, List<Point3D> points, int font, bool[] switches)
		{
			_Dimensions = dimensions;
			_Entries = entries;
			_Skin = skin;
			_Points = points;
			_Font = font;
			_Phantom = switches[0];
			_Stealth = switches[1];
			_Reverse = switches[2];
			_Lock = switches[3];
		}
Ejemplo n.º 19
0
        public void Move( Point2D position, MahjongPieceDirection direction, MahjongWind wind )
        {
            MahjongPieceDim dim = GetDimensions( position, direction );

            if ( !dim.IsValid() )
            {
                return;
            }

            m_Position = position;
            m_Direction = direction;
            m_Wind = wind;

            m_Game.Players.SendGeneralPacket( true, true );
        }
Ejemplo n.º 20
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadEncodedInt();
			Point = reader.ReadPoint2D();
			Range = reader.ReadInt();
			Map = reader.ReadMap();

			int count = reader.ReadInt();
			Messages = new string[ count ];

			for ( int i = 0; i < count; i++ )
				Messages[i] = reader.ReadString();

			OnMessage = reader.ReadInt();
		}	
Ejemplo n.º 21
0
		public void Move( Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea )
		{
			MahjongPieceDim dim = GetDimensions( position, direction );
			int curHandArea = Dimensions.GetHandArea();
			int newHandArea = dim.GetHandArea();

			if ( !IsMovable || !dim.IsValid() || ( validHandArea >= 0 && ((curHandArea >= 0 && curHandArea != validHandArea) || (newHandArea >= 0 && newHandArea != validHandArea)) ) )
				return;

			m_Position = position;
			m_Direction = direction;
			m_StackLevel = -1; // Avoid self interference
			m_StackLevel = m_Game.GetStackLevel( dim ) + 1;
			m_Flipped = flip;

			m_Game.Players.SendTilePacket( this, true, true );
		}
Ejemplo n.º 22
0
        public override bool CanMoveTo(Point2D newLocation, ref string err)
        {
            if ( ! base.CanMoveTo (newLocation, ref err) )
                return false;

            int dx = newLocation.X - m_Position.X;
            int dy = newLocation.Y - m_Position.Y;

            if ( Math.Abs( dx ) != Math.Abs( dy ) )
            {
                err = "Bishops can move only on diagonals";
                return false; // Not a diagonal movement
            }

            int xDirection = dx > 0 ? 1 : -1;
            int yDirection = dy > 0 ? 1 : -1;

            if ( Math.Abs( dx ) > 1 )
            {
                // Verify that the path to target is empty
                for ( int i = 1; i < Math.Abs( dx ); i++ ) // Skip the bishop square and stop before target
                {
                    int xOffset = xDirection * i;
                    int yOffset = yDirection * i;

                    if ( m_BChessboard[ m_Position.X + xOffset, m_Position.Y + yOffset ] != null )
                    {
                        err = "Bishops can't move over other pieces";
                        return false;
                    }
                }
            }

            // Verify target piece
            BaseChessPiece piece = m_BChessboard[ newLocation ];

            if ( piece == null || piece.Color != m_Color )
            {
                return true;
            }
            else
            {
                err = "You can't capture pieces of your own color";
                return false;
            }
        }
Ejemplo n.º 23
0
		/// <summary>
		/// Moves the NPC to the specified location
		/// </summary>
		/// <param name="to">The location the NPC should move to</param>
		public void GoTo( Point2D to )
		{
			AI = AIType.AI_Melee;

			m_NextMove = new Point3D( to, Z );

			if ( m_Piece is Knight )
			{
				WayPoint end = new WayPoint();
				WayPoint start = new WayPoint();

				end.MoveToWorld( m_NextMove, Map );

				// This is a knight, so do L shaped move
				int dx = to.X - X;
				int dy = to.Y - Y;

				Point3D p = Location; // Point3D is a value type

				if ( Math.Abs( dx ) == 1 )
					p.X += dx;
				else
					p.Y += dy;

				start.MoveToWorld( p, Map );
				start.NextPoint = end;

				CurrentWayPoint = start;

				m_WayPoints.Add( start );
				m_WayPoints.Add( end );
			}
			else
			{
				WayPoint wp = new WayPoint();
				wp.MoveToWorld( m_NextMove, Map );
				CurrentWayPoint = wp;

				m_WayPoints.Add( wp );
			}

			Paralyzed = false;
		}
Ejemplo n.º 24
0
                protected override void OnTarget(Mobile from, object targ)
                {
                    if (targ is IPoint2D)
                    {
                        Point2D p = new Point2D((IPoint2D)targ);

                        if (!from.CheckSkill(SkillName.Musicianship, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(502472); // You don't seem to be able to persuade that to move.

                            m_Flute.PlayInstrumentBadly(from);
                        }
                        else if (!m_Snake.InRange(p, 10))
                        {
                            from.SendLocalizedMessage(500643); // Target is too far away.
                        }
                        else
                        {
                            m_Snake.BeginCharm(from, p);

                            from.SendLocalizedMessage(502479); // The animal walks where it was instructed to.

                            from.BeginAction(typeof(SnakeCharmerFlute));
                            Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(
                                delegate { from.EndAction(typeof(SnakeCharmerFlute)); }));

                            m_Flute.PlayInstrumentWell(from);
                            m_Flute.UsesRemaining--;

                            if (m_Flute.UsesRemaining == 0)
                            {
                                from.SendLocalizedMessage(1112177); // You broke your snake charmer flute.

                                m_Flute.Delete();
                            }
                        }
                    }
                }
Ejemplo n.º 25
0
        public override bool CanMoveTo(Point2D newLocation, ref string err)
        {
            if ( ! base.CanMoveTo (newLocation, ref err) )
                return false;

            // Verify if this is a castle
            BaseChessPiece rook = m_BChessboard[ newLocation ];

            if ( rook is Rook && rook.Color == m_Color )
            {
                // Trying to castle
                return m_BChessboard.AllowCastle( this, rook, ref err );
            }

            int dx = newLocation.X - m_Position.X;
            int dy = newLocation.Y - m_Position.Y;

            if ( Math.Abs( dx ) > 1 || Math.Abs( dy ) > 1 )
            {
                err = "The can king can move only 1 tile at a time";
                return false; // King can move only 1 tile away from its position
            }

            // Verify target piece
            BaseChessPiece piece = m_BChessboard[ newLocation ];

            if ( piece == null || piece.Color != m_Color )
            {
                return true;
            }
            else
            {
                err = "You can't capture pieces of your same color";
                return false;
            }
        }
Ejemplo n.º 26
0
 public static bool InUpdateRange(Point2D p1, Point2D p2)
 {
     return((p1.m_X >= (p2.m_X - 18)) && (p1.m_X <= (p2.m_X + 18)) && (p1.m_Y >= (p2.m_Y - 18)) &&
            (p1.m_Y <= (p2.m_Y + 18)));
 }
Ejemplo n.º 27
0
 public override void Write(Point2D value)
 {
     Write(value.m_X);
     Write(value.m_Y);
 }
Ejemplo n.º 28
0
 public void Transform(ref Point2D p, double offset)
 {
     Transform(ref p, this, offset);
 }
Ejemplo n.º 29
0
        public static Triangle2D Parse(string value)
        {
            var param = value.Split('+');

            if (param.Length >= 3 && param.All(p => p.Contains(',')))
            {
                return(new Triangle2D(Point2D.Parse(param[0]), Point2D.Parse(param[1]), Point2D.Parse(param[2])));
            }

            throw new FormatException(
                      "The specified triangle must be represented by three Point2D coords using the format " +           //
                      "'(x1,y1)+(x2,y2)+(x3,y3)'");
        }
Ejemplo n.º 30
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count];

            for (int i = 0; i < count; ++i)
            {
                allTiles[i].m_ItemID  = reader.ReadUInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();

                if (PostHSFormat)
                {
                    allTiles[i].m_Flags = (TileFlag)reader.ReadUInt64();
                }
                else
                {
                    allTiles[i].m_Flags = (TileFlag)reader.ReadUInt32();
                }

                MultiTileEntry e = allTiles[i];

                if (i == 0 || e.m_Flags != 0)
                {
                    if (e.m_OffsetX < m_Min.m_X)
                    {
                        m_Min.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY < m_Min.m_Y)
                    {
                        m_Min.m_Y = e.m_OffsetY;
                    }

                    if (e.m_OffsetX > m_Max.m_X)
                    {
                        m_Max.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY > m_Max.m_Y)
                    {
                        m_Max.m_Y = e.m_OffsetY;
                    }
                }
            }

            m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y);
            m_Width  = m_Max.m_X - m_Min.m_X + 1;
            m_Height = m_Max.m_Y - m_Min.m_Y + 1;

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new StaticTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new StaticTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                if (i == 0 || allTiles[i].m_Flags != 0)
                {
                    int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                    int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;
                    int itemID  = (allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000;

                    tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].m_OffsetZ);
                }
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                }
            }
        }
Ejemplo n.º 31
0
        public MultiComponentList(List <MultiTileEntry> list)
        {
            MultiTileEntry[] allTiles = m_List = new MultiTileEntry[list.Count];

            for (int i = 0; i < list.Count; ++i)
            {
                allTiles[i].m_ItemID  = list[i].m_ItemID;
                allTiles[i].m_OffsetX = list[i].m_OffsetX;
                allTiles[i].m_OffsetY = list[i].m_OffsetY;
                allTiles[i].m_OffsetZ = list[i].m_OffsetZ;

                allTiles[i].m_Flags = list[i].m_Flags;

                MultiTileEntry e = allTiles[i];

                if (i == 0 || e.m_Flags != 0)
                {
                    if (e.m_OffsetX < m_Min.m_X)
                    {
                        m_Min.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY < m_Min.m_Y)
                    {
                        m_Min.m_Y = e.m_OffsetY;
                    }

                    if (e.m_OffsetX > m_Max.m_X)
                    {
                        m_Max.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY > m_Max.m_Y)
                    {
                        m_Max.m_Y = e.m_OffsetY;
                    }
                }
            }

            m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y);
            m_Width  = m_Max.m_X - m_Min.m_X + 1;
            m_Height = m_Max.m_Y - m_Min.m_Y + 1;

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new StaticTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new StaticTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                if (i == 0 || allTiles[i].m_Flags != 0)
                {
                    int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                    int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;
                    int itemID  = (allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000;

                    tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].m_OffsetZ);
                }
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                }
            }
        }
Ejemplo n.º 32
0
 public override void Write(Point2D value)
 {
     this.Write(value.m_X);
     this.Write(value.m_Y);
 }
Ejemplo n.º 33
0
        public MultiComponentList(GenericReader reader)
        {
            int version = reader.ReadInt();

            m_Min    = reader.ReadPoint2D();
            m_Max    = reader.ReadPoint2D();
            m_Center = reader.ReadPoint2D();
            m_Width  = reader.ReadInt();
            m_Height = reader.ReadInt();

            int length = reader.ReadInt();

            MultiTileEntry[] allTiles = m_List = new MultiTileEntry[length];

            if (version == 0)
            {
                for (int i = 0; i < length; ++i)
                {
                    int id = reader.ReadShort();
                    if (id >= 0x4000)
                    {
                        id -= 0x4000;
                    }

                    allTiles[i].m_ItemID  = (ushort)id;
                    allTiles[i].m_OffsetX = reader.ReadShort();
                    allTiles[i].m_OffsetY = reader.ReadShort();
                    allTiles[i].m_OffsetZ = reader.ReadShort();
                    allTiles[i].m_Flags   = reader.ReadInt();
                }
            }
            else
            {
                for (int i = 0; i < length; ++i)
                {
                    allTiles[i].m_ItemID  = reader.ReadUShort();
                    allTiles[i].m_OffsetX = reader.ReadShort();
                    allTiles[i].m_OffsetY = reader.ReadShort();
                    allTiles[i].m_OffsetZ = reader.ReadShort();
                    allTiles[i].m_Flags   = reader.ReadInt();
                }
            }

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new StaticTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new StaticTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                if (i == 0 || allTiles[i].m_Flags != 0)
                {
                    int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                    int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;

                    tiles[xOffset][yOffset].Add((ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ);
                }
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                }
            }
        }
Ejemplo n.º 34
0
        public void Resize(int newWidth, int newHeight)
        {
            int oldWidth = m_Width, oldHeight = m_Height;

            Tile[][][] oldTiles = m_Tiles;

            int totalLength = 0;

            Tile[][][] newTiles = new Tile[newWidth][][];

            for (int x = 0; x < newWidth; ++x)
            {
                newTiles[x] = new Tile[newHeight][];

                for (int y = 0; y < newHeight; ++y)
                {
                    if (x < oldWidth && y < oldHeight)
                    {
                        newTiles[x][y] = oldTiles[x][y];
                    }
                    else
                    {
                        newTiles[x][y] = new Tile[0];
                    }

                    totalLength += newTiles[x][y].Length;
                }
            }

            m_Tiles  = newTiles;
            m_List   = new MultiTileEntry[totalLength];
            m_Width  = newWidth;
            m_Height = newHeight;

            m_Min = Point2D.Zero;
            m_Max = Point2D.Zero;

            int index = 0;

            for (int x = 0; x < newWidth; ++x)
            {
                for (int y = 0; y < newHeight; ++y)
                {
                    Tile[] tiles = newTiles[x][y];

                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        Tile tile = tiles[i];

                        int vx = x - m_Center.X;
                        int vy = y - m_Center.Y;

                        if (vx < m_Min.m_X)
                        {
                            m_Min.m_X = vx;
                        }

                        if (vy < m_Min.m_Y)
                        {
                            m_Min.m_Y = vy;
                        }

                        if (vx > m_Max.m_X)
                        {
                            m_Max.m_X = vx;
                        }

                        if (vy > m_Max.m_Y)
                        {
                            m_Max.m_Y = vy;
                        }

                        m_List[index++] = new MultiTileEntry((short)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1);
                    }
                }
            }
        }
Ejemplo n.º 35
0
        public MultiComponentList(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                m_Min    = reader.ReadPoint2D();
                m_Max    = reader.ReadPoint2D();
                m_Center = reader.ReadPoint2D();
                m_Width  = reader.ReadInt();
                m_Height = reader.ReadInt();

                int length = reader.ReadInt();

                MultiTileEntry[] allTiles = m_List = new MultiTileEntry[length];

                for (int i = 0; i < length; ++i)
                {
                    allTiles[i].m_ItemID  = reader.ReadShort();
                    allTiles[i].m_OffsetX = reader.ReadShort();
                    allTiles[i].m_OffsetY = reader.ReadShort();
                    allTiles[i].m_OffsetZ = reader.ReadShort();
                    allTiles[i].m_Flags   = reader.ReadInt();
                }

                TileList[][] tiles = new TileList[m_Width][];
                m_Tiles = new Tile[m_Width][][];

                for (int x = 0; x < m_Width; ++x)
                {
                    tiles[x]   = new TileList[m_Height];
                    m_Tiles[x] = new Tile[m_Height][];

                    for (int y = 0; y < m_Height; ++y)
                    {
                        tiles[x][y] = new TileList();
                    }
                }

                for (int i = 0; i < allTiles.Length; ++i)
                {
                    if (i == 0 || allTiles[i].m_Flags != 0)
                    {
                        int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                        int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;

                        tiles[xOffset][yOffset].Add((short)((allTiles[i].m_ItemID & 0x3FFF) | 0x4000), (sbyte)allTiles[i].m_OffsetZ);
                    }
                }

                for (int x = 0; x < m_Width; ++x)
                {
                    for (int y = 0; y < m_Height; ++y)
                    {
                        m_Tiles[x][y] = tiles[x][y].ToArray();
                    }
                }

                break;
            }
            }
        }
Ejemplo n.º 36
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            MultiTileEntry[] allTiles = m_List = new MultiTileEntry[count];

            for (int i = 0; i < count; ++i)
            {
                allTiles[i].m_ItemID  = reader.ReadInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();
                allTiles[i].m_Flags   = reader.ReadInt32();

                MultiTileEntry e = allTiles[i];

                if (i == 0 || e.m_Flags != 0)
                {
                    if (e.m_OffsetX < m_Min.m_X)
                    {
                        m_Min.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY < m_Min.m_Y)
                    {
                        m_Min.m_Y = e.m_OffsetY;
                    }

                    if (e.m_OffsetX > m_Max.m_X)
                    {
                        m_Max.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY > m_Max.m_Y)
                    {
                        m_Max.m_Y = e.m_OffsetY;
                    }
                }
            }

            m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y);
            m_Width  = (m_Max.m_X - m_Min.m_X) + 1;
            m_Height = (m_Max.m_Y - m_Min.m_Y) + 1;

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new Tile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new Tile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                if (i == 0 || allTiles[i].m_Flags != 0)
                {
                    int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                    int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;

                    tiles[xOffset][yOffset].Add((short)((allTiles[i].m_ItemID & 0x3FFF) | 0x4000), (sbyte)allTiles[i].m_OffsetZ);
                }
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                }
            }
        }
Ejemplo n.º 37
0
        private static void ProcessDisplayCase( Map map, StaticTile[] tiles, int x, int y )
        {
            ShopFlags flags = ShopFlags.None;

            for ( int i = 0; i < tiles.Length; ++i )
                flags |= ProcessDisplayedItem( tiles[i].ID );

            if ( flags != ShopFlags.None )
            {
                Point2D p = new Point2D( x, y );
                ShopInfo si = (ShopInfo)m_ShopTable[p];

                if ( si == null )
                {
                    ArrayList floor = new ArrayList();

                    RecurseFindFloor( map, x, y, floor );

                    if ( floor.Count == 0 )
                        return;

                    si = new ShopInfo();
                    si.m_Flags = flags;
                    si.m_Floor = floor;
                    m_ShopList.Add( si );

                    for ( int i = 0; i < floor.Count; ++i )
                        m_ShopTable[(Point2D)floor[i]] = si;
                }
                else
                {
                    si.m_Flags |= flags;
                }
            }
        }
Ejemplo n.º 38
0
 public abstract void Write(Point2D value);
Ejemplo n.º 39
0
 public DeltaState( Point2D p )
 {
     m_X = p.X;
     m_Y = p.Y;
     m_List = new ArrayList();
 }
Ejemplo n.º 40
0
		public static bool Mobile_SkillCheckDirectLocation( Mobile from, SkillName skillName, double chance )
		{
			Skill skill = from.Skills[skillName];

			if ( skill == null )
				return false;

			if ( chance < 0.0 )
				return false; // Too difficult
			else if ( chance >= 1.0 )
				return true; // No challenge

			Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
			return CheckSkill( from, skill, loc, chance );
		}
Ejemplo n.º 41
0
        private static void RecurseFindFloor( Map map, int x, int y, ArrayList floor )
        {
            Point2D p = new Point2D( x, y );

            if ( floor.Contains( p ) )
                return;

            floor.Add( p );

            for ( int xo = -1; xo <= 1; ++xo )
            {
                for ( int yo = -1; yo <= 1; ++yo )
                {
                    if ( (xo != 0 || yo != 0) && IsFloor( map, x + xo, y + yo, false ) )
                        RecurseFindFloor( map, x + xo, y + yo, floor );
                }
            }
        }
Ejemplo n.º 42
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            var allTiles = m_List = new MultiTileEntry[count];

            for (int i = 0; i < count; ++i)
            {
                allTiles[i].m_ItemID  = reader.ReadUInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();
                allTiles[i].m_Flags   = reader.ReadInt32();

                if (_PostHSFormat)
                {
                    reader.ReadInt32();                     // ??
                }

                MultiTileEntry e = allTiles[i];

                if (i == 0 || e.m_Flags != 0)
                {
                    if (e.m_OffsetX < m_Min.m_X)
                    {
                        m_Min.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY < m_Min.m_Y)
                    {
                        m_Min.m_Y = e.m_OffsetY;
                    }

                    if (e.m_OffsetX > m_Max.m_X)
                    {
                        m_Max.m_X = e.m_OffsetX;
                    }

                    if (e.m_OffsetY > m_Max.m_Y)
                    {
                        m_Max.m_Y = e.m_OffsetY;
                    }
                }
            }

            m_Center = new Point2D(-m_Min.m_X, -m_Min.m_Y);
            m_Width  = (m_Max.m_X - m_Min.m_X) + 1;
            m_Height = (m_Max.m_Y - m_Min.m_Y) + 1;

            var tiles = new TileList[m_Width][];

            m_Tiles = new StaticTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new StaticTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                if (i == 0 || allTiles[i].m_Flags != 0)
                {
                    int xOffset = allTiles[i].m_OffsetX + m_Center.m_X;
                    int yOffset = allTiles[i].m_OffsetY + m_Center.m_Y;

                    #region Stygian Abyss
                    //tiles[xOffset][yOffset].Add( (ushort)allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ );
                    tiles[xOffset][yOffset].Add(
                        (ushort)((allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000), (sbyte)allTiles[i].m_OffsetZ);
                    #endregion
                }
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                }
            }
        }
Ejemplo n.º 43
0
		public static bool Mobile_SkillCheckLocation( Mobile from, SkillName skillName, double minSkill, double maxSkill )
		{
			Skill skill = from.Skills[skillName];

			if ( skill == null )
				return false;

			double value = skill.Value;

			if ( value < minSkill )
				return false; // Too difficult
			else if ( value >= maxSkill )
				return true; // No challenge

			double chance = (value - minSkill) / (maxSkill - minSkill);

			Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
			return CheckSkill( from, skill, loc, chance );
		}
Ejemplo n.º 44
0
        public void Register()
        {
            if (m_Registered)
            {
                return;
            }

            OnRegister();

            m_Registered = true;

            if (m_Parent != null)
            {
                m_Parent.m_Children.Add(this);
                m_Parent.OnChildAdded(this);
            }

            m_Regions.Add(this);

            m_Map.RegisterRegion(this);

            m_IndexedName = IndexedRegionName.NotIndexed;

            if (m_Name != null)
            {
                IndexedRegionName temp;

                if (m_NameToIndexLookup.TryGetValue(m_Name, out temp))
                {
                    m_IndexedName = temp;
                }
            }

            List <Sector> sectors = new List <Sector>();

            for (int i = 0; i < m_Area.Length; i++)
            {
                Rectangle3D rect = m_Area[i];

                Point2D start = m_Map.Bound(new Point2D(rect.Start));
                Point2D end   = m_Map.Bound(new Point2D(rect.End));

                Sector startSector = m_Map.GetSector(start);
                Sector endSector   = m_Map.GetSector(end);

                for (int x = startSector.X; x <= endSector.X; x++)
                {
                    for (int y = startSector.Y; y <= endSector.Y; y++)
                    {
                        Sector sector = m_Map.GetRealSector(x, y);

                        sector.OnEnter(this, rect);

                        if (!sectors.Contains(sector))
                        {
                            sectors.Add(sector);
                        }
                    }
                }
            }

            m_Sectors = sectors.ToArray();
        }