/** * Start level under pressed button. * Start pedometer when level is solved already. */ void WorldMap::runSelected() { Level *level = createSelected(); if (level) { m_levelStatus->prepareRun(m_selected->getCodename(), m_selected->getPoster(), m_selected->getBestMoves(), m_selected->getBestAuthor()); level->fillStatus(m_levelStatus); if (m_selected->getState() == LevelNode::STATE_SOLVED) { Pedometer *pedometer = new Pedometer(m_levelStatus, level); pushState(pedometer); } else { pushState(level); } } else { if (m_activeMask == m_maskIntro) { runIntro(); } else if (m_activeMask == m_maskExit) { quitState(); } else if (m_activeMask == m_maskCredits) { runCredits(); } else if (m_activeMask == m_maskOptions) { runOptions(); } } }
void runGameState(GameVars* gameVars) { //Game State manager switch (gameVars->gameState) { //Title screen case GSTitle: { runTitle(gameVars); } break; //Menu screen case GSMenu: { runMenu(gameVars); } break; case GSCredits: { runCredits(gameVars); } break; //Game engine case GSGameStart: case GSWaitForServe: case GSPlay: case GSScored: case GSGameOver: { runGameplay(gameVars); } break; default: break; } }
void OSpit::xbookclick(const ArgumentArray &args) { // Let's hook onto our video RivenVideo *video = _vm->_video->getSlot(args[0]); // Convert from the standard QuickTime base time to milliseconds // The values are in terms of 1/600 of a second. // Have I said how much I just *love* QuickTime? </sarcasm> uint32 startTime = args[1] * 1000 / 600; uint32 endTime = args[2] * 1000 / 600; // Track down our hotspot Common::String hotspotName = Common::String::format("touchBook%d", args[3]); RivenHotspot *hotspot = _vm->getCard()->getHotspotByName(hotspotName); Common::Rect hotspotRect = hotspot->getRect(); debug(0, "xbookclick:"); debug(0, "\tVideo Code = %d", args[0]); debug(0, "\tStart Time = %dms", startTime); debug(0, "\tEnd Time = %dms", endTime); debug(0, "\tHotspot = %d -> %s", args[3], hotspotName.c_str()); // Just let the video play while we wait until Gehn opens the trap book for us while (video->getTime() < startTime && !_vm->hasGameEnded()) { _vm->doFrame(); } // Break out if we're quitting if (_vm->hasGameEnded()) return; // OK, Gehn has opened the trap book and has asked us to go in. Let's watch // and see what the player will do... while (video->getTime() < endTime && !_vm->hasGameEnded()) { if (hotspotRect.contains(getMousePosition())) _vm->_cursor->setCursor(kRivenOpenHandCursor); else _vm->_cursor->setCursor(kRivenMainCursor); if (mouseIsDown()) { if (hotspotRect.contains(getMousePosition())) { // OK, we've used the trap book! We go for ride lady! _vm->_video->closeVideos(); // Stop all videos _vm->_cursor->setCursor(kRivenHideCursor); // Hide the cursor _vm->_gfx->scheduleTransition(kRivenTransitionBlend); _vm->getCard()->drawPicture(3); // Black out the screen _vm->_sound->playSound(0); // Play the link sound _vm->delay(12000); _vm->getCard()->playMovie(7); // Activate Gehn Link Video RivenVideo *linkVideo = _vm->_video->openSlot(1); // Play Gehn Link Video linkVideo->playBlocking(); _vm->_vars["ocage"] = 1; _vm->_vars["agehn"] = 4; // Set Gehn to the trapped state _vm->_vars["atrapbook"] = 1; // We've got the trap book again _vm->_sound->playSound(0); // Play the link sound again _vm->_gfx->scheduleTransition(kRivenTransitionBlend); _vm->changeToCard(_vm->getStack()->getCardStackId(0x2885)); // Link out! _vm->_inventory->forceVisible(true); _vm->delay(2000); _vm->_inventory->forceVisible(false); _vm->_scriptMan->stopAllScripts(); // Stop all running scripts (so we don't remain in the cage) return; } } _vm->doFrame(); } // Break out if we're quitting if (_vm->hasGameEnded()) return; // If there was no click and this is the third time Gehn asks us to // use the trap book, he will shoot the player. Dead on arrival. // Run the credits from here. if (_vm->_vars["agehn"] == 3) { runCredits(args[0], 5000, 995); return; } // There was no click, so just play the rest of the video. video->playBlocking(); }
void StateMachine::run() { ResourceManager& resourceManager = ResourceManager::getInstance(); if (!resourceManager.noUsableScreenResolution) { state = loading; //Edit this to set the startup state } else { state = noScreenResolution; //Edit this to set the startup state } sf::Sound sound; while (state != quit) { switch (state) { case loading: state = runLoading(); break; case mainMenu: sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState")); sound.Play(); state = runMainMenu(); break; case gameSetup: sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState")); sound.Play(); state = runGameSetup(); break; case runGame: state = runTheGame(); break; case gameDone: state = runGameDone(); break; case highScore: sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState")); sound.Play(); state = runHighScore(); break; case credits: sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState")); sound.Play(); state = runCredits(); break; case help: sound.SetBuffer(resourceManager.sounds.getSound(0,"ChangeState")); sound.Play(); state = runHelp(); break; case noScreenResolution: state = runNoScreenResolution(); state = quit; break; case tournament: state = runTournament(); default: break; } // Just in case something in the list is bad pointers. // TODO: Clean up all resources in the end of all // state functions (like runTheGame) resourceManager.drawableList.clear(); } resourceManager.win.Close(); }