예제 #1
0
파일: Map.cs 프로젝트: DjTrilogic/BlueSheep
 public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
 {
     m_Account.ModifBar(6, 0, 0, "Déplacement");
     MovementPath path = null;
     int savDistance = -1;
     MapPoint characterPoint = new MapPoint(Character.CellId);
     MapPoint targetPoint = new MapPoint(cellId);
     foreach (MapPoint point in GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
     {
         Pathfinder pathFinding = null;
         if ((targetPoint.DistanceToCell(point) > maxDistance) || ((targetPoint.X != point.X) && (targetPoint.Y != point.Y)))
             continue;
         int distance = characterPoint.DistanceTo(point);
         if ((savDistance != -1) && (distance >= savDistance))
             continue;
         if (bool1)
         {
             if (Data.IsWalkable(point.CellId))
                 goto Label_00A8;
             continue;
         }
         if (!(NothingOnCell(point.CellId)))
             continue;
     Label_00A8:
         pathFinding = new Pathfinder(m_Account.Map.Data, m_Account.Map);
         MovementPath path2 = pathFinding.FindPath(Character.CellId, point.CellId);
         if (path2 != null)
         {
             path = path2;
             savDistance = distance;
         }
     }
     if (path == null)
         return false;
     //if (AutoTimeout)
     //    m_Account.Game.Character.State.SetTimeout(StateEnum.Moving, false, TimeoutMin, TimeoutMax);
     List<UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
     int timetowait;
     if (serverMovement.Count() < 3)
         timetowait = serverMovement.Count() * 500;
     else
     {
         timetowait = serverMovement.Count() * 300;
     }
     //m_Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), Id));
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), 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);
     }
     m_Account.Wait(timetowait, timetowait + 100);
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
         newmsg.Serialize(writer);
         MessagePackaging pack = new MessagePackaging(writer);
         pack.Pack((int)newmsg.ProtocolID);
         if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
         {
             m_Account.SocketManager.Send(pack.Writer.Content);
             m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
             //m_Account.Wait(3000, 4000);
             //if (m_Account.StatusLb.Text != "Combat")
             //{
             //    m_Account.Fight.SearchFight();
             //}
         }
         else if (m_Account.Gather.Id != -1)
         {
             m_Account.SocketManager.Send(pack.Writer.Content);
             UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
         }
         else
         {
             m_Account.SocketManager.Send(pack.Writer.Content);
         }
         m_Account.ModifBar(6, 0, 0, "Connecté");
     }
     return true;
 }
예제 #2
0
파일: Map.cs 프로젝트: DjTrilogic/BlueSheep
        public bool MoveToCell(int cellId)
        {
            if (m_Account.StatusLb.Text == "Combat" || m_Account.StatusLb.Text == "Fighting")
                return false;
            m_Account.ModifBar(6, 0, 0, "Déplacement");
            MovementPath path = (new Pathfinder(m_Account.Map.Data, m_Account.Map)).FindPath(Character.CellId, cellId);
            if (path == null)
                return false;
            List<UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
            int timetowait;
            if (serverMovement.Count() < 3)
                timetowait = serverMovement.Count() * 500;
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            //if (AutoTimeout)
            //    m_Account.Game.Character.State.SetTimeout(StateEnum.Moving, false, TimeoutMin, TimeoutMax);
            //m_Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), Id));
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), 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);
            }
            m_Account.Wait(timetowait, timetowait + 100);
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
                newmsg.Serialize(writer);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)newmsg.ProtocolID);
                if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
                    //m_Account.Wait(3000, 4000);
                    //if (m_Account.StatusLb.Text != "Combat")
                    //{
                    //    m_Account.Fight.SearchFight();
                    //}
                }
                else
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                }
                if (m_Account.Gather != null)
                    m_Account.Gather.Moved = true;
                m_Account.ModifBar(6, 0, 0, "Connecté");
            }

            return true;
        }