예제 #1
0
        private void UpdateCurrentShips(int step)
        {
            for (int i = 0; i < 10; i++)
            {
                if (ServerShips[i] == null || CurrentShips[i] == null)
                {
                    return;
                }

                var diffCoords = ServerShips[i].Ship.Coordinates - CurrentShips[i].Ship.Coordinates;
                var diffAngle  = PolarCoordinateHelper.GetAngle(ServerShips[i].Ship.MoveVector, CurrentShips[i].Ship.MoveVector);

                if (Math.Abs(diffAngle) > Math.PI)
                {
                    diffAngle = -(float)(2 * Math.PI - Math.Abs(diffAngle)) * (Math.Sign(diffAngle));
                }

                CurrentShips[i].Ship.Coordinates += diffCoords / (5 - step);
                CurrentShips[i].Ship.MoveVector   = PolarCoordinateHelper.TurnVector2(CurrentShips[i].Ship.MoveVector, diffAngle / (5 - step));
            }
        }
예제 #2
0
 protected override void TurnToTheRight(object obj)
 {
     MoveVector = PolarCoordinateHelper.TurnVector2(MoveVector, 0.05f);
 }