Example #1
0
 private static void CleanupCombatData()
 {
     AttackStep   = CombatStep.None;
     Attacker     = null;
     Defender     = null;
     ChosenWeapon = null;
     ShotInfo     = null;
 }
Example #2
0
        private Ship.GenericShip TryToDeclareTarget(Ship.GenericShip targetShip, float distance)
        {
            Ship.GenericShip selectedTargetShip = targetShip;

            if (DebugManager.DebugAI)
            {
                Debug.Log("AI checks target for attack: " + targetShip);
            }

            if (DebugManager.DebugAI)
            {
                Debug.Log("Ship is selected before validation: " + selectedTargetShip);
            }
            Selection.TryToChangeAnotherShip("ShipId:" + selectedTargetShip.ShipId);

            Ship.IShipWeapon chosenWeapon = null;

            foreach (var upgrade in Selection.ThisShip.UpgradeBar.GetUpgradesOnlyFaceup())
            {
                Ship.IShipWeapon secondaryWeapon = (upgrade as Ship.IShipWeapon);
                if (secondaryWeapon != null)
                {
                    if (secondaryWeapon.IsShotAvailable(targetShip))
                    {
                        chosenWeapon = secondaryWeapon;
                        break;
                    }
                }
            }

            chosenWeapon        = chosenWeapon ?? Selection.ThisShip.PrimaryWeapon;
            Combat.ChosenWeapon = chosenWeapon;
            Combat.ShotInfo     = new Board.ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, Combat.ChosenWeapon);

            if (Rules.TargetIsLegalForShot.IsLegal(true) && Combat.ChosenWeapon.IsShotAvailable(Selection.AnotherShip))
            {
                if (DebugManager.DebugAI)
                {
                    Debug.Log("AI target legal: " + Selection.AnotherShip);
                }
            }
            else
            {
                if (DebugManager.DebugAI)
                {
                    Debug.Log("But validation is not passed: " + selectedTargetShip);
                }
                selectedTargetShip = null;
            }

            if (DebugManager.DebugAI)
            {
                Debug.Log("AI decision about " + targetShip + " : " + selectedTargetShip);
            }

            return(selectedTargetShip);
        }
Example #3
0
        public void PerformAttackWithWeapon(Ship.IShipWeapon weapon)
        {
            Tooltips.EndTooltip();

            Combat.ChosenWeapon = weapon;

            Messages.ShowInfo("Attack with " + weapon.Name);

            Phases.FinishSubPhase(typeof(WeaponSelectionDecisionSubPhase));
            CallBack();
        }
Example #4
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();
    }
Example #5
0
        private static List <Ship.IShipWeapon> GetAllWeapons()
        {
            List <Ship.IShipWeapon> allWeapons = new List <Ship.IShipWeapon>();

            allWeapons.Add(Selection.ThisShip.PrimaryWeapon);

            foreach (var upgrade in Selection.ThisShip.InstalledUpgrades)
            {
                Ship.IShipWeapon secondaryWeapon = upgrade.Value as Ship.IShipWeapon;
                if (secondaryWeapon != null)
                {
                    allWeapons.Add(secondaryWeapon);
                }
            }

            return(allWeapons);
        }