示例#1
0
        private void AssignFocusTokensToTarget()
        {
            // Count ships in arc of Jyn Erso's ship...
            var tokenCount = Roster.AllShips.Values
                             .Where(s => s.Owner.Id != HostShip.Owner.Id)
                             .Where(s =>
            {
                var arcInfo = new Board.ShipShotDistanceInformation(HostShip, s);
                return(arcInfo.InArc && arcInfo.Range <= 3);
            })
                             .Count();

            // ... to a maximum of 3...
            tokenCount = Math.Min(tokenCount, 3);

            // ... and assign that many focus tokens to the selected ship
            Messages.ShowInfo(string.Format("{0} assigns {1} focus {3} to {2}.", HostUpgrade.Name, tokenCount, TargetShip.PilotName, tokenCount == 1 ? "token" : "tokens"));
            if (tokenCount > 0)
            {
                // Assign the tokens
                RegisterAssignMultipleFocusTokens(tokenCount);
                // Jyn says something
                var clip = new[] { "JynErso1", "JynErso2", "JynErso3", "JynErso4", "JynErso5" }[UnityEngine.Random.Range(0, 5)];
                Sounds.PlayShipSound(clip);
            }
        }
示例#2
0
        public override bool IsShotAvailable(Ship.GenericShip anotherShip)
        {
            bool result = true;

            if (isDiscarded)
            {
                return(false);
            }

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Host, anotherShip);
            int range = shotInfo.Range;

            if (range < MinRange)
            {
                return(false);
            }
            if (range > MaxRange)
            {
                return(false);
            }

            if (!shotInfo.InArc)
            {
                return(false);
            }

            if (!Actions.HasTargetLockOn(Host, anotherShip))
            {
                return(false);
            }

            return(result);
        }
示例#3
0
        public override bool AnotherShipCanBeSelected(GenericShip targetShip, int mouseKeyIsPressed)
        {
            bool result = false;

            if (Roster.GetPlayer(RequiredPlayer).GetType() != typeof(Players.NetworkOpponentPlayer))
            {
                if (Selection.ThisShip != null)
                {
                    if (targetShip.Owner.PlayerNo != Phases.CurrentSubPhase.RequiredPlayer)
                    {
                        Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Selection.ThisShip, targetShip);
                        MovementTemplates.ShowFiringArcRange(shotInfo);
                        result = true;
                    }
                    else
                    {
                        Messages.ShowErrorToHuman("Ship cannot be selected as attack target: Friendly ship");
                    }
                }
                else
                {
                    Messages.ShowErrorToHuman("Ship cannot be selected as attack target:\nFirst select attacker");
                }
            }
            return(result);
        }
示例#4
0
        public bool IsShotAvailable(GenericShip targetShip)
        {
            bool result = true;

            int range;

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Host, targetShip, this);
            range = shotInfo.Range;
            if (!CanShootOutsideArc)
            {
                if (!shotInfo.InShotAngle)
                {
                    return(false);
                }

                if (!shotInfo.CanShootPrimaryWeapon)
                {
                    return(false);
                }
            }

            if (range < MinRange)
            {
                return(false);
            }
            if (range > MaxRange)
            {
                return(false);
            }

            return(result);
        }
示例#5
0
        public override bool IsActionEffectAvailable()
        {
            bool result = false;

            switch (Combat.AttackStep)
            {
            case CombatStep.Attack:
                if ((Combat.ChosenWeapon.GetType() == typeof(PrimaryWeaponClass)) && (Combat.ShotInfo.InArc))
                {
                    result = true;
                }
                break;

            case CombatStep.Defence:
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon);
                if (shotInfo.InArc)
                {
                    result = true;
                }
                break;

            default:
                break;
            }

            return(result);
        }
示例#6
0
 private bool FilterTargetInBullseyeArc(GenericShip ship)
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, ship, HostShip.PrimaryWeapon);
     return(shotInfo.InBullseyeArc && FilterByTargetType(ship, new List <TargetTypes>()
     {
         TargetTypes.Enemy
     }) && FilterTargetsByRange(ship, 1, 3));
 }
示例#7
0
        public bool InPrimaryWeaponFireZone(GenericShip anotherShip)
        {
            bool result = true;

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(this, anotherShip, PrimaryWeapon);
            result = InPrimaryWeaponFireZone(shotInfo.Range, shotInfo.InPrimaryArc);
            return(result);
        }
