コード例 #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
ファイル: 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;
 }