Exemple #1
0
    public static int GetFiringRangeAndShow(Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
    {
        ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(thisShip, anotherShip);

        MovementTemplates.ShowFiringArcRange(shotInfo);
        return(shotInfo.Range);
    }
Exemple #2
0
 private static void CleanupCombatData()
 {
     AttackStep   = CombatStep.None;
     Attacker     = null;
     Defender     = null;
     ChosenWeapon = null;
     ShotInfo     = null;
 }
Exemple #3
0
    public static int GetFiringRangeAndShow(GenericShip thisShip, GenericShip anotherShip)
    {
        ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(thisShip, anotherShip, thisShip.PrimaryWeapon);
        bool inArc = MovementTemplates.ShowFiringArcRange(shotInfo);

        if (!inArc)
        {
            Messages.ShowInfoToHuman("Out of primary weapon arc");
        }
        return(shotInfo.Range);
    }
Exemple #4
0
 private static void CleanupCombatData()
 {
     AttackStep            = CombatStep.None;
     Attacker              = null;
     Defender              = null;
     ChosenWeapon          = null;
     ShotInfo              = null;
     hitsCounter           = 0;
     ExtraAttackFilter     = null;
     IsAttackAlreadyCalled = false;
 }
Exemple #5
0
    // DECLARE INTENT TO ATTACK

    public static void DeclareIntentToAttack(int attackerId, int defenderID)
    {
        Selection.ChangeActiveShip("ShipId:" + attackerId);
        Selection.ChangeAnotherShip("ShipId:" + defenderID);

        ChosenWeapon = Selection.ThisShip.PrimaryWeapon;
        ShotInfo     = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);

        UI.HideContextMenu();

        SelectWeapon();
    }
Exemple #6
0
 public static void ShowFiringArcRange(ShipShotDistanceInformation shotInfo)
 {
     if (shotInfo.InArc)
     {
         ShowRangeRuler(shotInfo);
     }
     else
     {
         Messages.ShowErrorToHuman("Out of arc!");
         ShowRangeRuler(new ShipShotOutOfArcDistanceInformation(shotInfo.ThisShip, shotInfo.AnotherShip));
     }
 }
Exemple #7
0
        private bool FilterTargetsOfAbility(GenericShip ship)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(HostShip, ship);

            return(FilterByTargetType(ship, new List <TargetTypes> ()
            {
                TargetTypes.Enemy, TargetTypes.OtherFriendly
            }) &&
                   FilterTargetsByRange(ship, 1, 1) &&
                   shotInfo.InMobileArc &&
                   shotInfo.InPrimaryArc);
        }
Exemple #8
0
 public static bool ShowFiringArcRange(ShipShotDistanceInformation shotInfo)
 {
     if (shotInfo.InShotAngle)
     {
         ShowRangeRuler(shotInfo);
     }
     else
     {
         ShowRangeRuler(new ShipShotOutOfArcDistanceInformation(shotInfo.ThisShip, shotInfo.AnotherShip));
     }
     return(shotInfo.InShotAngle);
 }
Exemple #9
0
    public static bool HasTarget(GenericShip thisShip)
    {
        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(thisShip, anotherShip.Value, thisShip.PrimaryWeapon);
            if ((shotInfo.Range < 4) && (shotInfo.InShotAngle))
            {
                return(true);
            }
        }

        return(false);
    }
Exemple #10
0
            public override bool IsActionEffectAvailable()
            {
                bool result = false;

                if (Combat.AttackStep == CombatStep.Defence)
                {
                    ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Combat.Defender, Combat.Attacker);
                    if (shotInfo.InMobileArc)
                    {
                        result = true;
                    }
                }
                return(result);
            }
Exemple #11
0
        public override void Prepare()
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip);

            infoText = "Choose weapon for attack (Range " + shotInfo.Range + ")";

            AddDecision("Primary", PerformPrimaryAttack);
            AddDecision("Proton Torpedoes", PerformTorpedoesAttack);

            //Temporary
            tooltips.Add("Proton Torpedoes", "https://vignette2.wikia.nocookie.net/xwing-miniatures/images/e/eb/Proton-torpedoes.png");

            defaultDecision = "Proton Torpedoes";
        }
Exemple #12
0
    public static int CountEnemiesTargeting(Ship.GenericShip thisShip)
    {
        int result = 0;

        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(anotherShip.Value, thisShip, anotherShip.Value.PrimaryWeapon);
            if ((shotInfo.Range < 4) && (shotInfo.InShotAngle))
            {
                result++;
            }
        }

        return(result);
    }