示例#8
0
 private void BackstabberPilotAbility(ref int diceNumber)
 {
     Board.ShipShotDistanceInformation shotInformation = new Board.ShipShotDistanceInformation(Combat.Defender, Combat.Attacker, Combat.ChosenWeapon);
     if (!shotInformation.InArc)
     {
         Messages.ShowInfo("Backstabber: Additional dice");
         diceNumber++;
     }
 }
示例#9
0
 public void CheckAttackDistanceBonus(ref int result)
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Attacker, Combat.Defender);
     if (shotInfo.Range == 1)
     {
         Messages.ShowInfo("Distance bonus: +1 attack dice");
         result++;
     }
 }
示例#10
0
 private void MaulerMithelPilotAbility(ref int result)
 {
     Board.ShipShotDistanceInformation shotInformation = new Board.ShipShotDistanceInformation(Combat.Attacker, Combat.Defender, Combat.ChosenWeapon);
     if (shotInformation.Range == 1)
     {
         Messages.ShowInfo("\"Mauler Mithel\": +1 attack die");
         result++;
     }
 }
示例#11
0
        private void CheckConditions()
        {
            var shotInformation = new Board.ShipShotDistanceInformation(HostShip, Combat.Attacker);

            if (shotInformation.InArc)
            {
                HostShip.AfterGotNumberOfDefenceDice += RollExtraDice;
            }
        }
示例#12
0
        private int GetAiAbilityPriority(GenericShip ship)
        {
            int result = 0;

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, ship, HostShip.PrimaryWeapon);
            result += (3 - shotInfo.Range) * 100;

            result += ship.Cost + ship.UpgradeBar.GetUpgradesOnlyFaceup().Sum(n => n.Cost);

            return(result);
        }
示例#13
0
        public virtual bool IsShotAvailable(Ship.GenericShip targetShip)
        {
            bool result = true;

            if (isDiscarded)
            {
                return(false);
            }

            int range;

            if (!CanShootOutsideArc)
            {
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Host, targetShip, this);
                range = shotInfo.Range;

                if (!shotInfo.InShotAngle)
                {
                    return(false);
                }
            }
            else
            {
                Board.ShipDistanceInformation distanceInfo = new Board.ShipDistanceInformation(Host, targetShip);
                range = distanceInfo.Range;
            }

            if (range < MinRange)
            {
                return(false);
            }
            if (range > MaxRange)
            {
                return(false);
            }

            if (RequiresTargetLockOnTargetToShoot)
            {
                if (!Actions.HasTargetLockOn(Host, targetShip))
                {
                    return(false);
                }
            }

            if (RequiresFocusToShoot)
            {
                if (!Host.HasToken(typeof(Tokens.FocusToken)))
                {
                    return(false);
                }
            }

            return(result);
        }
示例#14
0
 private void RegisterBraylenStrammPilotAbility(GenericShip ship)
 {
     if (Combat.Attacker == ship && ship.Owner != HostShip.Owner && Combat.Defender != HostShip && Combat.Defender.Owner == HostShip.Owner)
     {
         var arcInfo = new Board.ShipShotDistanceInformation(HostShip, ship);
         if (arcInfo.InArc && arcInfo.Range <= 3)
         {
             RegisterAbilityTrigger(TriggerTypes.OnAttackFinish, PerformFreeAction);
         }
     }
 }
示例#15
0
        public override bool IsActionEffectAvailable()
        {
            bool result = false;

            if (Combat.AttackStep == CombatStep.Defence)
            {
                Board.ShipShotDistanceInformation reverseShotInfo = new Board.ShipShotDistanceInformation(Host, Combat.Attacker, Host.PrimaryWeapon);
                result = !reverseShotInfo.InArc;
            }
            return(result);
        }
示例#16
0
        public override bool IsActionEffectAvailable()
        {
            bool result = false;

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Attacker, Combat.Defender, Combat.ChosenWeapon);
            if ((Combat.AttackStep == CombatStep.Attack) && (shotInfo.Range > 1))
            {
                result = true;
            }
            return(result);
        }
示例#17
0
 public void CanPerformAttack(ref bool result, Ship.GenericShip attacker, Ship.GenericShip defender)
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(attacker, defender);
     if (shotInfo.Range > 3)
     {
         if (attacker.Owner.Type == Players.PlayerType.Human)
         {
             Messages.ShowErrorToHuman("Ship is outside your firing range");
         }
         result = false;
     }
 }
