Example #1
0
 private static int CalculatePlayerTraveledDistance(PlayerData playerData)
 {
     double moveTimeElapsed = DateTime.Now.Subtract(playerData.MovingStartTime).TotalMilliseconds;
     float fDistance = ((float)moveTimeElapsed / playerData.Player.Speed) +
                       playerData.MovingDistanceRest;
     int traveled = (int)Math.Floor(fDistance);
     if (traveled > 0)
     {
         playerData.MovingDistanceRest = fDistance - traveled;
         playerData.MovingStartTime = DateTime.Now;
     }
     return traveled;
 }
Example #2
0
 public static bool ValidateNewPlayerPosition(PlayerData playerData, IBaseMap map, bool emulateCheat = false)
 {
     if (playerData.IsMoving)
     {
         int traveled = CalculatePlayerTraveledDistance(playerData);
         if (emulateCheat) traveled += 5;
         Point newPos = CalculateNewPlayerPos(playerData.Player, traveled);
         PlayerPosProcessCollision(playerData.Player, map, ref newPos);
         if (playerData.Player.Position != newPos)
         {
             playerData.Player.Position = newPos;
             return true;
         }
     }
     return false;
 }