Exemple #13
0
        private void CheckShadowCasterAbility()
        {
            if (IsAbilityUsed)
            {
                return;
            }

            ShipShotDistanceInformation shotInfo = Combat.ShotInfo;

            if (!shotInfo.InMobileArc || shotInfo.Range > 2)
            {
                return;
            }

            RegisterAbilityTrigger(TriggerTypes.OnAttackHit, AssignTractorBeamToken);
        }
Exemple #14
0
 public void AddTailGunnerAbility()
 {
     if (Selection.ThisShip.ShipId == HostShip.ShipId)
     {
         //Gather shot info to determine if in rear arc
         ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Combat.Attacker, Combat.Defender);
         //make sure card requirements are met.
         //can't reduce defender agility past 0 and must be aux arc
         if (Combat.Defender.Agility != 0 && shotInfo.InRearAuxArc)
         {
             Messages.ShowError("Tail Gunner: Agility is decreased");
             Combat.Defender.Tokens.AssignCondition(new Conditions.TailGunnerCondition(Combat.Defender));
             Combat.Defender.ChangeAgilityBy(-1);
             Combat.Defender.OnAttackFinish += RemoveTailGunnerAbility;
         }
     }
 }
Exemple #15
0
    public static void DeclareTarget()
    {
        Game.UI.HideContextMenu();

        ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip);

        int attackTypesAreAvailable = Selection.ThisShip.GetAttackTypes(shotInfo.Range, shotInfo.InArc);

        if (attackTypesAreAvailable > 1)
        {
            Phases.StartTemporarySubPhase("Choose weapon for attack", typeof(SubPhases.WeaponSelectionDecisionSubPhase));
        }
        else
        {
            SelectWeapon();
            TryPerformAttack();
        }
    }
Exemple #16
0
        private bool IsDefenderOnlyShipInArcAtShotDistance()
        {
            bool result = true;

            foreach (var shipHolder in Roster.AllShips)
            {
                if (shipHolder.Value.ShipId != Host.ShipId && shipHolder.Value.ShipId != Combat.Defender.ShipId)
                {
                    ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Host, shipHolder.Value);
                    if (shotInfo.InArc && shotInfo.Range <= 3)
                    {
                        return(false);
                    }
                }
            }

            return(result);
        }
Exemple #17
0
        private void CheckShadowCasterAbility()
        {
            if (IsAbilityUsed)
            {
                return;
            }

            ShipShotDistanceInformation shotInfo = Combat.ShotInfo;

            if (!shotInfo.InMobileArc || shotInfo.Range > 2)
            {
                return;
            }

            Tokens.TractorBeamToken token = new Tokens.TractorBeamToken(Combat.Defender, Combat.Attacker.Owner);
            Combat.Defender.Tokens.AssignToken(token, delegate {
                IsAbilityUsed = true;
            });
        }
Exemple #18
0
    // DECLARE INTENT TO ATTACK

    public static void DeclareIntentToAttack(int attackerId, int defenderID)
    {
        if (!IsAttackAlreadyCalled)
        {
            IsAttackAlreadyCalled = true;

            UI.HideContextMenu();
            UI.HideSkipButton();

            Selection.ChangeActiveShip("ShipId:" + attackerId);
            Selection.ChangeAnotherShip("ShipId:" + defenderID);

            ChosenWeapon = Selection.ThisShip.PrimaryWeapon;
            ShotInfo     = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
            SelectWeapon();
        }
        else
        {
            Debug.Log("Attack was called when attack is already called - ignore");
        }
    }
Exemple #19
0
        private void CheckAssignStress()
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(HostShip, TargetShip);

            if (shotInfo.InMobileArc && shotInfo.Range >= 1 && shotInfo.Range <= 2)
            {
                Messages.ShowError(HostShip.PilotName + " assigns Stress Token\nto " + TargetShip.PilotName);
                TargetShip.Tokens.AssignToken(new Tokens.StressToken(TargetShip), SelectShipSubPhase.FinishSelection);
            }
            else
            {
                if (!shotInfo.InMobileArc)
                {
                    Messages.ShowError("Target is not inside Mobile Arc");
                }
                else if (shotInfo.Distance >= 3)
                {
                    Messages.ShowError("Target is outside range 2");
                }
            }
        }
