public bool Tick()
        {
            switch (currentState)
            {
            case State.Title:
                title.Tick(inputDevice.CurrentTitleInput);
                if (title.CurrentState == TitleScene.State.StageSelect)
                {
                    currentState            = State.StageSelect;
                    stageSelect             = new StageSelectScene(numUnlockedStages, currentStageIndex);
                    stageSelect.AudioDevice = audioDevice;
                    return(true);
                }
                else if (title.CurrentState == TitleScene.State.GotoGame)
                {
                    title                   = null;
                    currentState            = State.Game;
                    currentStageIndex       = settings.StartStageIndex;
                    currentGame             = CreateGameScene(currentStageIndex);
                    currentGame.AudioDevice = audioDevice;
                    WriteLog("NewGame");
                    return(true);
                }
                else if (title.CurrentState == TitleScene.State.Exit)
                {
                    currentState = State.Exit;
                }
                break;

            case State.StageSelect:
                stageSelect.Tick(inputDevice.CurrentStageSelectInput);
                title.Tick(TitleInput.Empty);
                if (stageSelect.CurrentState == StageSelectScene.State.GotoGame)
                {
                    currentState            = State.Game;
                    currentStageIndex       = stageSelect.SelectedStage;
                    currentGame             = CreateGameScene(currentStageIndex);
                    currentGame.AudioDevice = audioDevice;
                    WriteLog("Continue (Stage " + (currentStageIndex + 1) + ")");
                    return(true);
                }
                else if (stageSelect.CurrentState == StageSelectScene.State.Exit)
                {
                    stageSelect  = null;
                    currentState = State.Title;
                    title.StageSelectExited();
                }
                break;

            case State.Game:
                if (inputDevice.DebugKey)
                {
                    currentGame.DebugMode = true;
                }
                currentGame.Tick(inputDevice.CurrentGameInput);
                if (currentGame.CurrentState == GameScene.State.Clear)
                {
                    if (currentStageIndex == NUM_STAGES - 1)
                    {
                        currentGame        = null;
                        currentState       = State.Ending;
                        ending             = new EndingScene();
                        ending.AudioDevice = audioDevice;
                        return(true);
                    }
                    currentStageIndex       = (currentStageIndex + 1) % NUM_STAGES;
                    currentGame             = CreateGameScene(currentStageIndex, currentGame.Player.State);
                    currentGame.AudioDevice = audioDevice;
                    if (numUnlockedStages < currentStageIndex + 1)
                    {
                        numUnlockedStages = currentStageIndex + 1;
                    }
                    return(true);
                }
                else if (currentGame.CurrentState == GameScene.State.Gameover)
                {
                    currentGame       = null;
                    currentState      = State.Title;
                    title             = new TitleScene(1, settings.ArcadeMode);
                    title.AudioDevice = audioDevice;
                    return(true);
                }
                break;

            case State.Ending:
                ending.Tick(inputDevice.CurrentEndingInput);
                if (ending.CurrentState == EndingScene.State.Exit)
                {
                    ending            = null;
                    currentState      = State.Title;
                    title             = new TitleScene(1, settings.ArcadeMode);
                    title.AudioDevice = audioDevice;
                    return(true);
                }
                break;
            }
            return(false);
        }
 public bool Tick()
 {
     switch (currentState)
     {
         case State.Title:
             title.Tick(inputDevice.CurrentTitleInput);
             if (title.CurrentState == TitleScene.State.StageSelect)
             {
                 currentState = State.StageSelect;
                 stageSelect = new StageSelectScene(numUnlockedStages, currentStageIndex);
                 stageSelect.AudioDevice = audioDevice;
                 return true;
             }
             else if (title.CurrentState == TitleScene.State.GotoGame)
             {
                 title = null;
                 currentState = State.Game;
                 currentStageIndex = settings.StartStageIndex;
                 currentGame = CreateGameScene(currentStageIndex);
                 currentGame.AudioDevice = audioDevice;
                 WriteLog("NewGame");
                 return true;
             }
             else if (title.CurrentState == TitleScene.State.Exit)
             {
                 currentState = State.Exit;
             }
             break;
         case State.StageSelect:
             stageSelect.Tick(inputDevice.CurrentStageSelectInput);
             title.Tick(TitleInput.Empty);
             if (stageSelect.CurrentState == StageSelectScene.State.GotoGame)
             {
                 currentState = State.Game;
                 currentStageIndex = stageSelect.SelectedStage;
                 currentGame = CreateGameScene(currentStageIndex);
                 currentGame.AudioDevice = audioDevice;
                 WriteLog("Continue (Stage " + (currentStageIndex + 1) + ")");
                 return true;
             }
             else if (stageSelect.CurrentState == StageSelectScene.State.Exit)
             {
                 stageSelect = null;
                 currentState = State.Title;
                 title.StageSelectExited();
             }
             break;
         case State.Game:
             if (inputDevice.DebugKey)
             {
                 currentGame.DebugMode = true;
             }
             currentGame.Tick(inputDevice.CurrentGameInput);
             if (currentGame.CurrentState == GameScene.State.Clear)
             {
                 if (currentStageIndex == NUM_STAGES - 1)
                 {
                     currentGame = null;
                     currentState = State.Ending;
                     ending = new EndingScene();
                     ending.AudioDevice = audioDevice;
                     return true;
                 }
                 currentStageIndex = (currentStageIndex + 1) % NUM_STAGES;
                 currentGame = CreateGameScene(currentStageIndex, currentGame.Player.State);
                 currentGame.AudioDevice = audioDevice;
                 if (numUnlockedStages < currentStageIndex + 1)
                 {
                     numUnlockedStages = currentStageIndex + 1;
                 }
                 return true;
             }
             else if (currentGame.CurrentState == GameScene.State.Gameover)
             {
                 currentGame = null;
                 currentState = State.Title;
                 title = new TitleScene(1, settings.ArcadeMode);
                 title.AudioDevice = audioDevice;
                 return true;
             }
             break;
         case State.Ending:
             ending.Tick(inputDevice.CurrentEndingInput);
             if (ending.CurrentState == EndingScene.State.Exit)
             {
                 ending = null;
                 currentState = State.Title;
                 title = new TitleScene(1, settings.ArcadeMode);
                 title.AudioDevice = audioDevice;
                 return true;
             }
             break;
     }
     return false;
 }