예제 #1
0
        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);
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
    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();
        }
    }
예제 #8
0
        private void GetResults()
        {
            obstaclesStayDetectorBase.ReCheckCollisionsFinish();
            obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish();

            if (IsBarrelRollAllowed())
            {
                StartBarrelRollExecution(Selection.ThisShip);
            }
            else
            {
                CancelBarrelRoll();
            }
        }
예제 #9
0
        private void GetResults()
        {
            obstaclesStayDetectorBase.ReCheckCollisionsFinish();
            obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish();

            if (IsBarrelRollAllowed())
            {
                CheckMines();
                Selection.ThisShip.IsLandedOnObstacle = obstaclesStayDetectorBase.OverlapsAsteroidNow;
                GameMode.CurrentGameMode.StartBarrelRollExecution(Selection.ThisShip);
            }
            else
            {
                GameMode.CurrentGameMode.CancelBarrelRoll();
            }
        }
예제 #10
0
        private void GetResults()
        {
            obstaclesStayDetectorBase.ReCheckCollisionsFinish();
            obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish();

            if (IsBoostAllowed())
            {
                StartBoostExecution(Selection.ThisShip);
            }
            else
            {
                CancelBoost();
            }

            HidePlanningTemplates();
        }
예제 #11
0
        private void GetResults()
        {
            obstaclesStayDetectorBase.ReCheckCollisionsFinish();
            obstaclesStayDetectorMovementTemplate.ReCheckCollisionsFinish();

            if (IsDecloakAllowed())
            {
                CheckMines();
                StartDecloakExecution(Selection.ThisShip);
            }
            else
            {
                CancelDecloak();
            }

            HidePlanningTemplates();
        }
예제 #12
0
        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();
        }
예제 #13
0
        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();
            }
        }
예제 #14
0
        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;
            }
        }
예제 #15
0
        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);
            }
        }