Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
            if (metaState == MetaState.InitialLoad)
            {
                splashScreen = new SplashScreen();
                metaState = MetaState.SplashScreen;
            }

            // Controls
            //if (GamePad.GetState(Game.playerIndex).Buttons.Back == ButtonState.Pressed)
              //  this.Exit();
            if (HighScoreTracker.device!=null && Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                HighScoreData data = HighScoreTracker.LoadHighScores();
                data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                data.musicEnabled = gameSettings.musicEnabled;
                data.displayHelp = gameSettings.displayControls;
                data.wideScreen = gameSettings.wideScreen;
                data.keyboardControls = gameSettings.keyboardControls;
                HighScoreTracker.SaveHighScores(data);
                Logger.CloseLogger();
                this.Exit();
            }
            if (metaState == MetaState.SplashScreen)
            {
                if (MenuResult.GoToMainMenu == splashScreen.Update(gameTime))
                {
                    base.Initialize();
                    try
                    {
                        if (Guide.IsVisible == true)
                            splashScreen.stillActive = true;
                        else
                            StorageDevice.BeginShowSelector(this.GetDevice, "Select Storage Device");
                    }
                    catch
                    {
                        splashScreen.stillActive = true;
                    }
                }

            }
            if (HighScoreTracker.device != null && HighScoreTracker.device.IsConnected == true)
            {
                showRetry = false;
            }
            if (backToRetry == true || (HighScoreTracker.device != null && showRetry == false && HighScoreTracker.device.IsConnected == false))
            {
                if (Guide.IsVisible == false)
                {
                    try
                    {
                        StorageDevice.BeginShowSelector(this.RetryDevice, "Select Storage Device");
                        backToRetry = false;
                        showRetry = true;
                    }
                    catch
                    {
                    }
                }
            }
            if (metaState == MetaState.SplashScreen && deviceSelected==true)
            {
                HighScoreData data = HighScoreTracker.LoadHighScores();
                gameSettings = new GameSettings();
                gameSettings.displayControls = data.displayHelp;
                gameSettings.musicEnabled = data.musicEnabled;
                gameSettings.soundEffectsEnabled = data.soundEffectsEnabled;
                gameSettings.fullScreen = data.fullScreen;
                gameSettings.wideScreen = data.wideScreen;
                gameSettings.keyboardControls = data.keyboardControls;
                currentSettings = new Settings();
                p1engine = new Engine(-1);
                mainMenu = new MainMenu();
                pauseMenu = new PauseMenu();
                summaryMenu = new SummaryMenu(false);
                gameOverMenu = new GameOverMenu();
                selectMenu = new LevelSelectMenu();
                tutorialLauncher = new TutorialLauncher();
                settingsMenu = new Menu(MenuClass.SettingsMenu);

                currentSettings = new Settings();
                p1engine = new Engine(-1);
                mainMenu = new MainMenu();
                pauseMenu = new PauseMenu();
                summaryMenu = new SummaryMenu(false);
                gameOverMenu = new GameOverMenu();
                selectMenu = new LevelSelectMenu();
                tutorialLauncher = new TutorialLauncher();
                settingsMenu = new Menu(MenuClass.SettingsMenu);

                if(Guide.IsTrialMode)
                    mainMenu.AddMenuItem(MenuResult.GoToTutorial, "Tutorial", "Learn to play Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.GoToTimeAttack, "Emergency Room", "Score as many points as you can within the \ntime limit.");
                mainMenu.AddMenuItem(MenuResult.GoToMoveChallenge, "Operation", "Score as many points as you can with a \nlimited number of moves.");
                mainMenu.AddMenuItem(MenuResult.GoToPuzzle, "Challenge", "Solve a series of unique challenges.");
                if(Guide.IsTrialMode==false)
                    mainMenu.AddMenuItem(MenuResult.GoToTutorial, "Tutorial", "Learn to play Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.BuyFullGame, "Unlock Full Game", "Purchase the full version of Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.GoToJellyfishCity, "Jellyfish Parade", "Check in on your former patients!");
                mainMenu.AddMenuItem(MenuResult.GoToSettings, "Settings", "Change settings for Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.Quit, "Quit", "Quit Jellyfish, MD??");
                gameOverMenu.AddMenuItem(MenuResult.StartTimeAttack, "Replay");
                gameOverMenu.AddMenuItem(MenuResult.GoToMainMenu, "Main Menu");
                gameOverMenu.AddMenuItem(MenuResult.GoToLevelSelect, "Level Select");
                settingsMenu.AddMenuItem(MenuResult.GoToMainMenu, "Return to Menu");
                settingsMenu.AddMenuItem(MenuType.SoundToggle, "Sound Effects");
                settingsMenu.AddMenuItem(MenuType.MusicToggle, "Music");
                settingsMenu.AddMenuItem(MenuType.HelpToggle, "Help Overlay");

                #if WINDOWS
                    settingsMenu.AddMenuItem(MenuType.FullScreenToggle, "Full Screen");
                    settingsMenu.AddMenuItem(MenuType.WideScreenToggle, "Wide Screen");
                #endif
                UpdateResolution();

                metaState = MetaState.MainMenu;
            }
            if (metaState == MetaState.GamePlay && IsActive==true)
            {
                GameStopCause cause = p1engine.Update(gameTime);
                if (cause == GameStopCause.PAUSE)
                {
                    pauseMenu = new PauseMenu();
                    metaState = MetaState.Paused;
                }
                if (cause == GameStopCause.END)
                {
                    gameOverMenu.score = p1engine.currentScore;
                    gameOverMenu.level = currentSettings.level;
                    gameOverMenu.state = GameOverMenuState.SCORECHECK;
                    summaryMenu = new SummaryMenu(true);
                    if(currentSettings.mode==GameMode.MoveChallenge)
                        summaryMenu.text = "Looks like you're out of moves, Doctor! \nLet's see how you did...";
                    if(currentSettings.mode == GameMode.TimeAttack)
                        summaryMenu.text = "Time's up, Doctor! Let's see \nhow you did...";
                    MusicControl.PlayMenuMusic();
                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.WIN)
                {
                    gameOverMenu.score = Engine.clock.timeElapsed;
                    gameOverMenu.level = currentSettings.level;
                    gameOverMenu.state = GameOverMenuState.SCORECHECK;
                    summaryMenu = new SummaryMenu(true);
                    summaryMenu.text = "Way to go, Doctor! You did it!";
                    metaState = MetaState.Summary;
                    MusicControl.PlayMenuMusic();
                }
                if (cause == GameStopCause.TUTORIAL_TEXT)
                {
                    TutorialStage.phase = TutorialPhase.Intro;
                    summaryMenu = new SummaryMenu(true);
                    summaryMenu.text = TutorialStage.IntroText();
                    if (summaryMenu.text == null)
                        metaState = MetaState.GamePlay;
                    summaryMenu.state = SummaryMenuState.READY;

                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.TUTORIAL_PASS)
                {
                    TutorialStage.phase = TutorialPhase.Pass;
                    String text = TutorialStage.SuccessText();
                    summaryMenu = new SummaryMenu(true);
                    summaryMenu.text = text;
                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.TUTORIAL_FAIL)
                {
                    TutorialStage.phase = TutorialPhase.Fail;
                    String text = TutorialStage.FailureText();
                    summaryMenu = new SummaryMenu(false);
                    summaryMenu.text = text;
                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.LOSE_STUCK)
                {
                    summaryMenu = new SummaryMenu(false);
                    summaryMenu.text = "Oh no! Looks like you're stuck! Try to be more \ncareful next time!";
                    gameOverMenu.state = GameOverMenuState.READY;
                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.LOSE_ERROR)
                {
                    summaryMenu = new SummaryMenu(false);
                    summaryMenu.text = "Oh no! You burst a " + currentSettings.dangerColorDisplay + " bubble! Try to be more \ncareful next time!";
                    gameOverMenu.state = GameOverMenuState.READY;
                    metaState = MetaState.Summary;
                }
            }
            else if (metaState == MetaState.Paused)
            {
                MenuResult result = pauseMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    TutorialStage.phase = TutorialPhase.None;
                    metaState = MetaState.MainMenu;
                }
                if (result == MenuResult.ResumeGame)
                {
                    summaryMenu.state = SummaryMenuState.NURSEIN;
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToLevelSelect)
                {
                    MusicControl.PlayMenuMusic();
                    if (currentSettings.mode == GameMode.TimeAttack)
                        metaState = MetaState.Settings_TimeAttack;
                    if (currentSettings.mode == GameMode.Puzzle)
                        metaState = MetaState.Settings_Puzzle;
                    if (currentSettings.mode == GameMode.MoveChallenge)
                        metaState = MetaState.Settings_Move;
                }
                if (result == MenuResult.Replay)
                {
                    p1engine = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
            }
            else if (metaState == MetaState.Summary)
            {
                if (Game.currentSettings.mode==GameMode.Puzzle && gameOverMenu.state != GameOverMenuState.SCORECHECK)
                {
                    Engine.clock.Update(gameTime);
                }
                MenuResult result = summaryMenu.Update(gameTime);
                if (TutorialStage.phase != TutorialPhase.None && TutorialStage.introIndex-1 == TutorialStage.controlLessonIndex)
                    p1engine.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    TutorialStage.phase = TutorialPhase.None;
                    metaState = MetaState.MainMenu;
                }
                if (result == MenuResult.Replay)
                {
                    if (TutorialStage.phase == TutorialPhase.Fail)
                    {
                        p1engine.LoadTutorial(TutorialStage.lessonIndex);
                        TutorialStage.phase = TutorialPhase.Intro;
                        TutorialStage.failureIndex = 0;
                        TutorialStage.introIndex = 0;
                        TutorialStage.successIndex = 0;
                        p1engine.firstResume = true;
                        metaState = MetaState.GamePlay;
                    }
                    else if (TutorialStage.phase == TutorialPhase.Pass)
                    {
                        p1engine.LoadTutorial(TutorialStage.lessonIndex);
                        TutorialStage.phase = TutorialPhase.Intro;
                        TutorialStage.failureIndex = 0;
                        TutorialStage.introIndex = 0;
                        TutorialStage.successIndex = 0;
                        p1engine.firstResume = false;
                        metaState = MetaState.GamePlay;
                    }
                    else
                    {
                        p1engine = new Engine(-1);
                        MusicControl.PlayGameMusic();
                        metaState = MetaState.GamePlay;
                    }
                }
                if (result == MenuResult.Undo)
                {
                    p1engine.Back();
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToResults)
                {
                    if (currentSettings.mode == GameMode.Tutorial)
                    {
                        if (TutorialStage.phase == TutorialPhase.Intro)
                        {
                            metaState = MetaState.GamePlay;
                        }
                        else if (TutorialStage.phase == TutorialPhase.Pass)
                        {
                            TutorialStage.lessonIndex++;
                            if (TutorialStage.lessonIndex == TutorialStage.maxLesson)
                            {
                                TutorialStage.phase = TutorialPhase.None;
                                summaryMenu = new SummaryMenu(false);
                                metaState = MetaState.MainMenu;
                            }
                            else
                            {
                                //p1engine = new Engine(TutorialStage.lessonIndex);
                                p1engine.LoadTutorial(TutorialStage.lessonIndex);
                                p1engine.firstResume = true;
                                //p1engine.gameState = State.VANISH;
                                TutorialStage.phase = TutorialPhase.Intro;
                                metaState = MetaState.GamePlay;
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        metaState = MetaState.GameOver_TimeAttack;
                    }
                }
                if (result == MenuResult.GoToLevelSelect)
                {
                    MusicControl.PlayMenuMusic();
                    if (currentSettings.mode == GameMode.TimeAttack)
                        metaState = MetaState.Settings_TimeAttack;
                    if (currentSettings.mode == GameMode.Puzzle)
                        metaState = MetaState.Settings_Puzzle;
                    if (currentSettings.mode == GameMode.MoveChallenge)
                        metaState = MetaState.Settings_Move;
                }
            }
            else if (metaState == MetaState.Settings_TimeAttack || metaState == MetaState.Settings_Puzzle || metaState == MetaState.Settings_Move)
            {
                MenuResult result = selectMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    System.Threading.Thread.Sleep(100);
                    metaState = MetaState.MainMenu;
                }
                if (result == MenuResult.StartTimeAttack)
                {
                    currentSettings = selectMenu.GetCurrentSettings();
                    currentSettings.level = selectMenu.currentLevel;
                    p1engine = new Engine(-1);
                    MusicControl.PlayGameMusic();
                    metaState = MetaState.GamePlay;
                }
            }
            else if (metaState == MetaState.GameOver_TimeAttack)
            {
                if (Engine.mode == ControlMode.AUTOMATED)
                {
                    p1engine = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
                else
                {
                    MenuResult result = gameOverMenu.Update(gameTime);
                    if (result == MenuResult.GoToMainMenu)
                    {
                        metaState = MetaState.MainMenu;
                        System.Threading.Thread.Sleep(100);
                    }
                    if (result == MenuResult.GoToLevelSelect)
                    {
                        selectMenu = new LevelSelectMenu();
                        selectMenu.state = LevelSelectMenu.SelectMenuState.LOAD;

                        if (currentSettings.mode == GameMode.MoveChallenge)
                        {
                            metaState = MetaState.Settings_Move;
                            selectMenu.cooldown = 250;
                            selectMenu.currentLevel = gameSettings.moveChallengeViewLevel;
                            selectMenu.levelList = SettingsLoader.LoadMoveCountLevels();
                            currentSettings.mode = GameMode.MoveChallenge;
                        }
                        if (currentSettings.mode == GameMode.TimeAttack)
                        {
                            metaState = MetaState.Settings_TimeAttack;
                            selectMenu.cooldown = 250;
                            selectMenu.currentLevel = gameSettings.timeAttackViewLevel;
                            selectMenu.levelList = SettingsLoader.LoadTimeAttackLevels();
                            currentSettings.mode = GameMode.TimeAttack;
                        }
                        if (currentSettings.mode == GameMode.Puzzle)
                        {
                            metaState = MetaState.Settings_Puzzle;
                            selectMenu.cooldown = 250;
                            selectMenu.levelList = SettingsLoader.LoadPuzzleLevels();
                            selectMenu.currentLevel = gameSettings.puzzleViewLevel;
                            currentSettings.mode = GameMode.Puzzle;
                        }
                    }
                    if (result == MenuResult.StartTimeAttack)
                    {
                        p1engine = new Engine(-1);
                        MusicControl.PlayGameMusic();
                        metaState = MetaState.GamePlay;
                    }
                }
            }
            else if (metaState == MetaState.Settings)
            {
                MenuResult result = settingsMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    metaState = MetaState.MainMenu;
                }
            }
            else if (metaState == MetaState.JellyfishCity)
            {
                MenuResult result = jellyCity.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    metaState = MetaState.MainMenu;
                }
            }
            else if (metaState == MetaState.Tutorial)
            {
                MenuResult result = tutorialLauncher.Update(gameTime);
                if (result == MenuResult.StartTutorial)
                {
                    summaryMenu.state = SummaryMenuState.READY;
                    currentSettings = SettingsLoader.Tutorial();
                    p1engine = new Engine(0);
                    p1engine.firstResume = true;
                    metaState = MetaState.GamePlay;

                }
            }
            else if (metaState == MetaState.MainMenu)
            {
                MenuResult result = mainMenu.Update(gameTime);
                if (result == MenuResult.ReturnToSplashScreen)
                {
                    HighScoreData data = HighScoreTracker.LoadHighScores();
                    data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                    data.musicEnabled = gameSettings.musicEnabled;
                    data.displayHelp = gameSettings.displayControls;
                    data.fullScreen = gameSettings.fullScreen;
                    data.wideScreen = gameSettings.wideScreen;
                    data.keyboardControls = gameSettings.keyboardControls;
                    HighScoreTracker.SaveHighScores(data);

                    deviceSelected = false;
                    HighScoreTracker.device = null;
                    if (HighScoreTracker.container != null)
                        HighScoreTracker.container.Dispose();
                    HighScoreTracker.container = null;
                    HighScoreTracker.cachedData = null;
                    splashScreen = new SplashScreen();
                    metaState = MetaState.SplashScreen;
                }
                if (result == MenuResult.BuyFullGame)
                {
                    try { Guide.ShowMarketplace(Game.playerIndex); }
                    catch (GamerPrivilegeException)
                    {
                        Guide.BeginShowMessageBox("Oops!",
                            "The current controller is either not signed in or is unable to purchase games on XBox Live.",
                            new string[] { "OK" },
                            0, MessageBoxIcon.None, null, null);
                    }
                    catch
                    {
                    }

                }
                if (result == MenuResult.GoToSettings)
                {
                    metaState = MetaState.Settings;
                }
                if (result == MenuResult.GoToTimeAttack)
                {
                    metaState = MetaState.Settings_TimeAttack;
                    selectMenu = new LevelSelectMenu();
                    selectMenu.levelList = SettingsLoader.LoadTimeAttackLevels();
                    selectMenu.currentLevel = gameSettings.timeAttackViewLevel;
                    selectMenu.state = LevelSelectMenu.SelectMenuState.LOAD;
                    currentSettings.mode = GameMode.TimeAttack;
                    System.Threading.Thread.Sleep(100);
                }
                if (result == MenuResult.GoToPuzzle)
                {
                    metaState = MetaState.Settings_Puzzle;
                    selectMenu = new LevelSelectMenu();
                    selectMenu.levelList = SettingsLoader.LoadPuzzleLevels();
                    selectMenu.state = LevelSelectMenu.SelectMenuState.LOAD;
                    selectMenu.currentLevel = gameSettings.puzzleViewLevel;
                    currentSettings.mode = GameMode.Puzzle;
                    System.Threading.Thread.Sleep(100);
                }
                if (result == MenuResult.GoToJellyfishCity)
                {
                    metaState = MetaState.JellyfishCity;
                    jellyCity = new JellyfishCity();
                }
                if (result == MenuResult.GoToTutorial)
                {
                    metaState = MetaState.Tutorial;
                    TutorialStage.phase = TutorialPhase.Intro;
                    TutorialStage.lessonIndex = 0;
                    TutorialStage.loaded = false;
                    tutorialLauncher = new TutorialLauncher();
                }
                if (result == MenuResult.GoToMoveChallenge)
                {
                    metaState = MetaState.Settings_Move;
                    selectMenu = new LevelSelectMenu();
                    selectMenu.levelList = SettingsLoader.LoadMoveCountLevels();
                    selectMenu.state = LevelSelectMenu.SelectMenuState.LOAD;
                    selectMenu.currentLevel = gameSettings.moveChallengeViewLevel;
                    currentSettings.mode = GameMode.TimeAttack;
                }
                if (result == MenuResult.StartCollect)
                {
                    p1engine = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.StartPuzzle)
                {
                    p1engine = new Engine(-1);

                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToSurvival)
                {
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.Quit)
                {
                    HighScoreData data = HighScoreTracker.LoadHighScores();
                    data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                    data.musicEnabled = gameSettings.musicEnabled;
                    data.displayHelp = gameSettings.displayControls;
                    data.fullScreen = gameSettings.fullScreen;
                    data.wideScreen = gameSettings.wideScreen;
                    data.keyboardControls = gameSettings.keyboardControls;
                    HighScoreTracker.SaveHighScores(data);
                    Logger.CloseLogger();
                    this.Exit();
                }

            }

            base.Update(gameTime);
        }