示例#18
0
 private void CheckIsTargetInBullseyeArc()
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, TargetShip, HostShip.PrimaryWeapon);
     if (shotInfo.InBullseyeArc)
     {
         Messages.ShowErrorToHuman("Target Lock is aquired");
         Actions.AssignTargetLockToPair(HostShip, TargetShip, SuccessfullSelection, UnSuccessfullSelection);
     }
     else
     {
         Messages.ShowErrorToHuman("Selected ship is not in bullseye arc");
     }
 }
示例#19
0
 private void TryRegisterStressEffect(GenericShip ship)
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon);
     if (shotInfo.InBullseyeArc)
     {
         Triggers.RegisterTrigger(new Trigger()
         {
             Name         = "Endorcer's ability",
             TriggerType  = TriggerTypes.OnAttackFinish,
             TriggerOwner = ship.Owner.PlayerNo,
             EventHandler = StressEffect
         });
     }
 }
示例#20
0
        public bool IsShotAvailable(GenericShip targetShip)
        {
            bool result = true;

            int range;

            if (Combat.ChosenWeapon.GetType() == GetType())
            {
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Host, targetShip, this);
                range = shotInfo.Range;
                if (!CanShootOutsideArc)
                {
                    //TODO: Change to munitions arc
                    if (!shotInfo.InShotAngle)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (!CanShootOutsideArc)
                {
                    Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Host, targetShip, this);
                    range = shotInfo.Range;

                    //TODO: Change to munitions arc
                    if (!shotInfo.InShotAngle)
                    {
                        return(false);
                    }
                }
                else
                {
                    Board.ShipDistanceInformation distanceInfo = new Board.ShipDistanceInformation(Host, targetShip);
                    range = distanceInfo.Range;
                }
            }

            if (range < MinRange)
            {
                return(false);
            }
            if (range > MaxRange)
            {
                return(false);
            }

            return(result);
        }
示例#21
0
        public override bool IsActionEffectAvailable()
        {
            bool result = false;

            if (Combat.AttackStep == CombatStep.Attack)
            {
                Board.ShipShotDistanceInformation shotInformation = new Board.ShipShotDistanceInformation(Combat.Attacker, Combat.Defender);
                if (shotInformation.Range == 1)
                {
                    result = true;
                }
            }
            return(result);
        }
        private bool IsNoEnemyInArcAndDistance()
        {
            bool result = true;

            foreach (var enemyShip in HostShip.Owner.EnemyShips)
            {
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, enemyShip.Value);
                if (shotInfo.InArc && shotInfo.Range >= 1 && shotInfo.Range <= 3)
                {
                    return(false);
                }
            }

            return(result);
        }
示例#23
0
        public void AnimateMunitionsShot()
        {
            Transform launchOrigin = modelCenter.Find("MunitionsLauncherPoint/MunitionsLauncherDirection");

            if (launchOrigin != null)
            {
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Attacker, Combat.Defender, Combat.ChosenWeapon);
                float distance = shotInfo.Distance;

                Vector3 targetPoint = Selection.AnotherShip.GetModelCenter();
                launchOrigin.LookAt(targetPoint);

                GameObject munition = MonoBehaviour.Instantiate(shipAllParts.Find("Munition").gameObject, launchOrigin);
                munition.GetComponent <MunitionMovement>().selfDescructTimer = distance;
                munition.SetActive(true);
            }
        }
示例#24
0
 private void ActivateOldTerochAbility()
 {
     Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(TargetShip, HostShip);
     // Range is already checked in "SelectTargetForAbility", only check if the Host is in the Target firing arc.
     // Do not use InPrimaryWeaponFireZone, reason :
     //		VCX-100 without docked Phantom cannot shoot using special rear arc,so InPrimaryWeaponFireZone
     //		will be false but this is still arc, so ability should be active - so just InArc is checked,
     //		even ship cannot shoot from it.
     if (shotInfo.InArc == true)
     {
         DiscardFocusAndEvadeTokens();
     }
     else
     {
         Messages.ShowError(HostShip.PilotName + " is not within " + TargetShip.PilotName + " firing arc.");
     }
 }
