Esempio n. 1
0
        public void ChangeGameStatus(GameStatus newStatus, bool restart = false)
        {
            if (newStatus == GameStatus.Loose)
            {
                // Audio
                Registry.AudioManager.MusicVolume = 0.2f;

                Registry.AudioManager.SpeakAsync("Mission failed ! You're ship has been destroyed !");

                // Interface
                gameUI.Kill();

                // Aliens
                _ennemyManager.Kill();

                // Joueurs
                if (_player.Active)
                {
                    _player.Kill();
                }

                // Messages
                _looseTimer.Start();
                messageBoxManager.ActiveMessageBox(MessageBoxType.End);
            }

            else if (newStatus == GameStatus.Paused)
            {
                _ennemyManager.Enabled = false;

                _player.Enabled = false;

                gameUI.Enabled = false;

                messageBoxManager.ActiveMessageBox(MessageBoxType.Pause);
            }

            else if (newStatus == GameStatus.Running)
            {
                _ennemyManager.Enabled = true;

                _player.Enabled = true;

                gameUI.Active = true;
                messageBoxManager.DesactiveMessageBoxes();
            }

            else if (newStatus == GameStatus.Starting)
            {
                Registry.AudioManager.SpeakAsync("Get ready !");

                _ennemyManager.Enabled = false;

                _player.Enabled = false;

                messageBoxManager.ActiveMessageBox(MessageBoxType.Start);
            }

            else if (newStatus == GameStatus.Success)
            {
                Registry.AudioManager.StopMusic();
                YnG.SwitchState(new ScoreState(true));
            }

            else if (newStatus == GameStatus.Quit)
            {
                Registry.AudioManager.StopMusic();
                YnG.SwitchState(new ScoreState(true));
            }

            else if (newStatus == GameStatus.Died)
            {
                Registry.AudioManager.StopMusic();
                YnG.SwitchState(new ScoreState(true));
            }

            gameStatus = newStatus;

            if (restart)
            {
                RestartScene();
            }
        }