internal void ResetHeadPosition()
        {
            float pathLength = Aircraft.ScaledContentSize.Width;

            // get the mathematical direction of the aircraft
            Constants.CCDegreesToDxDy(Aircraft.MyRotation, out float dx, out float dy);
            MoveHeadToClosestPointInsideManeuverPolygon(new CCPoint(Aircraft.PositionX + dx * pathLength, Aircraft.PositionY + dy * pathLength));
        }
 /// <summary>
 /// Check whether a bullet shot now would hit any parts of the TargetAircraft (if the TargetAircraft wouldn't move).
 /// </summary>
 /// <param name="partsInRange"></param>
 /// <returns>whether the bullet would hit</returns>
 internal bool WouldHit()
 {
     Constants.CCDegreesToDxDy(MyPart.TotalRotation, out float dx, out float dy);
     CollisionTypeLine cTypeReachLine = new CollisionTypeLine(MyPart.PositionWorldspace, MyPart.PositionWorldspace + new CCPoint(dx * Reach, dy * Reach));
     foreach (Part part in TargetAircraft.TotalParts)
     {
         if (Collisions.CollidePolygonLine(part, ((CollisionTypePolygon)part.CollisionType), cTypeReachLine))
             return true;
     }
     return false;
 }
 private void MoveHeadTo(float x, float y)
 {
     // move the head
     FlightPathHead.MoveTo(x, y);
     // if its a player aircraft make sure it doesn't move too far away from the others
     if (Layer is PlayLayer pl && pl.PlayerAircrafts != null && pl.PlayerAircrafts.Contains(Aircraft))
     {
         FlightPathHead.EnsureProximityToOtherPlayerHeads();
     }
     // recalculate the flight path
     Constants.CCDegreesToDxDy(Aircraft.MyRotation, out float dx, out float dy);
     FlightPathNode.CalculatePath(Aircraft.Position, dx, dy, FlightPathHead.Position);
     if (Aircraft.ControlledByPlayer)
     {
         FlightPathNode.DrawPath();
     }
     // rotate the head according to the direction (not the slope itself) at the end of the flight path
     FlightPathHead.MyRotation = FlightPathNode.DirectionAt(FlightPathNode.Path.Length - 1);
 }
Пример #4
0
 private protected void UpdateDxDy()
 {
     Constants.CCDegreesToDxDy(MyRotation, out float dx, out float dy);
     Dx = dx * Velocity; Dy = Velocity * dy;
 }