private void TestShotDistance()
    {
        Ship.GenericShip ship1    = Roster.GetShipById("ShipId:1");
        Ship.GenericShip ship2    = Roster.GetShipById("ShipId:2");
        ShotInfo         shotInfo = new ShotInfo(ship1, ship2, ship1.PrimaryWeapons);

        if (shotInfo.IsShotAvailable)
        {
            MovementTemplates.ShowRangeRuler(shotInfo.MinDistance);
        }
        else
        {
            MovementTemplates.ReturnRangeRuler();
        }
    }
Example #2
0
        public override void Next()
        {
            if (DebugManager.DebugPhases)
            {
                Debug.Log("Combat SubPhase - Next");
            }

            UI.HideSkipButton();
            MovementTemplates.ReturnRangeRuler();
            Selection.DeselectAllShips();

            bool success = GetNextActivation(RequiredPilotSkill);

            if (!success)
            {
                int nextPilotSkill = GetNextPilotSkill(RequiredPilotSkill);

                if (nextPilotSkill != RequiredPilotSkill)
                {
                    Phases.Events.CallCombatSubPhaseRequiredPilotSkillIsChanged();
                }

                if (nextPilotSkill != int.MaxValue)
                {
                    success = GetNextActivation(nextPilotSkill);
                }
                else
                {
                    FinishPhase();
                }
            }

            if (success)
            {
                if (DebugManager.DebugPhases)
                {
                    Debug.Log("Attack time for: " + RequiredPlayer + ", skill " + RequiredPilotSkill);
                }

                UpdateHelpInfo();
                Roster.HighlightShipsFiltered(FilterShipsToPerfromAttack);

                IsReadyForCommands = true;
                Roster.GetPlayer(RequiredPlayer).PerformAttack();
            }
        }
Example #3
0
    // CHECK LEGALITY OF ATTACK

    public static void TryPerformAttack()
    {
        UI.HideContextMenu();
        MovementTemplates.ReturnRangeRuler();

        if (IsTargetLegalForAttack())
        {
            UI.HideSkipButton();
            Roster.AllShipsHighlightOff();

            DeclareAttackerAndDefender();

            CheckFireLineCollisions();
        }
        else
        {
            Roster.GetPlayer(Phases.CurrentPhasePlayer).OnTargetNotLegalForAttack();
        }
    }
Example #4
0
    // CHECK LEGALITY OF ATTACK

    public static void TryPerformAttack(bool isSilent)
    {
        UI.HideContextMenu();
        MovementTemplates.ReturnRangeRuler();

        if (IsTargetLegalForAttack(Selection.AnotherShip, ChosenWeapon, isSilent))
        {
            UI.HideSkipButton();
            Roster.AllShipsHighlightOff();

            DeclareAttackerAndDefender();

            CheckFireLineCollisions();
        }
        else
        {
            IsAttackAlreadyCalled = false;
            Roster.GetPlayer(Phases.CurrentPhasePlayer).OnTargetNotLegalForAttack();
        }
    }
Example #5
0
        private void HanSoloSetupRangeHelper()
        {
            List <DistanceInfo> distancesToShips = new List <DistanceInfo>();

            foreach (GenericShip placedEnemyShip in HostShip.Owner.AnotherPlayer.Ships.Values.Where(n => n.IsSetupPerformed))
            {
                distancesToShips.Add(new DistanceInfo(HostShip, placedEnemyShip));
            }

            MovementTemplates.ReturnRangeRuler();

            if (distancesToShips.Count > 0)
            {
                DistanceInfo minDistance = distancesToShips.OrderBy(n => n.MinDistance.DistanceReal).First();
                if (minDistance.Range <= 3)
                {
                    MovementTemplates.ShowRangeRuler(minDistance.MinDistance);
                }
            }
        }
        private void PerformCoordinateEffect()
        {
            Selection.ThisShip = TargetShip;

            Triggers.RegisterTrigger(
                new Trigger()
            {
                Name         = "Coordinate",
                TriggerOwner = Selection.ThisShip.Owner.PlayerNo,
                TriggerType  = TriggerTypes.OnFreeActionPlanned,
                EventHandler = PerformFreeAction
            }
                );

            MovementTemplates.ReturnRangeRuler();

            Triggers.ResolveTriggers(TriggerTypes.OnFreeActionPlanned, delegate {
                Phases.FinishSubPhase(typeof(CoordinateTargetSubPhase));
                CallBack();
            });
        }
Example #7
0
        private void SelectColonelJendonAbilityTarget()
        {
            if (TargetShip.Tokens.HasToken(typeof(Tokens.BlueTargetLockToken), '*'))
            {
                Messages.ShowErrorToHuman("Only ships without blue target lock tokens can be selected");
                return;
            }

            MovementTemplates.ReturnRangeRuler();

            var token = HostShip.Tokens.GetToken(typeof(Tokens.BlueTargetLockToken), '*') as Tokens.BlueTargetLockToken;

            Actions.ReassignTargetLockToken(
                token.Letter,
                this.HostShip,
                TargetShip,
                delegate {
                Phases.FinishSubPhase(Phases.CurrentSubPhase.GetType());
                DecisionSubPhase.ConfirmDecision();
            });
        }
