Beispiel #1
0
void EngineStage::activatePerformSingleTap(float x, float y)
{
    switch (stageState)
    {
        case STAGE_STATE_INIT:
            break;
        case STAGE_STATE_RUNNING:
        {
            std::string queryGUI = hud->queryButtons(Vector2(x, y));
            
            if (queryGUI == "powerup1")
                player->performPowerUp("TractorBeam");
            else if (queryGUI == "powerup2")
                player->performPowerUp("Shields");
            else if (queryGUI == "powerup3")
                player->performPowerUp("TimeWarp");
            else if (queryGUI == "toggle1")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    // Bad hack but
                    // Don't show 3-Back for multi-collection tasks of 1 or less.
                    if (player->getLevelRequestRow() > 0)
                        player->setToggleBack(0);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle2")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(1);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle3")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(2);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle4")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(3);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "pause")
            {
                setPause(true);
                stageState = STAGE_STATE_PROMPT;
            }
            break;
        }
        case STAGE_STATE_PAUSE:
        {
            std::string queryGUI = hud->queryButtons(Vector2(x, y));
            
            if (queryGUI == "toggle1")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    // Bad hack but
                    // Don't show 3-Back for multi-collection tasks of 1 or less.
                    if (player->getLevelRequestRow() > 0)
                        player->setToggleBack(0);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle2")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(1);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle3")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(2);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "toggle4")
            {
                if (tunnel && tunnel->isMultiCollectionTask())
                {
                    player->setToggleBack(3);
                    tunnel->respondToToggleCheat();
                }
            }
            else if (queryGUI == "pause")
            {
                setPause(true);
                stageState = STAGE_STATE_PROMPT;
            }
            else if (queryGUI == "go")
            {
                stageState = STAGE_STATE_RUNNING;
                setPause(false);
            }
            break;
        }
        case STAGE_STATE_PROMPT:
        {
            std::string queryGUI = hud->queryButtons(Vector2(x, y));
            
            if (queryGUI == "resume")
            {
                // If game hasn't started yet, go back to init prompt
                // Otherwise, go to gameplay
                if (hud->isGoButtonActive())
                {
                    stageState = STAGE_STATE_PAUSE;
                    if (player->hasTriggeredStartup() && player->getStartMusicTimer() <= 0.0)
                        player->playMusic();
                }
                else if (!tunnel->needsCleaning())
                {
                    setPause(false);
                    stageState = STAGE_STATE_RUNNING;
                }
            }
            else if (queryGUI == "next")
            {
                LevelSet* levels = player->getLevels();
                int row = player->getLevelRequestRow();
                int col = player->getLevelRequestCol();
                int level = levels->getLevelNo(row, col);
                int nlevel = ((level + 1) % NUM_TASKS) != 5 ? level + 1 : level + 2;
                if (player->isLevelAvailable(nlevel))
                {
                    row = levels->getLevelRow(nlevel);
                    col = levels->getLevelCol(nlevel);
                    player->setLevelRequest(row, col);
                    stageState = STAGE_STATE_INIT;
                    
                    setPause(false);
                    OgreFramework::getSingletonPtr()->m_pSoundMgr->stopAllSounds();
                }
            }
            else if (queryGUI == "restart")
            {
                stageState = STAGE_STATE_INIT;
                
                setPause(false);
                OgreFramework::getSingletonPtr()->m_pSoundMgr->stopAllSounds();
            }
            else if (queryGUI == "levelselect")
            {
                stageState = STAGE_STATE_DONE;
                
                setPause(false);
                OgreFramework::getSingletonPtr()->m_pSoundMgr->stopAllSounds();
            }
            break;
        }
        case STAGE_STATE_DONE:
            break;
    }
}