protected override void doUpdate(GameTime currentTime)
        {
            button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds;
            zoom += currentTime.ElapsedGameTime.Milliseconds;

            switch (zoom_state)
            {
            case popUpZoomState.zoomIn:
                if (zoom > zoom_duration)
                {
                    pop_up_menu = true;
                    zoom_state  = popUpZoomState.zoomStay;
                    zoom        = 0.0f;
                }
                break;

            case popUpZoomState.zoomStay:
                zoom = 0.0f;
                break;

            case popUpZoomState.zoomOut:
                if (zoom > zoom_duration)
                {
                    zoom_state    = popUpZoomState.zoomStay;
                    pop_up_menu   = false;
                    pop_up_screen = false;
                    zoom          = 0.0f;
                }
                break;
            }

            if (!pop_up_menu)
            {
                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection))
                {
                    if (!down_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }
                    down_pressed = true;
                }

                if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    down_pressed         = false;
                    AudioLib.playSoundEffect(menuBlipSound);
                    menu_item_select++;

                    if (menu_item_select >= options_list.Count())
                    {
                        menu_item_select = menu_item_select % options_list.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        menu_item_select += options_list.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection))
                {
                    if (!up_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }

                    up_pressed = true;
                }

                if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    up_pressed           = false;
                    AudioLib.playSoundEffect(menuBlipSound);
                    menu_item_select--;

                    if (menu_item_select > 0)
                    {
                        menu_item_select = menu_item_select % options_list.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        menu_item_select += options_list.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
                {
                    confirm_pressed = true;
                }
                else if (confirm_pressed)
                {
                    confirm_pressed = false;

                    switch (options_list[menu_item_select].text)
                    {
                    case "HIGH SCORE":
                        isComplete = true;
                        break;

                    case "ERASE HIGH SCORE":
                        pop_up_screen       = true;
                        popup_item_selected = 0;
                        zoom_state          = popUpZoomState.zoomIn;
                        HighScoresState.ResetHighScores();
                        SaveGameModule.saveGame();
                        break;

                    case "CREDITS":
                        isComplete = true;
                        break;

                    case "BACK":
                        isComplete = true;
                        break;

                    default:
                        break;
                    }
                }

                for (int i = 0; i < options_list.Count(); i++)
                {
                    if (i == menu_item_select)
                    {
                        options_list[menu_item_select].select = true;
                    }
                    else
                    {
                        options_list[i].select = false;
                    }

                    options_list[i].update(currentTime);
                }
            }
            /*************************************************************************************************************/
            else
            {
                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection))
                {
                    if (!down_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }
                    down_pressed = true;
                }

                if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    down_pressed         = false;

                    popup_item_selected++;

                    if (popup_item_selected >= popup_options.Count())
                    {
                        popup_item_selected = popup_item_selected % popup_options.Count();
                    }
                    else if (menu_item_select < 0)
                    {
                        popup_item_selected += popup_options.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection))
                {
                    if (!up_pressed)
                    {
                        button_pressed_timer = 0.0f;
                    }

                    up_pressed = true;
                }

                if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection) && button_pressed_timer > max_button_pressed_timer))
                {
                    button_pressed_timer = 0.0f;
                    up_pressed           = false;

                    popup_item_selected--;

                    if (popup_item_selected > 0)
                    {
                        popup_item_selected = popup_item_selected % popup_options.Count();
                    }
                    else if (popup_item_selected < 0)
                    {
                        popup_item_selected += popup_options.Count();
                    }
                }

                if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm))
                {
                    confirm_pressed = true;
                }
                else if (confirm_pressed)
                {
                    confirm_pressed = false;

                    switch (popup_options[popup_item_selected].text)
                    {
                    case "NO":
                        zoom_state = popUpZoomState.zoomOut;
                        break;

                    case "YES":
                        zoom_state = popUpZoomState.zoomOut;
                        break;

                    default:
                        break;
                    }
                }

                for (int i = 0; i < popup_options.Count(); i++)
                {
                    if (i == popup_item_selected)
                    {
                        popup_options[popup_item_selected].select = true;
                    }
                    else
                    {
                        popup_options[i].select = false;
                    }

                    popup_options[i].update(currentTime);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new high scores screen state.
        /// </summary>
        /// <param name="inGame">If the player has died or completed the game, set this to true. If simply checking the scores from the menu, set this to false</param>
        public HighScoresState(bool inGame, bool gameComplete)
        {
            InitalizeHighScores();

            HighScoreValue newScore = new HighScoreValue(GameCampaign.PlayerName, GameCampaign.Player_Coin_Amount, GameCampaign.ElapsedCampaignTime, GameCampaign.PlayerLevelProgress, GameCampaign.PlayerFloorHeight);

            this.inGame       = inGame;
            this.gameComplete = gameComplete;

            try
            {
                SignedInGamer gamer = Gamer.SignedInGamers[InputDevice2.GetPlayerGamePadIndex(InputDevice2.PPG_Player.Player_1)];
                isSignedIn = (gamer != null);
            }
            catch (Exception)
            {
                isSignedIn = false;
            }

            if (inGame)
            {
                highScores.Add(newScore);

                // if there are 11 high scores now, remove the lowest score
                if (highScores.Count > 10)
                {
                    HighScoreValue    lowestScore = highScores[0];
                    CompareHighScores comparer    = new CompareHighScores();

                    for (int i = 1; i < highScores.Count; i++)
                    {
                        if (comparer.Compare(highScores[i], lowestScore) < 0)
                        {
                            lowestScore = highScores[i];
                        }
                    }

                    highScores.Remove(lowestScore);
                }

                highScores.Sort(new CompareHighScores());
                highScores.Reverse();

                for (int i = 0; i < highScores.Count; i++)
                {
                    if (highScores[i].playerName == newScore.playerName && highScores[i].secondsElapsed == newScore.secondsElapsed && highScores[i].floorDiedOn == newScore.floorDiedOn)
                    {
                        newlyAddedScoreIndex = i;
                    }
                }

                SaveGameModule.saveGame();
            }
            else
            {
                highScores.Sort(new CompareHighScores());
                highScores.Reverse();
            }

            stateTimer = 0;

            if (isSignedIn)
            {
                SaveGameModule.loadGame();
            }
        }
Exemple #3
0
        protected override void doUpdate(GameTime currentTime)
        {
            button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds;
            fade += currentTime.ElapsedGameTime.Milliseconds;

            if (screen == titleScreens.menuScreen || screen == titleScreens.playScreen)
            {
                fade_duration = max_fade_menu_timer;
            }
            else
            {
                fade_duration = max_fade_timer;
            }

            switch (screen)
            {
            case titleScreens.introScreen:
                if (fade > max_fade_timer)
                {
                    fade       = 0.0f;
                    fade_state = (FadeState)(((int)fade_state + 1) % 3);
                    if (fade_state == FadeState.stay)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                }
                break;

            /**************************************************************************************************************************/
            case titleScreens.logoScreen:
                if (fade > fade_duration)
                {
                    fade       = 0.0f;
                    fade_state = (FadeState)(((int)fade_state + 1) % 3);

                    if (fade_state == FadeState.fadeIn)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                    else if (fade_state == FadeState.stay)
                    {
                        fade          = 0.0f;
                        fade_duration = logo_stay_timer;
                    }
                    else if (fade_state == FadeState.fadeOut)
                    {
                        fade          = 0.0f;
                        fade_duration = max_fade_timer;
                    }
                }
                break;

            /**************************************************************************************************************************/
            case titleScreens.menuScreen:
                if (!music_playing)
                {
                    BackGroundAudio.playSong("Menu", true);
                    music_playing = true;
                }

                if (Game1.videoPlayer.State == Microsoft.Xna.Framework.Media.MediaState.Stopped)
                {
                    Game1.videoPlayer.IsLooped = true;
                    Game1.videoPlayer.Play(Game1.titleScreenVideo);
                }


                if (fade > max_fade_menu_timer)
                {
                    fade       = 0.0f;
                    fade_state = FadeState.stay;
                    if (fade_state == FadeState.fadeIn)
                    {
                        fade   = 0.0f;
                        screen = titleScreens.menuScreen;
                    }
                }

                if (storageDevicePrompted)
                {
                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad)
                    {
                        if (!down_pressed)
                        {
                            button_pressed_timer = 0.0f;
                        }

                        down_pressed = true;
                    }

                    if ((down_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad)) || (down_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.DownDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer))
                    {
                        down_pressed         = false;
                        button_pressed_timer = 0.0f;

                        menu_item_selected++;
                        AudioLib.playSoundEffect(menuBlipSound);
                        if (menu_item_selected >= menu_list.Count())
                        {
                            menu_item_selected = menu_item_selected % menu_list.Count();
                        }
                        else if (menu_item_selected < 0)
                        {
                            menu_item_selected += menu_list.Count();
                        }
                    }

                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad)
                    {
                        if (!up_pressed)
                        {
                            button_pressed_timer = 0.0f;
                        }
                        up_pressed = true;
                    }

                    if ((up_pressed && !(InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad)) || (up_pressed && (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.UpDirection) != InputDevice2.PlayerPad.NoPad) && button_pressed_timer > max_button_pressed_timer))
                    {
                        up_pressed           = false;
                        button_pressed_timer = 0.0f;

                        menu_item_selected--;
                        AudioLib.playSoundEffect(menuBlipSound);
                        if (menu_item_selected >= menu_list.Count())
                        {
                            menu_item_selected = menu_item_selected % menu_list.Count();
                        }
                        else if (menu_item_selected < 0)
                        {
                            menu_item_selected += menu_list.Count();
                        }
                    }

                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                    {
                        confirm_pressed = true;

                        whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm);
                    }
                    else if (confirm_pressed)
                    {
                        confirm_pressed = false;

                        switch (menu_list[menu_item_selected].text)
                        {
                        case "START":
                            screen     = titleScreens.playScreen;
                            fade_state = FadeState.fadeOut;
                            fade       = 0.0f;
                            break;

                        case "OPTIONS":
                            InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, whoPressedConfirm);
                            screen     = titleScreens.optionScreen;
                            fade_state = FadeState.fadeOut;
                            fade       = 0.0f;
                            break;

                        case "QUIT":
                            Game1.exitGame = true;
                            break;
                        }
                    }

                    for (int i = 0; i < menu_list.Count(); i++)
                    {
                        if (i == menu_item_selected)
                        {
                            menu_list[menu_item_selected].selected = true;
                        }
                        else
                        {
                            menu_list[i].selected = false;
                        }
                        menu_list[i].update(currentTime);
                    }
                }
                else
                {
                    if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm) != InputDevice2.PlayerPad.NoPad)
                    {
                        confirm_pressed = true;

                        whoPressedConfirm = InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.Confirm);
                    }
                    else if (confirm_pressed)
                    {
                        confirm_pressed = false;

                        SaveGameModule.selectStorageDevice((PlayerIndex)whoPressedConfirm);
                        SaveGameModule.loadGame();

                        storageDevicePrompted = true;
                    }
                }
                break;

            /*****************************************************************************************************/
            default:
                if (fade > max_fade_menu_timer)
                {
                    isComplete = true;
                    BackGroundAudio.stopAllSongs();
                    Game1.videoPlayer.Stop();
                }
                break;
            }
        }