Example #8
0
        private void SelectLandoCalrissianPilotAbilityTarget()
        {
            Selection.ThisShip = TargetShip;

            Triggers.RegisterTrigger(
                new Trigger()
            {
                Name         = "Lando Calrissian's ability: Free action",
                TriggerOwner = Selection.ThisShip.Owner.PlayerNo,
                TriggerType  = TriggerTypes.OnFreeActionPlanned,
                EventHandler = PerformFreeAction
            }
                );

            MovementTemplates.ReturnRangeRuler();

            Triggers.ResolveTriggers(TriggerTypes.OnFreeActionPlanned, delegate {
                Phases.FinishSubPhase(typeof(SelectLandoCalrissianPilotAbilityTargetSubPhase));
                Triggers.FinishTrigger();
            });
        }
Example #9
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));
            }
        }
    }
Example #10
0
        private void PerformJamEffect()
        {
            var jammingShip = Selection.ThisShip;
            var targetShip  = TargetShip;

            Triggers.RegisterTrigger(
                new Trigger()
            {
                Name         = "Jam",
                TriggerOwner = Selection.ThisShip.Owner.PlayerNo,
                TriggerType  = TriggerTypes.OnTokenIsAssigned,
                EventHandler = (s, e) => AssignJamToken(targetShip)
            }
                );

            MovementTemplates.ReturnRangeRuler();

            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsAssigned, delegate {
                Selection.ThisShip = jammingShip;
                Phases.FinishSubPhase(typeof(JamTargetSubPhase));
                CallBack();
            });
        }
Example #11
0
        private void SelectSquadLeaderTarget()
        {
            Selection.ThisShip = TargetShip;

            Triggers.RegisterTrigger(
                new Trigger()
            {
                Name         = "Squad Leader: Free action",
                TriggerOwner = Selection.ThisShip.Owner.PlayerNo,
                TriggerType  = TriggerTypes.OnFreeActionPlanned,
                EventHandler = PerformFreeAction
            }
                );

            MovementTemplates.ReturnRangeRuler();

            Triggers.ResolveTriggers(TriggerTypes.OnFreeActionPlanned, delegate {
                Phases.FinishSubPhase(typeof(SelectSquadLeaderTargetSubPhase));
                Phases.FinishSubPhase(typeof(ActionDecisonSubPhase));
                Triggers.FinishTrigger();
                CallBack();
            });
        }
Example #12
0
        public override void Next()
        {
            if (DebugManager.DebugPhases)
            {
                Debug.Log("Combat SubPhase - Next");
            }

            UI.HideSkipButton();
            MovementTemplates.ReturnRangeRuler();
            Selection.DeselectAllShips();

            // Try to get any pilot with same inititative, that didn't perform attack
            bool success = GetNextActivation(RequiredInitiative);

            if (success)
            {
                ReadyForCombatActivation();
            }
            else
            {
                ChangeInitiative();
            }
        }
Example #13
0
    // CHECK LEGALITY OF ATTACK

    public static void TryPerformAttack(bool isSilent)
    {
        UI.HideContextMenu();

        MovementTemplates.ReturnRangeRuler();

        if (ChosenWeapon != null && Rules.TargetIsLegalForShot.IsLegal(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon, isSilent))
        {
            if (!DebugManager.NoCinematicCamera)
            {
                CommandsList.ShotCamera.ShowShotCamera(Selection.ThisShip, Selection.AnotherShip);
                GameManagerScript.Wait(3, StartLegalAttack);
            }
            else
            {
                StartLegalAttack();
            }
        }
        else
        {
            IsAttackAlreadyCalled = false;
            Roster.GetPlayer(Phases.CurrentPhasePlayer).OnTargetNotLegalForAttack();
        }
    }
Example #14
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));
            }
        }
    }
Example #15
0
        private void PerformMultiCoordinateEffect(GenericShip targetShip)
        {
            Selection.ChangeActiveShip(targetShip);
            GenericAction currentAction = ActionsHolder.CurrentAction;

            Triggers.RegisterTrigger(
                new Trigger()
            {
                Name         = "Coordinate",
                TriggerOwner = Selection.ThisShip.Owner.PlayerNo,
                TriggerType  = TriggerTypes.OnFreeActionPlanned,
                EventHandler = delegate { PerformFreeAction(targetShip); }
            }
                );

            MovementTemplates.ReturnRangeRuler();

            Triggers.ResolveTriggers(TriggerTypes.OnFreeActionPlanned, (System.Action) delegate {
                Selection.ChangeActiveShip(CoordinateActionData.CoordinateProvider);
                CoordinateActionData.CoordinateProvider.OnCoordinateTargetIsSelected -= PrepareToRememberChosenAction;
                ActionsHolder.CurrentAction = currentAction;
                Triggers.FinishTrigger();
            });
        }
Example #16
0
        private void SelectGarvenDreisAbilityTarget()
        {
            MovementTemplates.ReturnRangeRuler();

            TargetShip.Tokens.AssignToken(typeof(FocusToken), SelectShipSubPhase.FinishSelection);
        }
Example #17
0
 //TODO: What is this?
 public virtual void CallNextSubPhase()
 {
     UI.HideTemporaryMenus();
     MovementTemplates.ReturnRangeRuler();
     Next();
 }
Example #18
0
 private void SelectSpacetugTarget()
 {
     MovementTemplates.ReturnRangeRuler();
     Tokens.TractorBeamToken token = new Tokens.TractorBeamToken(TargetShip, SpacetugOwner.Owner);
     TargetShip.Tokens.AssignToken(token, SelectShipSubPhase.FinishSelection);
 }
Example #19
0
 public static void CloseActionsPanel()
 {
     MovementTemplates.ReturnRangeRuler();
     Game.PrefabsList.PanelActions.SetActive(false);
 }