public static bool IsTargetLegalForAttack(GenericShip targetShip, IShipWeapon weapon, bool isSilent) { bool result = false; if (Rules.TargetIsLegalForShot.IsLegal(true) && weapon.IsShotAvailable(targetShip)) { if (ExtraAttackFilter == null || ExtraAttackFilter(targetShip, weapon, isSilent)) { result = true; } } return(result); }
private static bool IsTargetLegalForAttack() { bool result = false; if (Rules.TargetIsLegalForShot.IsLegal(true) && ChosenWeapon.IsShotAvailable(Selection.AnotherShip)) { if (ExtraAttackFilter == null || ExtraAttackFilter(Selection.AnotherShip, ChosenWeapon)) { result = true; } } return(result); }
public bool IsLegal(GenericShip thisShip, GenericShip anotherShip, IShipWeapon weapon, bool isSilent = false) { bool shipCheckResult = true; shipCheckResult = Selection.ThisShip.CallCanPerformAttack(shipCheckResult, null, isSilent); bool weaponCheckResult = weapon.IsShotAvailable(anotherShip); bool extraAttackFilterResult = false; if (Combat.ExtraAttackFilter == null || Combat.ExtraAttackFilter(anotherShip, weapon, isSilent)) { extraAttackFilterResult = true; } return(shipCheckResult && weaponCheckResult && extraAttackFilterResult); }
// ATTACK TYPES public int GetAnotherAttackTypesCount() { int result = 0; foreach (var upgrade in UpgradeBar.GetUpgradesOnlyFaceup()) { IShipWeapon secondaryWeapon = upgrade as IShipWeapon; if (secondaryWeapon != null) { if (secondaryWeapon.IsShotAvailable(Selection.AnotherShip)) { result++; } } } return(result); }
// ATTACK TYPES public int GetAnotherAttackTypesCount() { int result = 0; foreach (var upgrade in InstalledUpgrades) { IShipWeapon secondaryWeapon = upgrade.Value as IShipWeapon; if (secondaryWeapon != null) { if (secondaryWeapon.IsShotAvailable(Selection.AnotherShip)) { result++; } } } return(result); }
private GenericShip TryToDeclareTarget(GenericShip targetShip, float distance) { GenericShip selectedTargetShip = targetShip; if (DebugManager.DebugAI) { Debug.Log("AI checks target for attack: " + targetShip); } if (targetShip.IsReadyToBeDestroyed) { if (DebugManager.DebugAI) { Debug.Log("But this target is already destroyed"); } return(null); } if (DebugManager.DebugAI) { Debug.Log("Ship is selected before validation: " + selectedTargetShip); } Selection.TryToChangeAnotherShip("ShipId:" + selectedTargetShip.ShipId); IShipWeapon chosenWeapon = null; foreach (var upgrade in Selection.ThisShip.UpgradeBar.GetUpgradesOnlyFaceup()) { IShipWeapon secondaryWeapon = (upgrade as 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); }