コード例 #1
0
        private void InitScreens()
        {
            ScreenState_MainMenu mainMenuScreen =
                new ScreenState_MainMenu(this, _mainMenu);
            ScreenState_Play playScreen =
                new ScreenState_Play(this);
            ScreenState_Pause pauseScreen =
                new ScreenState_Pause(this, _pauseMenu);
            ScreenState_Settings settingsScreen =
                new ScreenState_Settings(this, _settingsMenu);
            ScreenState_GameOver gameOverScreen =
                new ScreenState_GameOver
                    (this, _gameOverScreen, PinballManager.Instance.GameOverDelay);

            _screenStates.Add(mainMenuScreen);
            _screenStates.Add(playScreen);
            _screenStates.Add(pauseScreen);
            _screenStates.Add(settingsScreen);
            _screenStates.Add(gameOverScreen);

            SetState(CurrentScreenState, mainMenuScreen);
        }
コード例 #2
0
        public bool PerformTransition(ScreenStateType targetState)
        {
            //Debug.Log("Next screen: " + targetState);

            if (!CurrentScreenState.CheckTransition(targetState))
            {
                Debug.LogWarning(targetState +
                                 " is currently not a valid state.");
                return(false);
            }

            bool result = false;

            ScreenStateBase state = GetStateByType(targetState);

            if (state != null)
            {
                // The pause state if it is currently active
                ScreenState_Pause pauseState =
                    CurrentScreenState as ScreenState_Pause;

                // Time continues if the pause state is exited
                // to something else than settings menu state
                if (pauseState != null &&
                    targetState != ScreenStateType.SettingsMenu)
                {
                    pauseState.ResumeGame();
                }

                SetState(CurrentScreenState, state);
                result = true;
            }
            else
            {
                Debug.LogError(targetState + " screen object is missing.");
            }

            return(result);
        }