예제 #1
0
        void Update()
        {
            if (lastEnemyShip == null || playerShip == null)
            {
                return;
            }

            if (!loadNextLevel && !returnToMenu)
            {
                if (levelBeat && !isLoading)
                {
                    isLoading = true;
                    StartCoroutine(WaitBeforeNextLevel());
                    return;
                }
                else if (levelLost)
                {
                    isLoading = true;
                    StartCoroutine(WaitBeforeReturnToMenu());
                }
            }

            if (loadNextLevel)
            {
                loadNextLevel = false;
                LoadNextLevel();
                return;
            }
            else if (returnToMenu)
            {
                returnToMenu = false;
                ReturnToMenu();
            }

            if (!lastEnemyShip.IsAlive() || !playerShip.IsAlive())
            {
                DisableItems();
                DisableMovement();
                StopVelocity();
                DisableAttacks();
                EnableItems();
                DestroyAllBullets();

                screenFade.SetScreenFade(true);
                DisplayVictoryOrDefeatText();
            }
        }
예제 #2
0
        private void Initialize()
        {
            ResetLevelManager();

            if (!IsMenuScene())
            {
                AssignPlayerComponents();
                AssignLastEnemyComponents();

                // Find inactive GameObjects
                GameObject transitionCanvas = GameObject.Find(Names.TransitionCanvas);
                victoryText = transitionCanvas.transform.Find(Names.VictoryText).gameObject;
                defeatText  = transitionCanvas.transform.Find(Names.DefeatText).gameObject;

                screenFade = UnityEngine.Camera.main.GetComponent <ScreenFade>();
                screenFade.SetScreenFade(false);
            }

            PlayThemeSong();
        }