Exemple #20
0
    public static void TryPerformAttack()
    {
        Game.UI.HideContextMenu();
        MovementTemplates.ReturnRangeRuler();

        if (Rules.TargetIsLegalForShot.IsLegal() && ChosenWeapon.IsShotAvailable(Selection.AnotherShip))
        {
            Game.UI.HideSkipButton();
            ShotInfo = (ChosenWeapon.GetType() == typeof(Ship.PrimaryWeaponClass)) ? ShotInfo : new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
            ShotInfo.CheckFirelineCollisions(delegate { PerformAttack(Selection.ThisShip, Selection.AnotherShip); });
        }
        else
        {
            if (Roster.GetPlayer(Phases.CurrentPhasePlayer).GetType() == typeof(Players.HumanPlayer))
            {
                // TODO: Better explanations
                if (!Rules.TargetIsLegalForShot.IsLegal())
                {
                    Messages.ShowError("Attack is not legal (this ship cannot attack or target cannot be attacked)");
                }
                else if (!ShotInfo.InShotAngle)
                {
                    Messages.ShowError("Target is outside your firing arc");
                }
                else if (ShotInfo.Distance > ChosenWeapon.MaxRange || ShotInfo.Distance < ChosenWeapon.MinRange)
                {
                    Messages.ShowError("Target is outside your firing range");
                }

                //TODO: except non-legal targets, bupmed for example, biggs?
                Roster.HighlightShipsFiltered(Roster.AnotherPlayer(Phases.CurrentPhasePlayer));
                Game.UI.HighlightNextButton();
            }
            else
            {
                Selection.ThisShip.IsAttackPerformed = true;
                Phases.FinishSubPhase(typeof(SubPhases.CombatSubPhase));
            }
        }
    }
Exemple #21
0
    public static void TryPerformAttack()
    {
        Game.UI.HideContextMenu();
        MovementTemplates.ReturnRangeRuler();

        if (Rules.TargetIsLegalForShot.IsLegal())
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip);
            shotInfo.CheckFirelineCollisions(CallPerformAttack);
        }
        else
        {
            if (Roster.GetPlayer(Phases.CurrentPhasePlayer).GetType() == typeof(Players.HumanPlayer))
            {
                Roster.HighlightShipsFiltered(Roster.AnotherPlayer(Phases.CurrentPhasePlayer));
                Game.UI.HighlightNextButton();
            }
            else
            {
                Selection.ThisShip.IsAttackPerformed = true;
                Phases.FinishSubPhase(typeof(SubPhases.CombatSubPhase));
            }
        }
    }
Exemple #22
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);
                 });
             }
         }
     }
 }
Exemple #23
0
        private void CheckAssignTractorBeam()
        {
            SelectShipSubPhase.FinishSelectionNoCallback();

            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(HostShip, TargetShip);

            if (shotInfo.InMobileArc && shotInfo.InMobileArc && shotInfo.Range == 1)
            {
                Messages.ShowError(HostShip.PilotName + " assigns Tractor Beam Token\nto " + TargetShip.PilotName);
                Tokens.TractorBeamToken token = new Tokens.TractorBeamToken(TargetShip, HostShip.Owner);
                TargetShip.Tokens.AssignToken(token, Triggers.FinishTrigger);
            }
            else
            {
                if (!shotInfo.InMobileArc || !shotInfo.InMobileArc)
                {
                    Messages.ShowError("Target is not inside Mobile Arc and Primary Arc");
                }
                else if (shotInfo.Distance > 1)
                {
                    Messages.ShowError("Target is outside range 1");
                }
            }
        }
Exemple #24
0
    public static int CountEnemiesTargeting(GenericShip thisShip, int direction = 0)
    {
        int result = 0;

        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(anotherShip.Value, thisShip, anotherShip.Value.PrimaryWeapon);
            if ((shotInfo.Range < 4) && (shotInfo.InShotAngle))
            {
                if (direction == 0)
                {
                    result++;
                }
                else
                {
                    ShipShotDistanceInformation reverseShotInfo = new ShipShotDistanceInformation(thisShip, anotherShip.Value, thisShip.PrimaryWeapon);
                    if (direction == 1)
                    {
                        if (reverseShotInfo.InArc)
                        {
                            result++;
                        }
                    }
                    else if (direction == -1)
                    {
                        if (!reverseShotInfo.InArc)
                        {
                            result++;
                        }
                    }
                }
            }
        }

        return(result);
    }
Exemple #25
0
        private bool FilterAbilityTargets(GenericShip ship)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(SpacetugOwner, ship);

            return(shotInfo.InArc && shotInfo.Range == 1);
        }
Exemple #26
0
        private bool FilterTargetInMobileFiringArc(GenericShip ship)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(HostShip, ship);

            return(shotInfo.InMobileArc);
        }
Exemple #27
0
 private static void CheckFireLineCollisions()
 {
     ShotInfo = (ChosenWeapon.GetType() == typeof(Ship.PrimaryWeaponClass)) ? ShotInfo : new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
     ShotInfo.CheckFirelineCollisions(PayAttackCost);
 }
Exemple #28
0
 private static void CheckFireLineCollisions()
 {
     ShotInfo = new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
     ShotInfo.CheckFirelineCollisions(PayAttackCost);
 }