Exemple #1
0
        private BaseResponse PlayerMove(int clientId, BasePacket packet)
        {
            PPlayerMove  pPlayerMove = (PPlayerMove)packet;
            PlayerDataEx playerData  = World.PlayerDataGet(pPlayerMove.SessionToken);

            if (playerData == null)
            {
                ThrowSessionError(packet.Type, packet.SessionToken);
                return(null);
            }

            if (playerData.Player.Position != pPlayerMove.Position ||
                playerData.Player.Direction != pPlayerMove.Direction)
            {
                _vCheckPosition.Validate(packet);

                if (pPlayerMove.Direction == Direction.None)
                {
                    playerData.StopMoving(pPlayerMove.Position);
                }
                else
                {
                    playerData.StartMoving(pPlayerMove.Position, pPlayerMove.Direction);
                }

                RegisterWorldResponseForNearest(playerData, new RPlayerMove
                {
                    PlayerId  = playerData.Player.Id,
                    Position  = pPlayerMove.Position,
                    Direction = pPlayerMove.Direction,
                });
            }

            return(null);
        }
 public void AssertAction(BasePacket packet)
 {
     switch (packet.Type)
     {
     case PacketType.PlayerMove:
     {
         PPlayerMove p = (PPlayerMove)packet;
         AssertDistance(packet, Geometry.GetDistance(p.Position.X, p.Position.Y,
                                                     _lastX, _lastY));
         break;
     }
     }
 }