public override void PlayDetonationAnimSound(GenericDeviceGameObject bombObject, Action callBack) { BombsManager.CurrentDevice = this; bombObject.transform.Find("Explosion/Explosion").GetComponent <ParticleSystem>().Play(); GameManagerScript.Wait(1, delegate { PlayDefferedSound(bombObject, callBack); }); }
private void ChooseToDetonate(GenericShip detonatedShip, GenericDeviceGameObject bombObject) { SubPhases.DecisionSubPhase.ConfirmDecisionNoCallback(); RegisterMineDetonationForShip(detonatedShip, bombObject); Triggers.ResolveTriggers(TriggerTypes.OnBombIsDetonated, Triggers.FinishTrigger); }
private void CreateBombObject(Vector3 bombPosition, Quaternion bombRotation) { GenericDeviceGameObject prefab = Resources.Load <GenericDeviceGameObject>((BombsManager.CurrentDevice as GenericBomb).bombPrefabPath); BombGO = MonoBehaviour.Instantiate(prefab, bombPosition, bombRotation, Board.GetBoard()); BombGO.Initialize(BombsManager.CurrentDevice as GenericBomb); }
private void ProcessStandOnPath(ObstaclesHitsDetector obstacleHitsDetector) { foreach (GenericObstacle asteroidHit in obstacleHitsDetector.OverlapedAsteroids) { if (!AsteroidsHit.Contains(asteroidHit)) { AsteroidsHit.Add(asteroidHit); } } foreach (var mineHit in obstacleHitsDetector.OverlapedMines) { GenericDeviceGameObject MineObject = mineHit.transform.parent.GetComponent <GenericDeviceGameObject>(); if (!MinesHit.Contains(MineObject)) { MinesHit.Add(MineObject); } } foreach (var remoteMovedThrough in obstacleHitsDetector.RemotesMovedThrough) { if (!RemotesMovedThrough.Contains(remoteMovedThrough)) { RemotesMovedThrough.Add(remoteMovedThrough); } } foreach (var shipsMovedThrough in obstacleHitsDetector.ShipsMovedThrough) { if (!ShipsMovedThrough.Contains(shipsMovedThrough)) { ShipsMovedThrough.Add(shipsMovedThrough); } } }
private void PlayDefferedSound(GenericDeviceGameObject bombObject, Action callBack) { Sounds.PlayBombSound(bombObject, "SeismicBomb"); bombObject.transform.Find("Explosion/Ring").GetComponent <ParticleSystem>().Play(); GameManagerScript.Wait(1.4f, delegate { callBack(); }); }
public void CheckForRemoveFuseInsteadOfDetonating(GenericDeviceGameObject deviceObject) { if (deviceObject.IsFused) { Messages.ShowInfoToHuman($"{BombsManager.CurrentDevice.UpgradeInfo.Name} removes one Fuse token instead of detonating."); deviceObject.Fuses--; BombsManager.DetonationIsAllowed = false; } }
private bool IsAtLeastOneEnemyInRange(GenericBomb bomb, GenericDeviceGameObject bombObject) { List <GenericShip> shipsInRange = BombsManager.GetShipsInRange(bombObject); // Count only enemies shipsInRange = shipsInRange.Where(n => n.Owner.PlayerNo != bomb.HostShip.Owner.PlayerNo).ToList(); return(shipsInRange.Count > 0); }
private void Start() { icon = transform.Find("Fuse/Icon").GetComponent <Image>(); numbers = transform.Find("Fuse/Number").GetComponent <Text>(); parentDevice = transform.GetComponentInParent <GenericDeviceGameObject>(); var parentModelOffset = parentDevice.transform.Find("Explosion")?.transform.localPosition ?? Vector3.zero; transform.localPosition = new Vector3(parentModelOffset.x, transform.localPosition.y, parentModelOffset.z); }
public override void PlayDetonationAnimSound(GenericDeviceGameObject bombObject, Action callBack) { int random = UnityEngine.Random.Range(1, 8); Sounds.PlayBombSound(bombObject, "Explosion-" + random); bombObject.transform.Find("Explosion/Explosion").GetComponent <ParticleSystem>().Play(); bombObject.transform.Find("Explosion/Ring").GetComponent <ParticleSystem>().Play(); GameManagerScript.Wait(1, delegate { callBack(); }); }
private void CheckMines() { foreach (var mineCollider in SelectedTemplate.Collider.OverlapedMinesNow) { GenericDeviceGameObject mineObject = mineCollider.transform.parent.GetComponent <GenericDeviceGameObject>(); if (!TheShip.MinesHit.Contains(mineObject)) { TheShip.MinesHit.Add(mineObject); } } }
public override void PlayDetonationAnimSound(GenericDeviceGameObject bombObject, Action callBack) { BombsManager.CurrentDevice = this; Sounds.PlayBombSound(bombObject, "Explosion-7"); bombObject.transform.Find("Explosion/Explosion").GetComponent <ParticleSystem>().Play(); bombObject.transform.Find("Explosion/Ring").GetComponent <ParticleSystem>().Play(); bombObject.transform.Find("Explosion/Sparks").GetComponent <ParticleSystem>().Play(); GameManagerScript.Wait(1.4f, delegate { callBack(); }); }
private void ProcessMines(ObstaclesStayDetector obstacleStayDetector) { foreach (var mineHit in obstacleStayDetector.OverlapedMines) { GenericDeviceGameObject MineObject = mineHit.transform.parent.GetComponent <GenericDeviceGameObject>(); if (!MinesHit.Contains(MineObject)) { MinesHit.Add(MineObject); } } }
private void CheckAbility(GenericBomb bomb, GenericDeviceGameObject bombObject) { if (!IsAbilityUsed && IsBombFriendly(bomb) && IsAtLeastOneEnemyInRange(bomb, bombObject)) { RegisterAbilityTrigger( TriggerTypes.OnBombIsRemoved, AskToUseSabine, new BombDetonationEventArgs() { BombObject = bombObject } ); } }
private void RegisterMineDetonationForShip(GenericShip detonatedShip, GenericDeviceGameObject bombObject) { Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = HostShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnBombIsDetonated, EventHandler = TryDetonate, EventArgs = new BombDetonationEventArgs() { DetonatedShip = detonatedShip, BombObject = bombObject } }); }
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 CheckNumberOfShipsHit(List <GenericShip> shipsHitMine, GenericDeviceGameObject bombObject) { if (shipsHitMine.Count == 1) { RegisterMineDetonationForShip(shipsHitMine[0], bombObject); } else { Triggers.RegisterTrigger( new Trigger() { Name = "Decide what ship triggered this mine", TriggerOwner = HostShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnBombIsDetonated, EventHandler = delegate { DecideWhatShipTriggeredMine(shipsHitMine, bombObject); }, } ); } }
private void CreateBombObject(Vector3 bombPosition, Quaternion bombRotation) { GenericBomb bomb = BombsManager.CurrentDevice as GenericBomb; GenericDeviceGameObject prefab = Resources.Load <GenericDeviceGameObject>(bomb.bombPrefabPath); var device = MonoBehaviour.Instantiate(prefab, bombPosition, bombRotation, Board.GetBoard()); device.Initialize(bomb); BombObjects.Add(device); if (!string.IsNullOrEmpty(bomb.bombSidePrefabPath)) { GenericDeviceGameObject prefabSide = Resources.Load <GenericDeviceGameObject>(bomb.bombSidePrefabPath); var extraPiece1 = MonoBehaviour.Instantiate(prefabSide, bombPosition, bombRotation, Board.GetBoard()); var extraPiece2 = MonoBehaviour.Instantiate(prefabSide, bombPosition, bombRotation, Board.GetBoard()); BombObjects.Add(extraPiece1); BombObjects.Add(extraPiece2); extraPiece1.Initialize(bomb); extraPiece2.Initialize(bomb); } }
private void DecideWhatShipTriggeredMine(List <GenericShip> shipsHitMine, GenericDeviceGameObject bombObject) { MineDetonationShipSelection subphase = Phases.StartTemporarySubPhaseNew <MineDetonationShipSelection>( "Decide what ship triggered this mine", Triggers.FinishTrigger ); subphase.DescriptionShort = UpgradeInfo.Name; subphase.DescriptionLong = "Decide what ship triggered this mine"; subphase.ImageSource = this; subphase.DecisionOwner = HostShip.Owner; subphase.ShowSkipButton = false; GenericShip enemyShipToDetonate = null; foreach (GenericShip ship in shipsHitMine) { if (ship.Owner.PlayerNo != HostShip.Owner.PlayerNo) { if (enemyShipToDetonate == null || ship.State.HullCurrent + ship.State.ShieldsCurrent < enemyShipToDetonate.State.HullCurrent + enemyShipToDetonate.State.ShieldsCurrent) { enemyShipToDetonate = ship; } } subphase.AddDecision( ship.ShipId + ": " + ship.PilotInfo.PilotName, delegate { ChooseToDetonate(ship, bombObject); }, ship.ImageUrl ); } subphase.DefaultDecisionName = (enemyShipToDetonate != null) ? enemyShipToDetonate.ShipId + ": " + enemyShipToDetonate.PilotInfo.PilotName : subphase.GetDecisions().First().Name; subphase.Start(); }
private void AskToUseSabine(object sender, EventArgs e) { if (!IsAbilityUsed) { Messages.ShowInfoToHuman("Sabine Wren: Select ship to deal 1 damage"); detonatedBombObject = (e as BombDetonationEventArgs).BombObject; SelectTargetForAbility( DealDamageToShip, FilterTargetsForDealDamage, GetAiPriorityForDealDamage, HostShip.Owner.PlayerNo, HostUpgrade.UpgradeInfo.Name, "Choose enemy ship at range 1 of detonated bomb token,\nthat ship suffers 1 damage", HostUpgrade ); } else { Messages.ShowErrorToHuman("Sabine Wren's ability has already been used!"); Triggers.FinishTrigger(); } }
public static void PlayBombSound(GenericDeviceGameObject bombObjectComponent, string path) { PlayBombSound(bombObjectComponent.gameObject, path); }
public virtual void PlayDetonationAnimSound(GenericDeviceGameObject bombObject, Action callBack) { callBack(); }
private void GetResults() { bool finalPositionFound = false; SuccessfullMovementProgress = 0; ObstaclesStayDetector lastShipBumpDetector = null; for (int i = generatedShipStands.Length - 1; i >= 0; i--) { ObstaclesStayDetector obstacleStayDetector = generatedShipStands[i].GetComponentInChildren <ObstaclesStayDetector>(); ObstaclesHitsDetector obstacleHitsDetector = generatedShipStands[i].GetComponentInChildren <ObstaclesHitsDetector>(); if (!finalPositionFound) { if (obstacleStayDetector.OverlapsShip) { lastShipBumpDetector = obstacleStayDetector; } else { IsOffTheBoard = obstacleStayDetector.OffTheBoard; LandedOnObstacles = new List <GenericObstacle>(obstacleStayDetector.OverlapedAsteroids); SuccessfullMovementProgress = (float)(i) / (generatedShipStands.Length - 1); if (lastShipBumpDetector != null) { foreach (var overlapedShip in lastShipBumpDetector.OverlapedShips) { if (!ShipsBumped.Contains(overlapedShip)) { ShipsBumped.Add(overlapedShip); } } } foreach (var overlapedRemote in obstacleStayDetector.OverlapedRemotes) { if (!RemotesOverlapped.Contains(overlapedRemote)) { RemotesOverlapped.Add(overlapedRemote); } } foreach (var asteroidHit in obstacleStayDetector.OverlapedAsteroids) { if (!AsteroidsHit.Contains(asteroidHit)) { AsteroidsHit.Add(asteroidHit); } } foreach (var mineHit in obstacleStayDetector.OverlapedMines) { GenericDeviceGameObject MineObject = mineHit.transform.parent.GetComponent <GenericDeviceGameObject>(); if (!MinesHit.Contains(MineObject)) { MinesHit.Add(MineObject); } } finalPositionFound = true; // Rotate last temp base if (i == generatedShipStands.Length - 1 && CurrentMovement.RotationEndDegrees != 0) { Vector3 centerOfTempBase = generatedShipStands[i].transform.TransformPoint(new Vector3(0, 0, -0.5f)); generatedShipStands[i].transform.RotateAround(centerOfTempBase, new Vector3(0, 1, 0), CurrentMovement.RotationEndDegrees); } FinalPosition = generatedShipStands[i].transform.position; FinalAngles = generatedShipStands[i].transform.eulerAngles; FinalPositionInfo = new ShipPositionInfo(FinalPosition, FinalAngles); //break; } } else { foreach (GenericObstacle asteroidHit in obstacleHitsDetector.OverlapedAsteroids) { if (!AsteroidsHit.Contains(asteroidHit)) { AsteroidsHit.Add(asteroidHit); } } foreach (var mineHit in obstacleHitsDetector.OverlapedMines) { GenericDeviceGameObject MineObject = mineHit.transform.parent.GetComponent <GenericDeviceGameObject>(); if (!MinesHit.Contains(MineObject)) { MinesHit.Add(MineObject); } } } } Selection.ThisShip.ToggleColliders(true); if (!DebugManager.DebugMovementDestroyTempBasesLater) { DestroyGeneratedShipStands(); if (CallBack != null) { CallBack(); } } else { GameManagerScript.Wait(2, delegate { DestroyGeneratedShipStands(); if (CallBack != null) { CallBack(); } }); } }