Exemple #2
0
        protected override void Update(GameTime gameTime)
        {
            if (metaState == MetaState.InitialLoad)
            {
                splashScreen = new SplashScreen();
                metaState    = MetaState.SplashScreen;
            }

            // Controls
            //if (GamePad.GetState(Game.playerIndex).Buttons.Back == ButtonState.Pressed)
            //  this.Exit();
            if (HighScoreTracker.device != null && Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                HighScoreData data = HighScoreTracker.LoadHighScores();
                data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                data.musicEnabled        = gameSettings.musicEnabled;
                data.displayHelp         = gameSettings.displayControls;
                data.wideScreen          = gameSettings.wideScreen;
                data.keyboardControls    = gameSettings.keyboardControls;
                HighScoreTracker.SaveHighScores(data);
                Logger.CloseLogger();
                this.Exit();
            }
            if (metaState == MetaState.SplashScreen)
            {
                if (MenuResult.GoToMainMenu == splashScreen.Update(gameTime))
                {
                    base.Initialize();
                    try
                    {
                        if (Guide.IsVisible == true)
                        {
                            splashScreen.stillActive = true;
                        }
                        else
                        {
                            StorageDevice.BeginShowSelector(this.GetDevice, "Select Storage Device");
                        }
                    }
                    catch
                    {
                        splashScreen.stillActive = true;
                    }
                }
            }
            if (HighScoreTracker.device != null && HighScoreTracker.device.IsConnected == true)
            {
                showRetry = false;
            }
            if (backToRetry == true || (HighScoreTracker.device != null && showRetry == false && HighScoreTracker.device.IsConnected == false))
            {
                if (Guide.IsVisible == false)
                {
                    try
                    {
                        StorageDevice.BeginShowSelector(this.RetryDevice, "Select Storage Device");
                        backToRetry = false;
                        showRetry   = true;
                    }
                    catch
                    {
                    }
                }
            }
            if (metaState == MetaState.SplashScreen && deviceSelected == true)
            {
                HighScoreData data = HighScoreTracker.LoadHighScores();
                gameSettings = new GameSettings();
                gameSettings.displayControls     = data.displayHelp;
                gameSettings.musicEnabled        = data.musicEnabled;
                gameSettings.soundEffectsEnabled = data.soundEffectsEnabled;
                gameSettings.fullScreen          = data.fullScreen;
                gameSettings.wideScreen          = data.wideScreen;
                gameSettings.keyboardControls    = data.keyboardControls;
                currentSettings  = new Settings();
                p1engine         = new Engine(-1);
                mainMenu         = new MainMenu();
                pauseMenu        = new PauseMenu();
                summaryMenu      = new SummaryMenu(false);
                gameOverMenu     = new GameOverMenu();
                selectMenu       = new LevelSelectMenu();
                tutorialLauncher = new TutorialLauncher();
                settingsMenu     = new Menu(MenuClass.SettingsMenu);

                currentSettings  = new Settings();
                p1engine         = new Engine(-1);
                mainMenu         = new MainMenu();
                pauseMenu        = new PauseMenu();
                summaryMenu      = new SummaryMenu(false);
                gameOverMenu     = new GameOverMenu();
                selectMenu       = new LevelSelectMenu();
                tutorialLauncher = new TutorialLauncher();
                settingsMenu     = new Menu(MenuClass.SettingsMenu);

                if (Guide.IsTrialMode)
                {
                    mainMenu.AddMenuItem(MenuResult.GoToTutorial, "Tutorial", "Learn to play Jellyfish, MD");
                }
                mainMenu.AddMenuItem(MenuResult.GoToTimeAttack, "Emergency Room", "Score as many points as you can within the \ntime limit.");
                mainMenu.AddMenuItem(MenuResult.GoToMoveChallenge, "Operation", "Score as many points as you can with a \nlimited number of moves.");
                mainMenu.AddMenuItem(MenuResult.GoToPuzzle, "Challenge", "Solve a series of unique challenges.");
                if (Guide.IsTrialMode == false)
                {
                    mainMenu.AddMenuItem(MenuResult.GoToTutorial, "Tutorial", "Learn to play Jellyfish, MD");
                }
                mainMenu.AddMenuItem(MenuResult.BuyFullGame, "Unlock Full Game", "Purchase the full version of Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.GoToJellyfishCity, "Jellyfish Parade", "Check in on your former patients!");
                mainMenu.AddMenuItem(MenuResult.GoToSettings, "Settings", "Change settings for Jellyfish, MD");
                mainMenu.AddMenuItem(MenuResult.Quit, "Quit", "Quit Jellyfish, MD??");
                gameOverMenu.AddMenuItem(MenuResult.StartTimeAttack, "Replay");
                gameOverMenu.AddMenuItem(MenuResult.GoToMainMenu, "Main Menu");
                gameOverMenu.AddMenuItem(MenuResult.GoToLevelSelect, "Level Select");
                settingsMenu.AddMenuItem(MenuResult.GoToMainMenu, "Return to Menu");
                settingsMenu.AddMenuItem(MenuType.SoundToggle, "Sound Effects");
                settingsMenu.AddMenuItem(MenuType.MusicToggle, "Music");
                settingsMenu.AddMenuItem(MenuType.HelpToggle, "Help Overlay");

                #if WINDOWS
                settingsMenu.AddMenuItem(MenuType.FullScreenToggle, "Full Screen");
                settingsMenu.AddMenuItem(MenuType.WideScreenToggle, "Wide Screen");
                #endif
                UpdateResolution();

                metaState = MetaState.MainMenu;
            }
            if (metaState == MetaState.GamePlay && IsActive == true)
            {
                GameStopCause cause = p1engine.Update(gameTime);
                if (cause == GameStopCause.PAUSE)
                {
                    pauseMenu = new PauseMenu();
                    metaState = MetaState.Paused;
                }
                if (cause == GameStopCause.END)
                {
                    gameOverMenu.score = p1engine.currentScore;
                    gameOverMenu.level = currentSettings.level;
                    gameOverMenu.state = GameOverMenuState.SCORECHECK;
                    summaryMenu        = new SummaryMenu(true);
                    if (currentSettings.mode == GameMode.MoveChallenge)
                    {
                        summaryMenu.text = "Looks like you're out of moves, Doctor! \nLet's see how you did...";
                    }
                    if (currentSettings.mode == GameMode.TimeAttack)
                    {
                        summaryMenu.text = "Time's up, Doctor! Let's see \nhow you did...";
                    }
                    MusicControl.PlayMenuMusic();
                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.WIN)
                {
                    gameOverMenu.score = Engine.clock.timeElapsed;
                    gameOverMenu.level = currentSettings.level;
                    gameOverMenu.state = GameOverMenuState.SCORECHECK;
                    summaryMenu        = new SummaryMenu(true);
                    summaryMenu.text   = "Way to go, Doctor! You did it!";
                    metaState          = MetaState.Summary;
                    MusicControl.PlayMenuMusic();
                }
                if (cause == GameStopCause.TUTORIAL_TEXT)
                {
                    TutorialStage.phase = TutorialPhase.Intro;
                    summaryMenu         = new SummaryMenu(true);
                    summaryMenu.text    = TutorialStage.IntroText();
                    if (summaryMenu.text == null)
                    {
                        metaState = MetaState.GamePlay;
                    }
                    summaryMenu.state = SummaryMenuState.READY;

                    metaState = MetaState.Summary;
                }
                if (cause == GameStopCause.TUTORIAL_PASS)
                {
                    TutorialStage.phase = TutorialPhase.Pass;
                    String text = TutorialStage.SuccessText();
                    summaryMenu      = new SummaryMenu(true);
                    summaryMenu.text = text;
                    metaState        = MetaState.Summary;
                }
                if (cause == GameStopCause.TUTORIAL_FAIL)
                {
                    TutorialStage.phase = TutorialPhase.Fail;
                    String text = TutorialStage.FailureText();
                    summaryMenu      = new SummaryMenu(false);
                    summaryMenu.text = text;
                    metaState        = MetaState.Summary;
                }
                if (cause == GameStopCause.LOSE_STUCK)
                {
                    summaryMenu        = new SummaryMenu(false);
                    summaryMenu.text   = "Oh no! Looks like you're stuck! Try to be more \ncareful next time!";
                    gameOverMenu.state = GameOverMenuState.READY;
                    metaState          = MetaState.Summary;
                }
                if (cause == GameStopCause.LOSE_ERROR)
                {
                    summaryMenu        = new SummaryMenu(false);
                    summaryMenu.text   = "Oh no! You burst a " + currentSettings.dangerColorDisplay + " bubble! Try to be more \ncareful next time!";
                    gameOverMenu.state = GameOverMenuState.READY;
                    metaState          = MetaState.Summary;
                }
            }
            else if (metaState == MetaState.Paused)
            {
                MenuResult result = pauseMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    TutorialStage.phase = TutorialPhase.None;
                    metaState           = MetaState.MainMenu;
                }
                if (result == MenuResult.ResumeGame)
                {
                    summaryMenu.state = SummaryMenuState.NURSEIN;
                    metaState         = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToLevelSelect)
                {
                    MusicControl.PlayMenuMusic();
                    if (currentSettings.mode == GameMode.TimeAttack)
                    {
                        metaState = MetaState.Settings_TimeAttack;
                    }
                    if (currentSettings.mode == GameMode.Puzzle)
                    {
                        metaState = MetaState.Settings_Puzzle;
                    }
                    if (currentSettings.mode == GameMode.MoveChallenge)
                    {
                        metaState = MetaState.Settings_Move;
                    }
                }
                if (result == MenuResult.Replay)
                {
                    p1engine  = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
            }
            else if (metaState == MetaState.Summary)
            {
                if (Game.currentSettings.mode == GameMode.Puzzle && gameOverMenu.state != GameOverMenuState.SCORECHECK)
                {
                    Engine.clock.Update(gameTime);
                }
                MenuResult result = summaryMenu.Update(gameTime);
                if (TutorialStage.phase != TutorialPhase.None && TutorialStage.introIndex - 1 == TutorialStage.controlLessonIndex)
                {
                    p1engine.Update(gameTime);
                }
                if (result == MenuResult.GoToMainMenu)
                {
                    TutorialStage.phase = TutorialPhase.None;
                    metaState           = MetaState.MainMenu;
                }
                if (result == MenuResult.Replay)
                {
                    if (TutorialStage.phase == TutorialPhase.Fail)
                    {
                        p1engine.LoadTutorial(TutorialStage.lessonIndex);
                        TutorialStage.phase        = TutorialPhase.Intro;
                        TutorialStage.failureIndex = 0;
                        TutorialStage.introIndex   = 0;
                        TutorialStage.successIndex = 0;
                        p1engine.firstResume       = true;
                        metaState = MetaState.GamePlay;
                    }
                    else if (TutorialStage.phase == TutorialPhase.Pass)
                    {
                        p1engine.LoadTutorial(TutorialStage.lessonIndex);
                        TutorialStage.phase        = TutorialPhase.Intro;
                        TutorialStage.failureIndex = 0;
                        TutorialStage.introIndex   = 0;
                        TutorialStage.successIndex = 0;
                        p1engine.firstResume       = false;
                        metaState = MetaState.GamePlay;
                    }
                    else
                    {
                        p1engine = new Engine(-1);
                        MusicControl.PlayGameMusic();
                        metaState = MetaState.GamePlay;
                    }
                }
                if (result == MenuResult.Undo)
                {
                    p1engine.Back();
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToResults)
                {
                    if (currentSettings.mode == GameMode.Tutorial)
                    {
                        if (TutorialStage.phase == TutorialPhase.Intro)
                        {
                            metaState = MetaState.GamePlay;
                        }
                        else if (TutorialStage.phase == TutorialPhase.Pass)
                        {
                            TutorialStage.lessonIndex++;
                            if (TutorialStage.lessonIndex == TutorialStage.maxLesson)
                            {
                                TutorialStage.phase = TutorialPhase.None;
                                summaryMenu         = new SummaryMenu(false);
                                metaState           = MetaState.MainMenu;
                            }
                            else
                            {
                                //p1engine = new Engine(TutorialStage.lessonIndex);
                                p1engine.LoadTutorial(TutorialStage.lessonIndex);
                                p1engine.firstResume = true;
                                //p1engine.gameState = State.VANISH;
                                TutorialStage.phase = TutorialPhase.Intro;
                                metaState           = MetaState.GamePlay;
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        metaState = MetaState.GameOver_TimeAttack;
                    }
                }
                if (result == MenuResult.GoToLevelSelect)
                {
                    MusicControl.PlayMenuMusic();
                    if (currentSettings.mode == GameMode.TimeAttack)
                    {
                        metaState = MetaState.Settings_TimeAttack;
                    }
                    if (currentSettings.mode == GameMode.Puzzle)
                    {
                        metaState = MetaState.Settings_Puzzle;
                    }
                    if (currentSettings.mode == GameMode.MoveChallenge)
                    {
                        metaState = MetaState.Settings_Move;
                    }
                }
            }
            else if (metaState == MetaState.Settings_TimeAttack || metaState == MetaState.Settings_Puzzle || metaState == MetaState.Settings_Move)
            {
                MenuResult result = selectMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    System.Threading.Thread.Sleep(100);
                    metaState = MetaState.MainMenu;
                }
                if (result == MenuResult.StartTimeAttack)
                {
                    currentSettings       = selectMenu.GetCurrentSettings();
                    currentSettings.level = selectMenu.currentLevel;
                    p1engine = new Engine(-1);
                    MusicControl.PlayGameMusic();
                    metaState = MetaState.GamePlay;
                }
            }
            else if (metaState == MetaState.GameOver_TimeAttack)
            {
                if (Engine.mode == ControlMode.AUTOMATED)
                {
                    p1engine  = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
                else
                {
                    MenuResult result = gameOverMenu.Update(gameTime);
                    if (result == MenuResult.GoToMainMenu)
                    {
                        metaState = MetaState.MainMenu;
                        System.Threading.Thread.Sleep(100);
                    }
                    if (result == MenuResult.GoToLevelSelect)
                    {
                        selectMenu       = new LevelSelectMenu();
                        selectMenu.state = LevelSelectMenu.SelectMenuState.LOAD;

                        if (currentSettings.mode == GameMode.MoveChallenge)
                        {
                            metaState               = MetaState.Settings_Move;
                            selectMenu.cooldown     = 250;
                            selectMenu.currentLevel = gameSettings.moveChallengeViewLevel;
                            selectMenu.levelList    = SettingsLoader.LoadMoveCountLevels();
                            currentSettings.mode    = GameMode.MoveChallenge;
                        }
                        if (currentSettings.mode == GameMode.TimeAttack)
                        {
                            metaState               = MetaState.Settings_TimeAttack;
                            selectMenu.cooldown     = 250;
                            selectMenu.currentLevel = gameSettings.timeAttackViewLevel;
                            selectMenu.levelList    = SettingsLoader.LoadTimeAttackLevels();
                            currentSettings.mode    = GameMode.TimeAttack;
                        }
                        if (currentSettings.mode == GameMode.Puzzle)
                        {
                            metaState               = MetaState.Settings_Puzzle;
                            selectMenu.cooldown     = 250;
                            selectMenu.levelList    = SettingsLoader.LoadPuzzleLevels();
                            selectMenu.currentLevel = gameSettings.puzzleViewLevel;
                            currentSettings.mode    = GameMode.Puzzle;
                        }
                    }
                    if (result == MenuResult.StartTimeAttack)
                    {
                        p1engine = new Engine(-1);
                        MusicControl.PlayGameMusic();
                        metaState = MetaState.GamePlay;
                    }
                }
            }
            else if (metaState == MetaState.Settings)
            {
                MenuResult result = settingsMenu.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    metaState = MetaState.MainMenu;
                }
            }
            else if (metaState == MetaState.JellyfishCity)
            {
                MenuResult result = jellyCity.Update(gameTime);
                if (result == MenuResult.GoToMainMenu)
                {
                    metaState = MetaState.MainMenu;
                }
            }
            else if (metaState == MetaState.Tutorial)
            {
                MenuResult result = tutorialLauncher.Update(gameTime);
                if (result == MenuResult.StartTutorial)
                {
                    summaryMenu.state    = SummaryMenuState.READY;
                    currentSettings      = SettingsLoader.Tutorial();
                    p1engine             = new Engine(0);
                    p1engine.firstResume = true;
                    metaState            = MetaState.GamePlay;
                }
            }
            else if (metaState == MetaState.MainMenu)
            {
                MenuResult result = mainMenu.Update(gameTime);
                if (result == MenuResult.ReturnToSplashScreen)
                {
                    HighScoreData data = HighScoreTracker.LoadHighScores();
                    data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                    data.musicEnabled        = gameSettings.musicEnabled;
                    data.displayHelp         = gameSettings.displayControls;
                    data.fullScreen          = gameSettings.fullScreen;
                    data.wideScreen          = gameSettings.wideScreen;
                    data.keyboardControls    = gameSettings.keyboardControls;
                    HighScoreTracker.SaveHighScores(data);

                    deviceSelected          = false;
                    HighScoreTracker.device = null;
                    if (HighScoreTracker.container != null)
                    {
                        HighScoreTracker.container.Dispose();
                    }
                    HighScoreTracker.container  = null;
                    HighScoreTracker.cachedData = null;
                    splashScreen = new SplashScreen();
                    metaState    = MetaState.SplashScreen;
                }
                if (result == MenuResult.BuyFullGame)
                {
                    try { Guide.ShowMarketplace(Game.playerIndex); }
                    catch (GamerPrivilegeException)
                    {
                        Guide.BeginShowMessageBox("Oops!",
                                                  "The current controller is either not signed in or is unable to purchase games on XBox Live.",
                                                  new string[] { "OK" },
                                                  0, MessageBoxIcon.None, null, null);
                    }
                    catch
                    {
                    }
                }
                if (result == MenuResult.GoToSettings)
                {
                    metaState = MetaState.Settings;
                }
                if (result == MenuResult.GoToTimeAttack)
                {
                    metaState               = MetaState.Settings_TimeAttack;
                    selectMenu              = new LevelSelectMenu();
                    selectMenu.levelList    = SettingsLoader.LoadTimeAttackLevels();
                    selectMenu.currentLevel = gameSettings.timeAttackViewLevel;
                    selectMenu.state        = LevelSelectMenu.SelectMenuState.LOAD;
                    currentSettings.mode    = GameMode.TimeAttack;
                    System.Threading.Thread.Sleep(100);
                }
                if (result == MenuResult.GoToPuzzle)
                {
                    metaState               = MetaState.Settings_Puzzle;
                    selectMenu              = new LevelSelectMenu();
                    selectMenu.levelList    = SettingsLoader.LoadPuzzleLevels();
                    selectMenu.state        = LevelSelectMenu.SelectMenuState.LOAD;
                    selectMenu.currentLevel = gameSettings.puzzleViewLevel;
                    currentSettings.mode    = GameMode.Puzzle;
                    System.Threading.Thread.Sleep(100);
                }
                if (result == MenuResult.GoToJellyfishCity)
                {
                    metaState = MetaState.JellyfishCity;
                    jellyCity = new JellyfishCity();
                }
                if (result == MenuResult.GoToTutorial)
                {
                    metaState                 = MetaState.Tutorial;
                    TutorialStage.phase       = TutorialPhase.Intro;
                    TutorialStage.lessonIndex = 0;
                    TutorialStage.loaded      = false;
                    tutorialLauncher          = new TutorialLauncher();
                }
                if (result == MenuResult.GoToMoveChallenge)
                {
                    metaState               = MetaState.Settings_Move;
                    selectMenu              = new LevelSelectMenu();
                    selectMenu.levelList    = SettingsLoader.LoadMoveCountLevels();
                    selectMenu.state        = LevelSelectMenu.SelectMenuState.LOAD;
                    selectMenu.currentLevel = gameSettings.moveChallengeViewLevel;
                    currentSettings.mode    = GameMode.TimeAttack;
                }
                if (result == MenuResult.StartCollect)
                {
                    p1engine  = new Engine(-1);
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.StartPuzzle)
                {
                    p1engine = new Engine(-1);

                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.GoToSurvival)
                {
                    metaState = MetaState.GamePlay;
                }
                if (result == MenuResult.Quit)
                {
                    HighScoreData data = HighScoreTracker.LoadHighScores();
                    data.soundEffectsEnabled = gameSettings.soundEffectsEnabled;
                    data.musicEnabled        = gameSettings.musicEnabled;
                    data.displayHelp         = gameSettings.displayControls;
                    data.fullScreen          = gameSettings.fullScreen;
                    data.wideScreen          = gameSettings.wideScreen;
                    data.keyboardControls    = gameSettings.keyboardControls;
                    HighScoreTracker.SaveHighScores(data);
                    Logger.CloseLogger();
                    this.Exit();
                }
            }

            base.Update(gameTime);
        }