Пример #1
0
    public static void AssignTargetLockToPair(GenericShip thisShip, GenericShip targetShip, Action successCallback, Action failureCallback)
    {
        if (Letters.Count == 0)
        {
            InitializeTargetLockLetters();
        }

        ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, targetShip);

        if (distanceInfo.Range >= thisShip.TargetLockMinRange && distanceInfo.Range <= thisShip.TargetLockMaxRange)
        {
            GenericToken existingBlueToken = thisShip.Tokens.GetToken(typeof(BlueTargetLockToken), '*');
            if (existingBlueToken != null)
            {
                thisShip.Tokens.RemoveToken(
                    existingBlueToken,
                    delegate { FinishAssignTargetLockPair(thisShip, targetShip, successCallback); }
                    );
            }
            else
            {
                FinishAssignTargetLockPair(thisShip, targetShip, successCallback);
            }
        }
        else
        {
            Messages.ShowErrorToHuman("Target is out of range of Target Lock");
            failureCallback();
        }
    }
Пример #2
0
    public static bool AssignTargetLockToPair(Ship.GenericShip thisShip, Ship.GenericShip targetShip)
    {
        bool result = false;

        if (Letters.Count == 0)
        {
            InitializeTargetLockLetters();
        }

        ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, targetShip);

        if (distanceInfo.Range < 4)
        {
            Tokens.GenericToken existingBlueToken = thisShip.GetToken(typeof(Tokens.BlueTargetLockToken), '*');
            if (existingBlueToken != null)
            {
                if ((existingBlueToken as Tokens.BlueTargetLockToken).LockedShip != null)
                {
                    (existingBlueToken as Tokens.BlueTargetLockToken).LockedShip.RemoveToken(typeof(Tokens.RedTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter);
                }
                thisShip.RemoveToken(typeof(Tokens.BlueTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter);
            }

            Tokens.BlueTargetLockToken tokenBlue = new Tokens.BlueTargetLockToken();
            Tokens.RedTargetLockToken  tokenRed  = new Tokens.RedTargetLockToken();

            char letter = GetFreeTargetLockLetter();
            tokenBlue.Letter     = letter;
            tokenBlue.LockedShip = targetShip;
            tokenRed.Letter      = letter;
            TakeTargetLockLetter(letter);

            Selection.ThisShip.AssignToken(tokenBlue);
            targetShip.AssignToken(tokenRed);

            result = true;
        }
        else
        {
            Messages.ShowErrorToHuman("Target is out of range of Target Lock");
        }

        return(result);
    }
Пример #3
0
    public static int GetRangeAndShow(GenericShip thisShip, GenericShip anotherShip)
    {
        ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, anotherShip);

        MovementTemplates.ShowRangeRuler(distanceInfo);

        int range = distanceInfo.Range;

        if (range < 4)
        {
            Messages.ShowInfo("Range " + range);
        }
        else
        {
            Messages.ShowError("Out of range");
        }

        return(distanceInfo.Range);
    }
Пример #4
0
    public static void AssignTargetLockToPair(Ship.GenericShip thisShip, Ship.GenericShip targetShip, Action successCallback, Action failureCallback)
    {
        if (Letters.Count == 0)
        {
            InitializeTargetLockLetters();
        }

        ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, targetShip);

        if (distanceInfo.Range >= thisShip.TargetLockMinRange && distanceInfo.Range <= thisShip.TargetLockMaxRange)
        {
            Tokens.GenericToken existingBlueToken = thisShip.GetToken(typeof(Tokens.BlueTargetLockToken), '*');
            if (existingBlueToken != null)
            {
                thisShip.RemoveToken(typeof(Tokens.BlueTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter);
            }

            Tokens.BlueTargetLockToken tokenBlue = new Tokens.BlueTargetLockToken();
            Tokens.RedTargetLockToken  tokenRed  = new Tokens.RedTargetLockToken();

            char letter = GetFreeTargetLockLetter();

            tokenBlue.Letter          = letter;
            tokenBlue.OtherTokenOwner = targetShip;

            tokenRed.Letter          = letter;
            tokenRed.OtherTokenOwner = Selection.ThisShip;

            TakeTargetLockLetter(letter);

            targetShip.AssignToken(
                tokenRed,
                delegate {
                thisShip.AssignToken(tokenBlue, successCallback);
            });
        }
        else
        {
            Messages.ShowErrorToHuman("Target is out of range of Target Lock");
            failureCallback();
        }
    }
Пример #5
0
    public static bool IsClosing(GenericShip thisShip, GenericShip anotherShip)
    {
        bool result = false;

        ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, anotherShip);
        int range = distanceInfo.Range;

        if (range <= 1)
        {
            return(true);
        }
        if (range >= 3)
        {
            return(false);
        }

        float distanceToFront = Vector3.Distance(thisShip.GetPosition(), anotherShip.ShipBase.GetCentralFrontPoint());
        float distanceToBack  = Vector3.Distance(thisShip.GetPosition(), anotherShip.ShipBase.GetCentralBackPoint());

        result = (distanceToFront < distanceToBack) ? true : false;
        return(result);
    }
Пример #6
0
 private void DeathTroopersEffect()
 {
     // If the defender is another friendly ship
     if (Combat.Defender.Owner.Id == HostShip.Owner.Id && Combat.Defender.ShipId != HostShip.ShipId)
     {
         // ...and it's at range 1 of me
         var distanceToDefender = new ShipDistanceInformation(HostShip, Combat.Defender);
         if (distanceToDefender.Range <= 1)
         {
             // ...and I am in arc, at range 1-3
             var attackInfo = new ShipShotDistanceInformation(Combat.Attacker, HostShip, Combat.ChosenWeapon);
             if (attackInfo.InArc && attackInfo.Range <= 3)
             {
                 // ...assign a stress token to the attacker
                 RegisterAbilityTrigger(TriggerTypes.OnAttackStart, (s, e) =>
                 {
                     Messages.ShowInfo(string.Format("{0}'s Death Troopers assign stress to {1}!", HostShip.PilotName, Combat.Attacker.PilotName));
                     Sounds.PlayShipSound("DeathTrooper");
                     Combat.Attacker.Tokens.AssignToken(new Tokens.StressToken(Combat.Attacker), Triggers.FinishTrigger);
                 });
             }
         }
     }
 }
Пример #7
0
 public static void ShowRangeRuler(ShipDistanceInformation shipDistanceInfo)
 {
     Templates.Find("RangeRuler").position = shipDistanceInfo.MinDistance.Point1;
     Templates.Find("RangeRuler").LookAt(shipDistanceInfo.MinDistance.Point2);
 }
Пример #8
0
 public static void ShowRangeRuler(ShipDistanceInformation shipDistanceInfo)
 {
     Templates.Find("RangeRuler").position = shipDistanceInfo.ThisShipNearestPoint;
     Templates.Find("RangeRuler").rotation = Quaternion.LookRotation(shipDistanceInfo.Vector);
 }