示例#25
0
        public override bool IsActionEffectAvailable()
        {
            bool result = false;

            if (Combat.AttackStep == CombatStep.Defence && Combat.ShotInfo.InArc)
            {
                Board.ShipDistanceInformation shipDistance = new Board.ShipDistanceInformation(Combat.Attacker, Combat.Defender);
                if (shipDistance.Range == 1)
                {
                    Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon);
                    if (shotInfo.InArc)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
示例#26
0
        private void CheckAbility(GenericShip ship)
        {
            if (IsAbilityUsed)
            {
                return;
            }

            if (HostShip.IsCannotAttackSecondTime)
            {
                return;
            }

            Board.ShipShotDistanceInformation counterAttackInfo = new Board.ShipShotDistanceInformation(Combat.Defender, Combat.Attacker);
            if (!counterAttackInfo.InArc)
            {
                return;
            }

            RegisterAbilityTrigger(TriggerTypes.OnCombatCheckExtraAttack, DoCounterAttack);
        }
示例#27
0
        private void CheckAbility(GenericShip activatedShip)
        {
            if (activatedShip.Owner.PlayerNo == HostShip.Owner.PlayerNo)
            {
                return;
            }

            if (HostShip.Tokens.HasToken(typeof(StressToken)))
            {
                return;
            }

            Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, activatedShip);
            if (!shotInfo.InArc || shotInfo.Range > 3)
            {
                return;
            }

            RegisterAbilityTrigger(TriggerTypes.OnCombatActivation, AskAbility);
        }
示例#28
0
        private void TryRegisterAbility(object sender, System.EventArgs e)
        {
            Players.GenericPlayer opponent = Roster.GetPlayer(Roster.AnotherPlayer(HostShip.Owner.PlayerNo));
            foreach (var ship in opponent.Ships)
            {
                Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(HostShip, ship.Value, HostShip.PrimaryWeapon);
                if (shotInfo.InBullseyeArc)
                {
                    Triggers.RegisterTrigger(new Trigger()
                    {
                        Name         = ship.Value.ShipId + ": " + Name,
                        TriggerType  = TriggerTypes.OnAbilityDirect,
                        TriggerOwner = opponent.PlayerNo,
                        EventHandler = ShowChooseEffect,
                        Sender       = ship.Value
                    });
                }
            }

            Triggers.ResolveTriggers(TriggerTypes.OnAbilityDirect, Triggers.FinishTrigger);
        }
示例#29
0
        public Dictionary<Ship.GenericShip, float> GetEnemyShipsAndDistance(Ship.GenericShip thisShip, bool ignoreCollided = false, bool inArcAndRange = false)
        {
            Dictionary<Ship.GenericShip, float> results = new Dictionary<Ship.GenericShip, float>();

            foreach (var shipHolder in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
            {
                if (ignoreCollided)
                {
                    if (thisShip.LastShipCollision != null)
                    {
                        if (thisShip.LastShipCollision.ShipId == shipHolder.Value.ShipId)
                        {
                            continue;
                        }
                    }
                    if (shipHolder.Value.LastShipCollision != null)
                    {
                        if (shipHolder.Value.LastShipCollision.ShipId == thisShip.ShipId)
                        {
                            continue;
                        }
                    }
                }

                if (inArcAndRange)
                {
                    Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(thisShip, shipHolder.Value);
                    if ((shotInfo.Range > 3) || (!shotInfo.InArc))
                    {
                        continue;
                    }
                }

                float distance = Vector3.Distance(thisShip.GetCenter(), shipHolder.Value.GetCenter());
                results.Add(shipHolder.Value, distance);
            }
            results = results.OrderBy(n => n.Value).ToDictionary(n => n.Key, n => n.Value);

            return results;
        }
示例#30
0
 private void CanAttackIfInArc(ref bool canAttack, GenericShip attacker, GenericShip defender)
 {
     if (attacker.ShipsBumped.Contains(defender))
     {
         if (attacker.ShipId == HostShip.ShipId)
         {
             Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(attacker, defender, attacker.PrimaryWeapon);
             if (shotInfo.InArc)
             {
                 canAttack = true;
             }
         }
         else if (defender.ShipId == HostShip.ShipId)
         {
             Board.ShipShotDistanceInformation shotInfo = new Board.ShipShotDistanceInformation(defender, attacker, defender.PrimaryWeapon);
             if (shotInfo.InArc)
             {
                 canAttack = true;
             }
         }
     }
 }