コード例 #1
0
ファイル: BFight.cs プロジェクト: Sadikk/BlueSheep
 /// <summary>
 /// Move to the specified cell (Fight).
 /// </summary>
 private bool MoveToCell(int cellId)
 {
     if (cellId != m_Data.Fighter.CellId)
     {
         if (!(m_Data.IsCellWalkable(cellId)))
         {
             int num = -1;
             int num2 = 5000;
             MapPoint point = new MapPoint(m_Data.Fighter.CellId);
             MapPoint point2 = new MapPoint(cellId);
             int direction = 1;
             while (true)
             {
                 MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1);
                 if (m_Data.IsCellWalkable(nearestCellInDirection.CellId))
                 {
                     int num4 = point.DistanceToCell(nearestCellInDirection);
                     if (num4 < num2)
                     {
                         num2 = num4;
                         num = nearestCellInDirection.CellId;
                     }
                 }
                 direction = (direction + 2);
                 if (direction > 7)
                 {
                     if (num == -1)
                         return false;
                     cellId = num;
                     break;
                 }
             }
         }
         SimplePathfinder pathfinder = new SimplePathfinder(m_Account.MapData);
         pathfinder.SetFight(m_Data.Fighters, m_Data.Fighter.MovementPoints);
         MovementPath path = pathfinder.FindPath(m_Data.Fighter.CellId, cellId);
         if (path != null)
         {
             List<UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
             using (BigEndianWriter writer = new BigEndianWriter())
             {
                 GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), m_Account.MapData.Id);
                 msg.Serialize(writer);
                 writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                 MessagePackaging pack = new MessagePackaging(writer);
                 pack.Pack((int)msg.ProtocolID);
                 flag = 0;
                 m_Account.SocketManager.Send(pack.Writer.Content);
                 if (m_Account.DebugMode.Checked)
                     m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
             }
             return true;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: FightData.cs プロジェクト: Sadikk/BlueSheep
 /// <summary>
 /// Returns the distance between our player and the specified fighter. Default is the nearest monster.
 /// </summary>
 public int DistanceFrom(BFighter fighter = null)
 {
     if (fighter == null)
         fighter = NearestMonster();
     MapPoint CharacterPoint = new MapPoint(Fighter.CellId);
     MapPoint TestFighterPoint = new MapPoint(fighter.CellId);
     int dist = new SimplePathfinder(m_Account.MapData).FindPath(fighter.CellId, TestFighterPoint.CellId).Cells.Count();
     dist += CharacterPoint.DistanceToCell(TestFighterPoint);
     return dist;
 }
コード例 #3
0
ファイル: FightData.cs プロジェクト: Sadikk/BlueSheep
 /// <summary>
 /// Returns the nearest monster from our player, in the specified list.
 /// </summary>
 public BFighter NearestMonster(List<BFighter> LFighters)
 {
     MapPoint CharacterPoint = new MapPoint(this.Fighter.CellId);
     BFighter Fighterr = null;
     int SavDistance = -1;
     foreach (BFighter TestFighter in LFighters)
     {
         if (TestFighter.TeamId == Fighter.TeamId || TestFighter.IsAlive == false)
             continue;
         MapPoint TestFighterPoint = new MapPoint(TestFighter.CellId);
         int dist = new SimplePathfinder(m_Account.MapData).FindPath(CharacterPoint.CellId, TestFighterPoint.CellId).Cells.Count();
         dist += CharacterPoint.DistanceToCell(TestFighterPoint);
         if (((dist < SavDistance) || (SavDistance == -1)) && TestFighter != this.Fighter)
         {
             SavDistance = dist;
             Fighterr = TestFighter;
         }
     }
     if (Fighterr == null)
     {
         return null;
     }
     return Fighterr;
 }
コード例 #4
0
ファイル: BFight.cs プロジェクト: DjTrilogic/BlueSheep
 public bool MoveToCell(int cellId)
 {
     if (cellId != Fighter.CellId)
     {
         if (!(IsCellWalkable(cellId)))
         {
             int num = -1;
             int num2 = 5000;
             MapPoint point = new MapPoint(Fighter.CellId);
             MapPoint point2 = new MapPoint(cellId);
             int direction = 1;
             while (true)
             {
                 MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1);
                 if (IsCellWalkable(nearestCellInDirection.CellId))
                 {
                     int num4 = point.DistanceToCell(nearestCellInDirection);
                     if (num4 < num2)
                     {
                         num2 = num4;
                         num = nearestCellInDirection.CellId;
                     }
                 }
                 direction = (direction + 2);
                 if (direction > 7)
                 {
                     if (num == -1)
                         return false;
                     cellId = num;
                     break;
                 }
             }
         }
         SimplePathfinder pathfinder = new SimplePathfinder((BlueSheep.Data.D2p.Map)m_Account.Map.Data);
         pathfinder.SetFight(Fighters, Fighter.MovementPoints);
         MovementPath path = pathfinder.FindPath(Fighter.CellId, cellId);
         if (path != null)
         {
             List<UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
             //Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), Account.Game.Map.Id));
             using (BigEndianWriter writer = new BigEndianWriter())
             {
                 GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), m_Account.Map.Id);
                 msg.Serialize(writer);
                 writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                 MessagePackaging pack = new MessagePackaging(writer);
                 pack.Pack((int)msg.ProtocolID);
                 m_Account.SocketManager.Send(pack.Writer.Content);
             }
             return true;
         }
     }
     return false;
 }