Esempio n. 1
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));
            }
        }
    }
Esempio n. 2
0
 private static void CheckFireLineCollisions()
 {
     ShotInfo = (ChosenWeapon.GetType() == typeof(Ship.PrimaryWeaponClass)) ? ShotInfo : new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
     ShotInfo.CheckFirelineCollisions(PayAttackCost);
 }