private bool IsAtLeastOneEnemyInRange(GenericBomb bomb, GameObject bombObject) { List <GenericShip> shipsInRange = BombsManager.GetShipsInRange(bombObject); // Count only enemies shipsInRange = shipsInRange.Where(n => n.Owner.PlayerNo != bomb.Host.Owner.PlayerNo).ToList(); return(shipsInRange.Count > 0); }
private void DetonateObstacle() { //TODO: Animation if (ChosenObstacle != null) { ObstaclesManager.Instance.DestroyObstacle(ChosenObstacle); } BombsManager.ResolveDetonationTriggers(); }
protected override void Detonate() { Phases.OnActivationPhaseEnd_Triggers -= PlanTimedDetonation; foreach (var ship in BombsManager.GetShipsInRange(BombsManager.CurrentBombObject)) { RegisterDetonationTriggerForShip(ship); } base.Detonate(); }
private void DoSecondDrop(object sender, EventArgs e) { DecisionSubPhase.ConfirmDecisionNoCallback(); IsSecondBombDropped = true; ForbiddenTemplate = BombsManager.LastManeuverTemplateUsed; HostShip.OnGetAvailableBombDropTemplatesForbid += RestrictLastTemplate; // TODO: Check interactions BombsManager.DropSelectedDevice(false); }
private void DropBomb(object sender, System.EventArgs e) { DecisionSubPhase.ConfirmDecisionNoCallback(); BombsManager.RegisterBombDropTriggerIfAvailable( HostShip, TriggerTypes.OnAbilityDirect, subType: UpgradeSubType.Bomb, onlyDrop: true, isRealDrop: false ); Triggers.ResolveTriggers(TriggerTypes.OnAbilityDirect, Triggers.FinishTrigger); }
private void CheckEdonKappehlAbility(GenericShip ship) { if (ship.AssignedManeuver.ColorComplexity != Movement.MovementComplexity.Easy && ship.AssignedManeuver.ColorComplexity != Movement.MovementComplexity.Normal) { return; } if (ship.IsBombAlreadyDropped || !BombsManager.HasBombsToDrop(ship)) { return; } RegisterAbilityTrigger(TriggerTypes.OnMovementActivationStart, AskEdonKappehlAbility); }
private void CheckDamage(GenericBomb bomb, GenericDeviceGameObject model) { if (BombsManager.GetShipsInRange(model).Contains(Host)) { Triggers.RegisterTrigger( new Trigger() { Name = "Rattled: Damage", TriggerOwner = Host.Owner.PlayerNo, TriggerType = TriggerTypes.OnAbilityDirect, EventHandler = RattledDamage } ); } }
private void StartRemoteDeployment(object sender, EventArgs e) { SubPhases.DecisionSubPhase.ConfirmDecisionNoCallback(); BombsManager.RegisterBombDropTriggerIfAvailable( HostShip, TriggerTypes.OnAbilityDirect, type: HostUpgrade.GetType() ); Triggers.ResolveTriggers( TriggerTypes.OnAbilityDirect, FinishRemoteDeployment ); }
private void UseGeniusAbility(object sender, EventArgs e) { List <GenericUpgrade> timedBombsInstalled = BombsManager.GetTimedBombsInstalled(HostShip); DecisionSubPhase.ConfirmDecisionNoCallback(); if (timedBombsInstalled.Count == 1) { BombsManager.CurrentBomb = timedBombsInstalled[0] as GenericBomb; StartDropBombSubphase(); } else { AskToSelectTimedBomb(StartDropBombSubphase); } }
private void CheckCatAbility(ref int count) { if (Combat.ChosenWeapon.WeaponType == WeaponTypes.PrimaryWeapon) { foreach (var bombHolder in BombsManager.GetBombsOnBoard()) { List <GenericShip> shipsNear = BombsManager.GetShipsInRange(bombHolder.Key); if (shipsNear.Contains(Combat.Defender) && bombHolder.Value.HostShip.Owner.PlayerNo == HostShip.Owner.PlayerNo) { Messages.ShowInfo(HostShip.PilotInfo.PilotName + ": +1 attack die"); count++; return; } } } }
private void CheckCatAbility(ref int count) { if (Combat.ChosenWeapon.WeaponType == WeaponTypes.PrimaryWeapon) { foreach (var bombHolder in BombsManager.GetBombsOnBoard()) { if (bombHolder.Value.HostShip.Owner.PlayerNo == HostShip.Owner.PlayerNo && BombsManager.IsShipInRange(Combat.Defender, bombHolder.Key, 1)) { Messages.ShowInfo(HostShip.PilotInfo.PilotName + " gains +1 attack die"); count++; return; } } } }
private void CheckDamage() { if (Selection.ThisShip.MinesHit.Count > 0) { foreach (var mine in Selection.ThisShip.MinesHit) { Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = Selection.ThisShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnPositionFinish, EventHandler = BombsManager.GetMineByObject(mine).Detonate, Sender = Selection.ThisShip }); } } }
private void DeployRemote(object sender, EventArgs e) { SubPhases.DecisionSubPhase.ConfirmDecisionNoCallback(); BombsManager.RegisterBombDropTriggerIfAvailable( HostShip, TriggerTypes.OnAbilityDirect, type: HostUpgrade.GetType() ); Triggers.ResolveTriggers( TriggerTypes.OnAbilityDirect, delegate { HostUpgrade.State.SpendCharge(); Triggers.FinishTrigger(); } ); }
private void CheckDistanceAdvanced() { float minDistance = float.MaxValue; foreach (Vector3 bombPoint in BombsManager.GetBombPoints(Bomb)) { MeshCollider obstacleCollider = Obstacle.ObstacleGO.GetComponentInChildren <MeshCollider>(); Vector3 obstacleColliderPoint = obstacleCollider.ClosestPoint(bombPoint); float distanceBetweenEdges = Vector3.Distance(bombPoint, obstacleColliderPoint); if (distanceBetweenEdges < minDistance) { minDistance = distanceBetweenEdges; } } Range = Mathf.Max(1, Mathf.CeilToInt(minDistance / Board.DISTANCE_INTO_RANGE)); }
private void DropBomb(object sender, EventArgs e) { if (!HostShip.IsStressed && HasAvailableDevice()) { BombsManager.RegisterBombDropTriggerIfAvailable( HostShip, TriggerTypes.OnAbilityDirect, onlyDrop: false, isRealDrop: false ); Triggers.ResolveTriggers(TriggerTypes.OnAbilityDirect, Triggers.FinishTrigger); } else { Triggers.FinishTrigger(); } }
private bool IsShipInDetonationRange(GenericShip ship, GameObject bombObject) { List <Vector3> bombPoints = BombsManager.GetBombPoints(); foreach (var localBombPoint in bombPoints) { Vector3 globalBombPoint = bombObject.transform.TransformPoint(localBombPoint); foreach (var globalShipBasePoint in ship.ShipBase.GetStandPoints().Select(n => n.Value)) { if (Board.BoardManager.GetRangeBetweenPoints(globalBombPoint, globalShipBasePoint) == 1) { return(true); } } } return(false); }
private void FinallyDetonateBomb() { BombsManager.UnregisterBomb(BombsManager.CurrentBombObject); CurrentBombObjects.Remove(BombsManager.CurrentBombObject); if (ChosenObstacle != null) { foreach (GenericShip ship in Roster.AllShips.Values) { ShipObstacleDistance shipOstacleDist = new ShipObstacleDistance(ship, ChosenObstacle); if (shipOstacleDist.Range < 2) { RegisterDetonationTriggerForShip(ship); } } } PlayDetonationAnimSound(BombsManager.CurrentBombObject, DetonateObstacle); }
private bool CheckDistanceSimple() { foreach (Vector3 bombPoint in BombsManager.GetBombPoints(Bomb)) { float distanceBetween = Vector3.Distance(bombPoint, Obstacle.ObstacleGO.transform.position); Range = Mathf.Max(1, Mathf.CeilToInt(distanceBetween / Board.DISTANCE_INTO_RANGE)); if (Range == 1) { return(true); } if (Range > 4) { return(true); } } return(false); }
private bool CheckDistanceSimple() { foreach (Vector3 bombPoint in BombsManager.GetBombPoints(Bomb)) { float distanceBetween = Vector3.Distance(bombPoint, Obstacle.ObstacleGO.transform.position); Range = Board.DistanceToRange(distanceBetween); if (Range == 1) { return(true); } if (Range > 4) { return(true); } } return(false); }
private void CheckGeniusAbility(GenericShip ship) { if (HostShip.IsBumped) { return; } if (HostShip.IsBombAlreadyDropped) { return; } if (!BombsManager.HasBombsToDrop(ship, BombTypeRestriction)) { return; } if (BoardTools.Board.IsOffTheBoard(ship)) { return; } RegisterAbilityTrigger(TriggerTypes.OnMovementActivationStart, AskUseGeniusAbility); }
private void CheckGeniusAbility(GenericShip ship) { if (HostShip.IsBumped) { return; } if (HostShip.IsBombAlreadyDropped) { return; } if (!BombsManager.HasTimedBombs(ship)) { return; } if (Board.BoardManager.IsOffTheBoard(ship)) { return; } RegisterAbilityTrigger(TriggerTypes.OnMovementActivation, AskUseGeniusAbility); }
private void CheckDamage(GenericShip ship) { if (ship.MinesHit.Count > 0) { foreach (var mine in ship.MinesHit) { Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = ship.Owner.PlayerNo, TriggerType = TriggerTypes.OnPositionFinish, EventHandler = BombsManager.GetBombByObject(mine).TryDetonate, EventArgs = new BombDetonationEventArgs() { DetonatedShip = ship, BombObject = mine } }); } } }
void Start() { SetApplicationParameters(); InitializeScripts(); //Global.Initialize(); Board.Initialize(); Roster.Initialize(); Roster.Start(); Selection.Initialize(); BombsManager.Initialize(); Actions.Initialize(); Combat.Initialize(); Triggers.Initialize(); DamageDecks.Initialize(); CheckRemoteSettings(); GameMode.CurrentGameMode.StartBattle(); }
private void AskToSelectTimedBomb(Action callback) { GeniusBombDecisionSubPhase selectBombToDrop = (GeniusBombDecisionSubPhase)Phases.StartTemporarySubPhaseNew( "Select bomb to drop", typeof(GeniusBombDecisionSubPhase), callback ); foreach (var timedBombInstalled in BombsManager.GetTimedBombsInstalled(HostShip)) { selectBombToDrop.AddDecision( timedBombInstalled.Name, delegate { SelectBomb(timedBombInstalled); } ); } selectBombToDrop.InfoText = "Select bomb to drop"; selectBombToDrop.DefaultDecisionName = BombsManager.GetTimedBombsInstalled(HostShip).First().Name; selectBombToDrop.RequiredPlayer = HostShip.Owner.PlayerNo; selectBombToDrop.Start(); }
public override bool IsActionAvailable() { return(BombsManager.GetBombsInRange(HostShip).Count == 0); }
private void RegisterMine() { BombsManager.RegisterMines(BombObjects, this); CheckImmediateDetonation(); }
private static void ShowCollisionResults() { string title = "Results of collision detection"; string description = ""; if (MovementPrediction.AsteroidsHit.Count > 0) { description += "Obstacles hit: "; foreach (GenericObstacle obstacle in MovementPrediction.AsteroidsHit) { description += obstacle.Name + ", "; } description = description.Remove(description.Length - 2, 2); description += "\n"; } if (MovementPrediction.IsLandedOnAsteroid) { description += "Landed on obstacles: "; foreach (GenericObstacle obstacle in MovementPrediction.LandedOnObstacles) { description += obstacle.Name + ", "; } description = description.Remove(description.Length - 2, 2); description += "\n"; } if (MovementPrediction.MinesHit.Count > 0) { description += "Mines hit: "; foreach (GenericDeviceGameObject mine in MovementPrediction.MinesHit) { description += BombsManager.GetBombByObject(mine).UpgradeInfo.Name + ", "; } description = description.Remove(description.Length - 2, 2); description += "\n"; } if (MovementPrediction.ShipsBumped.Count > 0) { description += "Bumped into ships: "; foreach (GenericShip ship in MovementPrediction.ShipsBumped) { description += ship.PilotInfo.PilotName + " (" + ship.ShipId + "), "; } description = description.Remove(description.Length - 2, 2); description += "\n"; } if (MovementPrediction.RemotesMovedThrough.Count > 0) { description += "Remotes hit: "; foreach (GenericRemote remote in MovementPrediction.RemotesMovedThrough) { description += remote.PilotInfo.PilotName + ", "; } description = description.Remove(description.Length - 3, 2); description += "\n"; } if (MovementPrediction.RemotesOverlapped.Count > 0) { description += "Landed on remotes: "; foreach (GenericRemote remote in MovementPrediction.RemotesOverlapped) { description += remote.PilotInfo.PilotName + ", "; } description = description.Remove(description.Length - 2, 2); description += "\n"; } if (description != "") { description = description.Remove(description.Length - 1, 1); } else { description = "No collisions"; } Phases.CurrentSubPhase.ShowSubphaseDescription(title, description); }
private void Start() { //sets manager form the same object manager = GetComponent <BombsManager>(); }
public virtual void ActivateBombs(List <GameObject> bombObjects, Action callBack) { Host.IsBombAlreadyDropped = true; BombsManager.RegisterBombs(bombObjects, this); PayDropCost(callBack); }
private void UseEdonKappehlAbility(object sender, EventArgs e) { DecisionSubPhase.ConfirmDecisionNoCallback(); BombsManager.CreateAskBombDropSubPhase(HostShip, onlyDrop: true); }