/// <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)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
            Keyboard.GetState().IsKeyDown(Keys.Escape))
        {
            Exit();
        }

        if (Keyboard.GetState().IsKeyDown(Keys.F8))
        {
            graphics.IsFullScreen = !graphics.IsFullScreen;
            graphics.ApplyChanges();
        }

        switch (currentMode)
        {
        case MODE.GAME: game.Update(gameTime); break;

        case MODE.WELCOME: welcomeScr.Update(gameTime); break;

        case MODE.LOADING: loadingScr.Update(gameTime); break;

        case MODE.CREDITS: creditsScr.Update(gameTime); break;

        case MODE.CONFIG: configScr.Update(gameTime); break;

        case MODE.HELP: helpScr.Update(gameTime); break;

        case MODE.END: endScr.Update(gameTime); break;
        }

        base.Update(gameTime);
    }
Beispiel #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

            // Updates keyboard and mouse states
            Globals.UpdateGlobals();

            // If there is a fade active, no other update code is run
            // If the game is paused, no other update code is run and there is a check to see if the player has left it. If the help screen is open, it runs that logic.
            // Otherwise, it runs the logic for the current mode.
            if (Globals.Fade.Active)
            {
                Globals.Fade.Update();
            }
            else if (paused)
            {
                // Checks if the player unpauses, or if they press the menu button
                if (Globals.CheckKey(Keys.Escape))
                {
                    paused = false;
                }
                else if (menuBtn.CheckButton())
                {
                    Globals.Fade.Start(Globals.MENU, 1);
                    paused = false;
                }
            }
            else if (Globals.HelpScreenOpen)
            {
                HelpScreen.Update();
            }
            else
            {
                switch (Globals.Gamestate)
                {
                case Globals.LOGO:
                {
                    // Once the logo has lasted for its entire duration, the fade to the menu begins
                    if (logoDuration.CheckCooldown())
                    {
                        Globals.Fade.Start(Globals.MENU, 1);
                    }
                    else
                    {
                        logoDuration.UpdateCooldown();
                    }
                    break;
                }

                case Globals.TRANSITION:
                {
                    TransitionScreen.Update();
                    break;
                }

                case Globals.MENU:
                {
                    Menu.Update();
                    break;
                }

                case Globals.GAMEPLAY:
                {
                    // Checks if the player has paused
                    if (Globals.CheckKey(Keys.Escape))
                    {
                        paused = true;
                    }

                    // Updates the game that is currently running
                    switch (Globals.Minigame)
                    {
                    case Globals.LUCKY_DAY:
                    {
                        luckyDay.Update();
                        break;
                    }

                    case Globals.COLOR_GUESSER:
                    {
                        colorGuesser.Update();
                        break;
                    }

                    case Globals.RAINDROPS:
                    {
                        raindrops.Update();
                        break;
                    }

                    case Globals.JUGGLER:
                    {
                        juggler.Update();
                        break;
                    }

                    case Globals.TERMINAL_VELOCITY:
                    {
                        terminalVelocity.Update();
                        break;
                    }

                    case Globals.BACKWARDS:
                    {
                        backwards.Update();
                        break;
                    }

                    case Globals.TYPEWRITER:
                    {
                        typewriter.Update();
                        break;
                    }

                    case Globals.FLOOR_IS_LAVA:
                    {
                        floorIsLava.Update();
                        break;
                    }

                    case Globals.MILKSHAKER:
                    {
                        milkshaker.Update();
                        break;
                    }

                    case Globals.CIRCLE_CLICKER:
                    {
                        circleClicker.Update();
                        break;
                    }
                    }
                    break;
                }

                case Globals.LEADERBOARD:
                {
                    Leaderboard.Update();
                    break;
                }

                case Globals.RESULTS:
                {
                    Results.Update();
                    break;
                }
                }
            }
            base.Update(gameTime);
        }