Exemple #1
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);
            }
        }
Exemple #2
0
        public void Clear(ShipPositionInfo positionInfo)
        {
            RealPositionInfo = VirtualPositionInfo = positionInfo;

            SimpleManeuverPredictionIsReady = false;
            NavigationResults = null;
            VirtualPositionWithCollisionsIsReady = false;
        }
 private void SaveFinalPositionInfoBeforeRotation(GameObject shipStand)
 {
     FinalPositionBeforeRotationInfo = new ShipPositionInfo
                                       (
         shipStand.transform.position,
         shipStand.transform.eulerAngles
                                       );
     CurrentMovement.FinalPositionInfoBeforeRotation = FinalPositionBeforeRotationInfo;
 }
Exemple #4
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);
            }
        }
Exemple #5
0
        public virtual void StartBoostExecution(ShipPositionInfo finalPositionInfo)
        {
            BoostExecutionSubPhase execution = (BoostExecutionSubPhase)Phases.StartTemporarySubPhaseNew(
                "Boost execution",
                typeof(BoostExecutionSubPhase),
                CallBack
                );

            execution.TheShip             = TheShip;
            execution.IsTractorBeamBoost  = IsTractorBeamBoost;
            execution.SelectedBoostHelper = SelectedBoostHelper;
            execution.FinalPositionInfo   = finalPositionInfo;
            execution.Start();
        }
Exemple #6
0
 public void SwitchToRealPosition(GenericShip ship)
 {
     if (!DebugManager.DebugMovementShowPlanning)
     {
         ShipPositionInfo savedModelPosition = new ShipPositionInfo(ship.GetShipAllPartsTransform().position, ship.GetShipAllPartsTransform().eulerAngles);
         ship.SetPositionInfo(Ships[ship].RealPositionInfo);
         ship.GetShipAllPartsTransform().position    = savedModelPosition.Position;
         ship.GetShipAllPartsTransform().eulerAngles = savedModelPosition.Angles;
     }
     else
     {
         ship.SetPositionInfo(Ships[ship].RealPositionInfo);
     }
 }
Exemple #7
0
 public void SwitchToVirtualPosition(GenericShip ship)
 {
     if (!DebugManager.DebugMovementShowPlanning)
     {
         ShipPositionInfo savedModelPosition = new ShipPositionInfo(ship.GetShipAllPartsTransform().position, ship.GetShipAllPartsTransform().eulerAngles);
         ship.SetPositionInfo(Ships[ship].VirtualPositionInfo);
         ship.GetShipAllPartsTransform().position    = savedModelPosition.Position;
         ship.GetShipAllPartsTransform().eulerAngles = savedModelPosition.Angles;
         ship.GetShipAllPartsTransform().Find("ShipBase/ShipBaseCollider").position       = Ships[ship].VirtualPositionInfo.Position;
         ship.GetShipAllPartsTransform().Find("ShipBase/ShipBaseCollider").localPosition += new Vector3(0, 0.150289f, 1.156069f);
         ship.GetShipAllPartsTransform().Find("ShipBase/ShipBaseCollider").eulerAngles    = Ships[ship].VirtualPositionInfo.Angles;
     }
     else
     {
         ship.SetPositionInfo(Ships[ship].VirtualPositionInfo);
     }
 }
Exemple #8
0
 public void UpdateSimpleManeuverPrediction(ShipPositionInfo virtualPositionInfo, string maneuverCode)
 {
     VirtualPositionInfo             = virtualPositionInfo;
     PlannedManeuverCode             = maneuverCode;
     SimpleManeuverPredictionIsReady = true;
 }
Exemple #9
0
 public VirtualShipInfo(GenericShip ship)
 {
     Ship             = ship;
     RealPositionInfo = new ShipPositionInfo(ship.GetPosition(), ship.GetAngles());
 }
Exemple #10
0
 public void SetVirtualPositionInfo(GenericShip ship, ShipPositionInfo virtualPositionInfo, string maneuverCode)
 {
     Ships[ship].UpdateSimpleManeuverPrediction(virtualPositionInfo, maneuverCode);
 }
Exemple #11
0
        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();
                                                     }
                                       });
            }
        }
Exemple #12
0
 public void SetVirtualPositionInfo(GenericShip ship, ShipPositionInfo virtualPositionInfo)
 {
     Ships[ship].UpdateVirtualPositionInfo(virtualPositionInfo);
 }
Exemple #13
0
 public void UpdatePositionInfo(ShipPositionInfo positionInfo)
 {
     RealPositionInfo = VirtualPositionInfo = positionInfo;
 }
Exemple #14
0
 public void UpdateVirtualPositionInfo(ShipPositionInfo virtualPositionInfo)
 {
     VirtualPositionInfo = virtualPositionInfo;
 }