Esempio n. 1
0
void OgreApp::setPause(bool value)
{
    if (value)
    {
        pause = value;
        player->pause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->pauseAllSounds();
        if (predictSessionOver())
        {
            if (player->getName() == "subject999")
                globals.setMessage("Training is complete!\nPlease check in.\n\nDouble tap to exit.", MESSAGE_FINAL);
            else
                globals.setMessage("That's it for Today!\nPlease check in before you leave.\n\nYou completed: " + Util::toStringInt(player->getNumStagesWon()) + " stages!\n\nDouble tap to exit.", MESSAGE_FINAL);
            endGame();
        }
        else
        {
            globals.appendMessage("\n\nSwipe to Continue", MESSAGE_NORMAL);
#ifdef DEBUG_MODE
            globals.appendMessage("\n\n" + player->getSkillLevel().getCurrentStats(), MESSAGE_NORMAL);
            globals.appendMessage("\n\n" + Util::toStringInt(globals.sessionTime - getTotalElapsed()), MESSAGE_NORMAL);
#endif
        }
        Ogre::ControllerManager::getSingleton().setTimeFactor(0);
    }
    else if (!sessionOver)
    {
        pause = value;
        player->unpause();
        OgreFramework::getSingletonPtr()->m_pSoundMgr->resumeAllPausedSounds();
        
        globals.clearMessage();
        Ogre::ControllerManager::getSingleton().setTimeFactor(1);
    }
}
Esempio n. 2
0
void EngineStage::setPause(bool value, bool targetAllSounds)
{
    if (value)
    {
        if (targetAllSounds)
            OgreFramework::getSingletonPtr()->m_pSoundMgr->pauseAllSounds();
        player->pause();
        
        // Display current level index
        LevelSet* levels = player->getLevels();
        std::string msg = "Level: ";
        msg += Util::toStringInt(player->getLevelRequestRow() + 1);
        msg += "-";
        msg += (char)('A' + player->getLevelRequestCol());
        globals.setMessage(msg, MESSAGE_NORMAL);
        
        Ogre::ControllerManager::getSingleton().setTimeFactor(0);
    }
    else
    {
        player->unpause();
        if (targetAllSounds)
            OgreFramework::getSingletonPtr()->m_pSoundMgr->resumeAllPausedSounds();
        globals.clearMessage();
        Ogre::ControllerManager::getSingleton().setTimeFactor(1);
    }
}
Esempio n. 3
0
void OgreApp::endLevel(Evaluation forced)
{
    globals.clearMessage();
    
    if (tunnel)
    {
        tunnel->setCleaning(true);
        if (levelMgr->levelFinished(tunnel, forced))
        {
            gameState = STATE_PROMPT;
            globals.setMessage("Play Again?\n\n\n(Yes / No)\n\n\n<--- Swipe --->", MESSAGE_NORMAL);
        }
        else
            gameState = STATE_PLAY;
    }
}
Esempio n. 4
0
void OgreApp::setLevel(Evaluation forced, bool forward)
{
    globals.clearMessage();
    
    std::vector<NavigationLevel> navLevels;
    if (tunnel)
    {
        levelMgr->updatePlayerSkill(tunnel, forced);
        if (forward)
            levelMgr->incrementSchedIndex();
        else
            levelMgr->decrementSchedIndex();
        navLevels = tunnel->getNavLevels();
        player->unlink();
        tunnel->unlink();
        hud->unlink();
    }
    
    // Don't gen a new tunnel if our schedule is over
    if (!predictSessionOver())
    {
        tunnel = levelMgr->getNextLevel(tunnel);
        if (navLevels.size() <= 0) // First stage
        {
            globals.appendMessage("\n\nSession No: " + Util::toStringInt(player->getSkillLevel().sessionID), MESSAGE_NORMAL);
        }
    }
    // Link/Relink Pointers
    tunnel->link(player, hud);
    player->link(tunnel, hud);
    hud->init(tunnel, player);
    
    if (!predictSessionOver())
    {
        // If repeated, repeat the same navigation level
        if (levelMgr->isRepeatingPhase())
            tunnel->setNavigationLevels(navLevels);
        else
            tunnel->setNavigationLevels();
        tunnel->constructTunnel(globals.tunnelSections);
        // If nback is same then panels are changing, keep speed same
        player->setCamPos(tunnel->getStart() + tunnel->getCurrent()->getForward() * globals.tunnelSegmentDepth);
        player->setCamRot(tunnel->getCurrent()->getQuaternion());
        player->setDesireRot(player->getCamRot());
        player->newTunnel(musicMode == MUSIC_ENABLED);
        
        Plane plane;
        switch (globals.setSkyBox)
        {
            case 0:
                plane.d = 3000;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/SpaceSkyPlane", 80, 4, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue::ZERO, 0.0, 300.0, 600.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
            case 1:
                plane.d = 160;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/TestSkyPlane0", 1.9, 1, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue(1.0, 0.95, 0.3, 0.0), 0.0, 500.0,  800.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
            default:
                plane.d = 3000;
                plane.normal = Ogre::Vector3(0, 0, 1);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setSkyPlane(true, plane, "General/SpaceSkyPlane", 80, 4, true);
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue::ZERO, 0.0, 300.0, 600.0);
                OgreFramework::getSingletonPtr()->m_pViewportMain->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
                OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->resetToInitialState();
                break;
        }
    }
    
    // Stop the game
    setPause(true);
}
Esempio n. 5
0
void EngineStage::setup()
{
    globals.clearMessage();
    
    // Dealloc data
    dealloc();
    
    // Retrieve player skill and gen new tunnel
    PlayerLevel skillLevel = player->getSkillLevel();
    
    // Setup player and tunnel params
    Vector3 origin = Vector3::ZERO;
    Vector3 forward = globals.tunnelReferenceForward;
    Quaternion rot = Quaternion(1, 0, 0, 0);
    
    //if (!configStageType(globals.configPath, globals.configBackup, "globalConfig"))
    //    globals.setMessage("WARNING: Failed to read configuration", MESSAGE_ERROR);
    
    globals.maxCamSpeed = skillLevel.maxSpeed;
    
    globals.stageTotalTargets1 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets2 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    globals.stageTotalTargets3 = globals.stageTotalSignals * (globals.podNBackChance / 100.0);
    
    StageMode nmode = STAGE_MODE_PROFICIENCY;
    StageRequest level = player->getLevels()->retrieveLevel(player->getLevelRequestRow(), player->getLevelRequestCol());
    int nlevel = level.nback;
    switch (level.phase)
    {
        case 'A':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_BLUE, POD_SHAPE_UNKNOWN, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_GREEN, POD_SHAPE_UNKNOWN, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_PINK, POD_SHAPE_UNKNOWN, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_YELLOW, POD_SHAPE_UNKNOWN, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.appendMessage("\nObtain matches by Color!", MESSAGE_NORMAL);
            break;
        }
        case 'B':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_DIAMOND, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_SPHERE, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_CONE, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_UNKNOWN, POD_SHAPE_TRIANGLE, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.appendMessage("Obtain matches by Shape!", MESSAGE_NORMAL);
            break;
        }
        case 'C':
        {
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_HOLDOUT, POD_SHAPE_UNKNOWN, POD_SOUND_4));

            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.setMessage("Obtain matches by only sound!", MESSAGE_NORMAL);
            break;
        }
        case 'D':
            nmode = STAGE_MODE_COLLECTION;
            globals.signalTypes = std::vector<std::vector<PodInfo> >(4);
            globals.signalTypes[POD_SIGNAL_1].push_back(PodInfo(POD_SIGNAL_1, POD_FUEL, POD_COLOR_BLUE, POD_SHAPE_DIAMOND, POD_SOUND_1));
            globals.signalTypes[POD_SIGNAL_2].push_back(PodInfo(POD_SIGNAL_2, POD_FUEL, POD_COLOR_GREEN, POD_SHAPE_SPHERE, POD_SOUND_2));
            globals.signalTypes[POD_SIGNAL_3].push_back(PodInfo(POD_SIGNAL_3, POD_FUEL, POD_COLOR_PINK, POD_SHAPE_CONE, POD_SOUND_3));
            globals.signalTypes[POD_SIGNAL_4].push_back(PodInfo(POD_SIGNAL_4, POD_FUEL, POD_COLOR_YELLOW, POD_SHAPE_TRIANGLE, POD_SOUND_4));
            
            //globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
            globals.setMessage("Obtain matching signals!", MESSAGE_NORMAL);
            break;
        case 'E':
            nmode = STAGE_MODE_RECESS;
            globals.signalTypes.clear();
            
            if (level.initCamSpeed <= 15) // For starting slower stages, be nicer
                globals.stageTotalCollections = (level.minCamSpeed + level.maxCamSpeed) / 3.0 * level.stageTime / Util::getModdedLengthByNumSegments(globals, globals.tunnelSegmentsPerPod);
            else
                globals.stageTotalCollections = (level.minCamSpeed + level.maxCamSpeed) / 2.5 * level.stageTime / Util::getModdedLengthByNumSegments(globals, globals.tunnelSegmentsPerPod);
            //globals.setBigMessage("Recess!");
            globals.setMessage("Reach the end! Grab Fuel Cells!", MESSAGE_NORMAL);
            break;
        case 'F':
            nmode = STAGE_MODE_TEACHING;
            globals.signalTypes.clear();
            //globals.setBigMessage("Training!");
            globals.setMessage("Grab Fuel Cells!", MESSAGE_NORMAL);
            break;
    }
    globals.initCamSpeed = level.initCamSpeed;
    globals.minCamSpeed = level.minCamSpeed;
    globals.maxCamSpeed = level.maxCamSpeed;
    
    tunnel = new Tunnel(
                        OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode(),
                        origin + forward * (globals.tunnelSegmentWidth / 2),
                        rot,
                        globals.tunnelSegmentWidth,
                        globals.tunnelSegmentDepth,
                        globals.tunnelMinAngleTurn,
                        globals.tunnelMaxAngleTurn,
                        1, // replace or remove...
                        nmode,
                        level.phase, // replace or remove...
                        nlevel,
                        level.stageTime,
                        SOUTH,
                        globals.tunnelSegmentsPerSection,
                        globals.tunnelSegmentsPerPod,
                        globals.tunnelSegmentsPerDistractors,
                        globals.tunnelSegmentsPerPowerup,
                        globals.signalTypes,
                        level.powerups);
    tunnel->link(player);
    player->link(tunnel);
    
    tunnel->setHoldout(level.hasHoldout,level.holdoutFrequency);
    if (tunnel->getMode() == STAGE_MODE_RECESS)
    {
        // Assign nav levels in an incremental order specified by Liam's formula if the mode is recess
        // Therefore, the level parameter provided looks at the nav level provided as the starting index
        tunnel->setNavigationLevels(level.navLevels[0].level, globals.navMap.size() - 1, level.tunnelSectionsPerNavLevel);
    }
    else
    {
        // Otherwise, nav levels provided by the parameters
        tunnel->setNavigationLevels(level.navLevels, level.tunnelSectionsPerNavLevel);
    }
    tunnel->setCollectionCriteria(level.collectionCriteria);
    tunnel->constructTunnel(level.nameTunnelTile, globals.tunnelSections);
    player->newTunnel(level.nameMusic);
    player->setSpeedParameters(globals.initCamSpeed, globals.minCamSpeed, globals.maxCamSpeed);
    
    Util::setSkyboxAndFog(level.nameSkybox);
    
    /*
     if (skillLevel.set1Notify)
     globals.setBigMessage("Congratulations! You earned " + Util::toStringInt(nlevel) + "-Back!");
     else
     {
     if (skillLevel.set1Rep >= 2)
     globals.setBigMessage(Util::toStringInt(nlevel) + "-Back. Challenge Round!");
     else
     globals.setBigMessage(Util::toStringInt(nlevel) + "-Back");
     }
     globals.setMessage("Match by Color!", MESSAGE_NORMAL);
     */
    
    hud = new HudStage(player, tunnel);
    
    Quaternion camRot = player->getCombinedRotAndRoll();
    
    // Set lighting
    lightMain = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->createLight("StageLight");
    lightMain->setDiffuseColour(1.0, 1.0, 1.0);
    lightMain->setSpecularColour(1.0, 1.0, 1.0);
    //lightMain->setAttenuation(10, 1.0, 0.0001, 0.0);
    lightNode = OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getRootSceneNode()->createChildSceneNode("lightNode");
    lightNode->attachObject(lightMain);
    
    // Set initial transformations for camera, light, skynode
    OgreFramework::getSingletonPtr()->m_pCameraMain->setPosition(player->getCamPos());
    OgreFramework::getSingletonPtr()->m_pCameraMain->setOrientation(camRot);
    if (OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode())
        OgreFramework::getSingletonPtr()->m_pSceneMgrMain->getSkyPlaneNode()->setOrientation(player->getCombinedRotAndRoll());
    if (lightNode)
        lightNode->setPosition(OgreFramework::getSingletonPtr()->m_pCameraMain->getPosition());
    
    // Set tutorial slides for certain thingies
    if (tunnel->getMode() == STAGE_MODE_RECESS || tunnel->getMode() == STAGE_MODE_TEACHING || tunnel->getHighestCriteria() <= 0)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_ZERO_BACK);
    if (tunnel->getHighestCriteria() == 1)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_ONE_BACK);
    if (tunnel->getHighestCriteria() == 2)
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_TWO_BACK);
    if (tunnel->getPhase() == 'A')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_COLOR_SOUND);
    if (tunnel->getPhase() == 'B')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_SHAPE_SOUND);
    if (tunnel->getPhase() == 'C')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_SOUND_ONLY);
    if (tunnel->getPhase() == 'D')
        player->getTutorialMgr()->setSlides(TutorialManager::TUTORIAL_SLIDES_HOLDOUT);

    spinVelocity = 0.0f;
    spinVelocityTarget = 0.0f;
    damping = 0.0f;
    freeMotion = false;
}