Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        private void GetResults()
        {
            bool finalPositionFound = false;
            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)
                    {
                        // Save information in which ships we are bumped
                        lastShipBumpDetector = obstacleStayDetector;
                    }
                    else
                    {
                        finalPositionFound          = true;
                        SuccessfullMovementProgress = (float)(i) / (GeneratedShipStands.Length - 1);

                        ProcessBumpedShips(lastShipBumpDetector);

                        ProcessFinalPosition(i);
                        ProcessOffTheBoard(obstacleStayDetector);
                        ProcessObstaclesLanded(obstacleStayDetector);
                        ProcessRemotesOverlaps(obstacleStayDetector);
                        ProcessObstaclesHit(obstacleStayDetector);
                        ProcessMines(obstacleStayDetector);
                    }
                }
                else
                {
                    ProcessStandOnPath(obstacleHitsDetector);
                }
            }
        }
Пример #3
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;
                        IsLandedOnAsteroid          = obstacleStayDetector.OverlapsAsteroid;
                        SuccessfullMovementProgress = (float)(i) / (generatedShipStands.Length - 1);

                        if (lastShipBumpDetector != null)
                        {
                            foreach (var overlapedShip in lastShipBumpDetector.OverlapedShips)
                            {
                                if (!ShipsBumped.Contains(overlapedShip))
                                {
                                    ShipsBumped.Add(overlapedShip);
                                }
                            }
                        }

                        foreach (var asteroidHit in obstacleStayDetector.OverlapedAsteroids)
                        {
                            if (!AsteroidsHit.Contains(asteroidHit))
                            {
                                AsteroidsHit.Add(asteroidHit);
                            }
                        }

                        foreach (var mineHit in obstacleStayDetector.OverlapedMines)
                        {
                            GameObject MineObject = mineHit.transform.parent.gameObject;
                            if (!MinesHit.Contains(MineObject))
                            {
                                MinesHit.Add(MineObject);
                            }
                        }

                        finalPositionFound = true;
                        //break;
                    }
                }
                else
                {
                    foreach (var asteroidHit in obstacleHitsDetector.OverlapedAsteroids)
                    {
                        if (!AsteroidsHit.Contains(asteroidHit))
                        {
                            AsteroidsHit.Add(asteroidHit);
                        }
                    }
                    foreach (var mineHit in obstacleHitsDetector.OverlapedMines)
                    {
                        GameObject MineObject = mineHit.transform.parent.gameObject;
                        if (!MinesHit.Contains(MineObject))
                        {
                            MinesHit.Add(MineObject);
                        }
                    }
                }
            }

            Selection.ThisShip.ToggleColliders(true);

            if (!DebugManager.DebugMovement)
            {
                DestroyGeneratedShipStands();
                CallBack();
            }
            else
            {
                GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>();
                Game.Wait(2, delegate { DestroyGeneratedShipStands(); CallBack(); });
            }
        }
Пример #4
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();
                                                     }
                                       });
            }
        }
Пример #5
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
                    {
                        IsLandedOnAsteroid          = obstacleStayDetector.OverlapsAsteroid;
                        SuccessfullMovementProgress = (i + 1f) / generatedShipStands.Length;

                        if (lastShipBumpDetector != null)
                        {
                            foreach (var overlapedShip in lastShipBumpDetector.OverlapedShips)
                            {
                                if (!ShipsBumped.Contains(overlapedShip))
                                {
                                    ShipsBumped.Add(overlapedShip);
                                }
                            }
                        }

                        foreach (var asteroidHit in obstacleStayDetector.OverlapedAsteroids)
                        {
                            if (!AsteroidsHit.Contains(asteroidHit))
                            {
                                AsteroidsHit.Add(asteroidHit);
                            }
                        }

                        finalPositionFound = true;
                        //break;
                    }
                }
                else
                {
                    foreach (var asteroidHit in obstacleHitsDetector.OverlapedAsteroids)
                    {
                        if (!AsteroidsHit.Contains(asteroidHit))
                        {
                            AsteroidsHit.Add(asteroidHit);
                        }
                    }
                }
            }

            Selection.ThisShip.ToggleColliders(true);

            DestroyGeneratedShipStands();

            currentMovement.LaunchShipMovement();
        }