예제 #1
0
        public void Update(ref ApplicationState appState, InputState input, PlayerIndex[] controllingPlayer)
        {
            base.Update(input, controllingPlayer);

            if (confirm == true)
            {
                switch (quitScreen.Update(input, controllingPlayer))
                {
                case 1: appState = ApplicationState.InitaliseApp;
                    break;

                case 0: confirm = false;
                    menuIndex   = 1;
                    return;
                }
            }

            if (selectedIndex == 0 || (input.IsNewButtonPress(ButtonMappings.Pad_BBtn, controllingPlayer[0], out controllingPlayer[1]) ||
                                       input.IsNewKeyPress(ButtonMappings.Keyboard_BBtn, controllingPlayer[0], out controllingPlayer[1])))
            {
                menuIndex = 0;
                appState  = ApplicationState.Playing;
            }
            else if (selectedIndex == 1)
            {
                confirm = true;
                quitScreen.Reset();
            }
        }
예제 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here
            input.Update();
            switch (appState)
            {
            case ApplicationState.Splash:       splashScreen.Update(ref appState, input, ref controllingPlayer);
                break;

            case ApplicationState.InitaliseApp: break;

            case ApplicationState.Home:         homeScreen.Update(ref appState, input, controllingPlayer);
                break;

            case ApplicationState.Options:      optionsScreen.Update(ref appState, input, controllingPlayer);
                break;

            case ApplicationState.Quit:
            {
                switch (quitScreen.Update(input, controllingPlayer))
                {
                case 0: appState = ApplicationState.InitaliseApp;
                    break;

                case 1:    this.Exit();
                    break;
                }
                break;
            }

            case ApplicationState.Trial:        trialScreen.Update(ref appState, input, controllingPlayer);
                break;

            case ApplicationState.GameOver:     gameOverScreen.Update(gameState.GetFinalLevel(), gameState.GetFinalScore(), ref appState, input, controllingPlayer);
                break;

            case ApplicationState.GameComplete: break;

            case ApplicationState.InitaliseGame: MediaPlayer.Stop();
                break;

            //ApplicationState.Playing || ApplicationState.Paused || ApplicationState.LevelComplete
            default:                            gameState.Update(gameTime, ref appState, input, controllingPlayer);
                break;
            }
            if (appState == ApplicationState.InitaliseGame)
            {
                gameState.Initialize(this);
                appState = ApplicationState.Playing;
            }

            if (appState == ApplicationState.InitaliseApp)
            {
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Volume      = 0.20f;
                MediaPlayer.Play(this.Content.Load <Song>("Audio\\Music\\Start"));
                homeScreen.Reset();
                trialScreen.Reset();
                gameOverScreen.Reset();
                appState = ApplicationState.Home;
            }

            gameOptions.IsTrial = Guide.IsTrialMode;
            base.Update(gameTime);
        }