private IEnumerator CheckPositions() { DisableRenderers(); OldPosition = HostShip.GetPositionInfo(); ObstaclesStayDetectorForced collisionDetector = HostShip.Model.GetComponentInChildren <ObstaclesStayDetectorForced>(); RelocateToFrontGuides(); collisionDetector.ReCheckCollisionsStart(); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); bool canBePlacedFront = NoCollisionsWithObjects(collisionDetector); collisionDetector.ReCheckCollisionsFinish(); RelocateToRearGuides(); collisionDetector.ReCheckCollisionsStart(); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); bool canBePlacedRear = NoCollisionsWithObjects(collisionDetector); collisionDetector.ReCheckCollisionsFinish(); HostShip.SetPositionInfo(OldPosition); RestoreRenderers(); if (!canBePlacedFront && !canBePlacedRear) { Messages.ShowInfo("Buzz Droid Swarm cannot be relocated without overlapping"); DealDamageToBothShips(); } else if (canBePlacedFront && canBePlacedRear) { StartDecisionSubphase(); } else if (canBePlacedFront && !canBePlacedRear) { RelocateToFrontGuidesAndFinish(Triggers.FinishTrigger); } else if (!canBePlacedFront && canBePlacedRear) { RelocateToRearGuidesAndFinish(Triggers.FinishTrigger); } }
private void GetResults(System.Action <bool> canBoostCallback = null) { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); HidePlanningTemplates(); if (canBoostCallback != null) { canBoostCallback(IsBoostAllowed(true)); return; } if (IsBoostAllowed()) { CheckMines(); TheShip.LandedOnObstacles = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); TheShip.ObstaclesHit = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); obstaclesStayDetectorMovementTemplate.OverlappedAsteroidsNow .Where((a) => !TheShip.ObstaclesHit.Contains(a)).ToList() .ForEach(TheShip.ObstaclesHit.Add); GameMode.CurrentGameMode.StartBoostExecution(); } else { GameMode.CurrentGameMode.CancelBoost(); } }
private void GetResults() { collisionChecker.ReCheckCollisionsFinish(); if (collisionChecker.OverlapsShipNow) { //TODO: FIX: Select manually GenericShip detonatedShip = collisionChecker.OverlappedShipsNow[0]; Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = detonatedShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnPositionFinish, EventHandler = Detonate, Sender = detonatedShip }); Triggers.ResolveTriggers(TriggerTypes.OnBombDetonated, CallBack); } else { CallBack(); } }
private void GetResults(ObstaclesStayDetectorForced collisionChecker) { collisionChecker.ReCheckCollisionsFinish(); if (collisionChecker.OverlapsShipNow) { List <GenericShip> shipsHitMine = collisionChecker.OverlappedShipsNow; CheckNumberOfShipsHit(shipsHitMine, collisionChecker.transform.parent.GetComponent <GenericDeviceGameObject>()); } immediateDetonationsCheckedCount++; int minesDropped = string.IsNullOrEmpty(bombSidePrefabPath) ? 1 : 3; if (immediateDetonationsCheckedCount == minesDropped) { GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>(); for (int i = 0; i < minesDropped; i++) { Game.Movement.FuncsToUpdate.Remove(delegate { return(UpdateColisionDetection(collisionChecker)); }); } immediateDetonationsCheckedCount = 0; Triggers.ResolveTriggers(TriggerTypes.OnBombIsDetonated, CallBack); } }
private void GetResults(ObstaclesStayDetectorForced collisionChecker) { collisionChecker.ReCheckCollisionsFinish(); if (collisionChecker.OverlapsShipNow) { //TODO: FIX: Select manually GenericShip detonatedShip = collisionChecker.OverlappedShipsNow[0]; Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = detonatedShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnPositionFinish, EventHandler = TryDetonate, EventArgs = new BombDetonationEventArgs() { DetonatedShip = detonatedShip, BombObject = collisionChecker.transform.parent.gameObject } }); } immediateDetonationsCheckedCount++; int minesDropped = string.IsNullOrEmpty(bombSidePrefabPath) ? 1 : 3; if (immediateDetonationsCheckedCount == minesDropped) { immediateDetonationsCheckedCount = 0; Triggers.ResolveTriggers(TriggerTypes.OnBombIsDetonated, CallBack); } }
private void GetResults(System.Action <bool> canBoostCallback = null) { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); ShipPositionInfo shipPositionInfo = new ShipPositionInfo(ShipStand.transform.position, ShipStand.transform.eulerAngles); HidePlanningTemplates(); if (canBoostCallback != null) { canBoostCallback(CheckBoostProblems(true).Count == 0); return; } List <ActionFailReason> boostProblems = CheckBoostProblems(); if (boostProblems.Count == 0) { CheckMines(); TheShip.ObstaclesLanded = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); obstaclesStayDetectorMovementTemplate.OverlappedAsteroidsNow .Where((a) => !TheShip.ObstaclesHit.Contains(a)).ToList() .ForEach(TheShip.ObstaclesHit.Add); StartBoostExecution(shipPositionInfo); } else { CancelBoost(boostProblems); } }
private IEnumerator CheckCollisions() { foreach (var temporaryShipBase in TemporaryShipBases.Values) { ObstaclesStayDetectorForced detector = temporaryShipBase.transform.Find("ShipBase").Find("ObstaclesStayDetector").gameObject.AddComponent <ObstaclesStayDetectorForced>(); detector.ReCheckCollisionsStart(); yield return(new WaitForFixedUpdate()); detector.ReCheckCollisionsFinish(); } }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsBarrelRollAllowed()) { StartBarrelRollExecution(Selection.ThisShip); } else { CancelBarrelRoll(); } }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsBarrelRollAllowed()) { CheckMines(); Selection.ThisShip.IsLandedOnObstacle = obstaclesStayDetectorBase.OverlapsAsteroidNow; GameMode.CurrentGameMode.StartBarrelRollExecution(Selection.ThisShip); } else { GameMode.CurrentGameMode.CancelBarrelRoll(); } }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsBoostAllowed()) { StartBoostExecution(Selection.ThisShip); } else { CancelBoost(); } HidePlanningTemplates(); }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsDecloakAllowed()) { CheckMines(); StartDecloakExecution(Selection.ThisShip); } else { CancelDecloak(); } HidePlanningTemplates(); }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsDecloakAllowed()) { CheckMines(); Selection.ThisShip.LandedOnObstacles = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); GameMode.CurrentGameMode.StartDecloakExecution(Selection.ThisShip); } else { GameMode.CurrentGameMode.CancelDecloak(); } HidePlanningTemplates(); }
private void GetResults() { obstaclesStayDetectorBase.ReCheckCollisionsFinish(); obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish(); if (IsBarrelRollAllowed()) { CheckMines(); TheShip.LandedOnObstacles = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); TheShip.ObstaclesHit = new List <GenericObstacle>(obstaclesStayDetectorBase.OverlappedAsteroidsNow); obstaclesStayDetectorMovementTemplate.OverlappedAsteroidsNow .Where((a) => !TheShip.ObstaclesHit.Contains(a)).ToList() .ForEach(TheShip.ObstaclesHit.Add); GameMode.CurrentGameMode.StartBarrelRollExecution(); } else { GameMode.CurrentGameMode.CancelBarrelRoll(); } }
private IEnumerator CheckBombPlacement() { ObstaclesStayDetectorForced detector = BombGO.GetComponentInChildren <ObstaclesStayDetectorForced>(); detector.ReCheckCollisionsStart(); yield return(WaitForFrames(2)); detector.ReCheckCollisionsFinish(); if (detector.OverlapsCurrentShipNow) { GameCommand command = GeneratePlaceBombCommand(BombGO.transform.position, BombGO.transform.eulerAngles); GameMode.CurrentGameMode.ExecuteCommand(command); } else { Messages.ShowError("The bomb must be touching ship's base"); IsInReposition = true; } }
private void GetResults(ObstaclesStayDetectorForced collisionChecker) { collisionChecker.ReCheckCollisionsFinish(); if (collisionChecker.OverlapsShipNow) { //TODO: FIX: Select manually GenericShip detonatedShip = collisionChecker.OverlappedShipsNow[0]; Triggers.RegisterTrigger(new Trigger() { Name = "Damage from mine", TriggerOwner = detonatedShip.Owner.PlayerNo, TriggerType = TriggerTypes.OnPositionFinish, EventHandler = TryDetonate, EventArgs = new BombDetonationEventArgs() { DetonatedShip = detonatedShip, BombObject = collisionChecker.transform.parent.gameObject } }); } immediateDetonationsCheckedCount++; int minesDropped = string.IsNullOrEmpty(bombSidePrefabPath) ? 1 : 3; if (immediateDetonationsCheckedCount == minesDropped) { GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>(); for (int i = 0; i < minesDropped; i++) { Game.Movement.FuncsToUpdate.Remove(delegate { return(UpdateColisionDetection(collisionChecker)); }); } immediateDetonationsCheckedCount = 0; Triggers.ResolveTriggers(TriggerTypes.OnBombIsDetonated, CallBack); } }