void Mission::showGoals(bool flag) { if( flag && !goalsIsVisible() ) { // show prompt Gameplay::iGui->getDesktop()->insertPanel( _promptWindow->getPanel() ); _promptWindow->align( gui::atTop, 0, gui::atRight, 0 ); // enumerate goals ActorV goals; happen( this, EVENT_GOAL_ENUMERATE, &goals ); // show & arrange goals Goal* goal; int x = 8; int y = _promptWindow->getPanel()->getRect().bottom + 8; gui::Rect desktopRect = Gameplay::iGui->getDesktop()->getRect(); gui::Rect rect; for( unsigned int i=0; i<goals.size(); i++ ) { goal = dynamic_cast<Goal*>( goals[i] ); assert( goal ); Gameplay::iGui->getDesktop()->insertPanel( goal->getWindow()->getPanel() ); // place goal rect.left = x; rect.right = x + goal->getWindow()->getPanel()->getRect().getWidth(); rect.top = y; rect.bottom = y + goal->getWindow()->getPanel()->getRect().getHeight(); // check rect is not overlaps the desktop if( rect.bottom > desktopRect.bottom ) { x = rect.right + 8; y = _promptWindow->getPanel()->getRect().bottom + 8; rect.left = x; rect.right = x + goal->getWindow()->getPanel()->getRect().getWidth(); rect.top = y; rect.bottom = y + goal->getWindow()->getPanel()->getRect().getHeight(); } goal->getWindow()->getPanel()->setRect( rect ); y = rect.bottom + 8; } } else if( !flag && goalsIsVisible() ) { // hide prompt Gameplay::iGui->getDesktop()->removePanel( _promptWindow->getPanel() ); // enumerate goals ActorV goals; happen( this, EVENT_GOAL_ENUMERATE, &goals ); // hide goals Goal* goal; for( unsigned int i=0; i<goals.size(); i++ ) { goal = dynamic_cast<Goal*>( goals[i] ); assert( goal ); Gameplay::iGui->getDesktop()->removePanel( goal->getWindow()->getPanel() ); } } }
void Mission::onUpdateActivity(float dt) { _fadTimeout -= dt; _interruptTimeout -= dt; // important action: ESC - interrupt mission if( Gameplay::iGameplay->getKeyboardState()->keyState[0x01] & 0x80 ) { if( _endOfPlayerActivity ) { _scene->getCareer()->setMissionWalkthroughFlag( _tournamentInfo, _wtmid, true ); _endOfMission = true; } else if( _interruptTimeout < 0 ) { assert( _scene->getCamera() ); _scene->getCamera()->updateActivity( 0.0f ); new Interrupt( _scene, _scene->getCamera()->getPose(), &_endOfMission, ( _player->getPhase() != jpRoaming ) ); _interruptTimeout = 0.25f; return; } } // soft time acceleration if( _fadValue != _fadTargetValue ) { float fadSpeed = 1.0f; float direction = _fadTargetValue - _fadValue; if( direction < 0 ) { _fadValue -= fadSpeed * dt; if( _fadValue < _fadTargetValue ) _fadValue = _fadTargetValue; } else { _fadValue += fadSpeed * dt; if( _fadValue > _fadTargetValue ) _fadValue = _fadTargetValue; } _scene->setTimeSpeedMultiplier( _fadValue ); } // action: first person mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode0 )->getTrigger() ) { setFirstPersonCamera(); } // action: third person mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode1 )->getTrigger() ) { setThirdPersonCamera(); } // action: follow mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode4 )->getTrigger() ) { setFollowCamera(); } // action : flyway mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode2 )->getTrigger() ) { _player->happen( this, EVENT_JUMPER_THIRDPERSON, _player ); _scene->setCamera( _fwcamera ); _fwcamera->setupCamera( _player, 2.0f, 0.75f ); } // action : free camera if( Gameplay::iGameplay->getActionChannel( iaCameraMode3 )->getTrigger() ) { _player->happen( this, EVENT_JUMPER_THIRDPERSON, _player ); _scene->setCamera( _frcamera ); } // action: time acceleration if( Gameplay::iGameplay->getActionChannel( ::iaAccelerateFlightTime )->getTrigger() && _fadTimeout < 0 && ( _player->getPhase() == ::jpFlight || _player->getPhase() == ::jpRoaming ) ) { _fadTargetValue *= 2.0f; if( _fadTargetValue > 4.0f ) _fadTargetValue = 4.0f; _fadTimeout = 0.25f; } // action: time deceleration if( Gameplay::iGameplay->getActionChannel( ::iaDecelerateFlightTime )->getTrigger() && _fadTimeout < 0 && ( _player->getPhase() == ::jpFlight || _player->getPhase() == ::jpRoaming ) ) { _fadTargetValue *= 0.5f; if( _fadTargetValue < 1.0f ) _fadTargetValue = 1.0f; _fadTimeout = 0.25f; } // reset time deceleration/acceleration if( _player->getPhase() == ::jpFreeFalling ) { _fadTargetValue = 1.0f; } // collect forest actors unsigned int forestId; std::vector<Forest*> forests; getScene()->getScenery()->happen( this, EVENT_FOREST_ENUMERATE, &forests ); // update physics _phTimeLeft += dt; while( _phTimeLeft > simulationStepTime ) { // begin to simulate physics _scene->getPhScene()->simulate( simulationStepTime ); _scene->getPhScene()->flushStream(); _scene->getPhScene()->fetchResults( NX_RIGID_BODY_FINISHED, true ); updatePhysics(); _phTimeLeft -= simulationStepTime; // forest interaction for( forestId=0; forestId<forests.size(); forestId++ ) { forests[forestId]->simulateInteraction( _player ); } } _scene->getPhScene()->visualize(); // player is over its activity? if( !_endOfPlayerActivity && _player->isOverActivity() ) { // raise local switch _endOfPlayerActivity = true; // hide HUD happen( this, EVENT_HUD_HIDE ); } // important action: TAB - show goals if( ( Gameplay::iGameplay->getKeyboardState()->keyState[0x0F] & 0x80 ) || _endOfPlayerActivity ) { if( !goalsIsVisible() ) { showGoals( true ); } } else { if( goalsIsVisible() ) { showGoals( false ); } } }
void Mission::onUpdateActivity(float dt) { _fadTimeout -= dt; _interruptTimeout -= dt; // important action: ESC - interrupt mission if( Gameplay::iGameplay->getKeyboardState()->keyState[0x01] & 0x80 ) { if( _endOfPlayerActivity ) { _scene->getCareer()->setMissionWalkthroughFlag( _wttid, _wtmid, true ); _endOfMission = true; } else if( _interruptTimeout < 0 ) { assert( _scene->getCamera() ); _scene->getCamera()->updateActivity( 0.0f ); new Interrupt( _scene, _scene->getCamera()->getPose(), &_endOfMission, ( _player->getPhase() != jpRoaming ) ); _interruptTimeout = 0.25f; return; } } // soft time acceleration if( _fadValue != _fadTargetValue ) { float fadSpeed = 1.0f; float direction = _fadTargetValue - _fadValue; if( direction < 0 ) { _fadValue -= fadSpeed * dt; if( _fadValue < _fadTargetValue ) _fadValue = _fadTargetValue; } else { _fadValue += fadSpeed * dt; if( _fadValue > _fadTargetValue ) _fadValue = _fadTargetValue; } //_scene->setTimeSpeedMultiplier( _fadValue ); } // action: first person mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode0 )->getTrigger() ) { setFirstPersonCamera(); Gameplay::iGameplay->getActionChannel( iaCameraMode0 )->reset(); } // action: third person mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode1 )->getTrigger() ) { setThirdPersonCamera(); } // action : flyway mode if( Gameplay::iGameplay->getActionChannel( iaCameraMode2 )->getTrigger() ) { _player->happen( this, EVENT_JUMPER_THIRDPERSON, _player ); _scene->setCamera( _fwcamera ); _fwcamera->setupCamera( _player, 2.0f, 0.75f ); } // action : free camera if( Gameplay::iGameplay->getActionChannel( iaCameraMode3 )->getTrigger() ) { _player->happen( this, EVENT_JUMPER_THIRDPERSON, _player ); _scene->setCamera( _frcamera ); } // action: time acceleration if( Gameplay::iGameplay->getActionChannel( ::iaAccelerateFlightTime )->getTrigger() && _fadTimeout < 0 && ( _player->getPhase() == ::jpFlight || _player->getPhase() == ::jpRoaming ) ) { _fadTargetValue *= 2.0f; if( _fadTargetValue > 4.0f ) _fadTargetValue = 4.0f; _fadTimeout = 0.25f; } // action: time deceleration if( Gameplay::iGameplay->getActionChannel( ::iaDecelerateFlightTime )->getTrigger() && _fadTimeout < 0 && ( _player->getPhase() == ::jpFlight || _player->getPhase() == ::jpRoaming ) ) { _fadTargetValue *= 0.5f; if( _fadTargetValue < 1.0f ) _fadTargetValue = 1.0f; _fadTimeout = 0.25f; } // reset time deceleration/acceleration if( _player->getPhase() == ::jpFreeFalling ) { _fadTargetValue = 1.0f; } // collect forest actors unsigned int forestId; std::vector<Forest*> forests; getScene()->getScenery()->happen( this, EVENT_FOREST_ENUMERATE, &forests ); // update physics _phTimeLeft += dt; while( _phTimeLeft > simulationStepTime ) { // begin to simulate physics _scene->getPhScene()->simulate( simulationStepTime ); // PHYSX3 _scene->getPhScene()->flushSimulation(); _scene->getPhScene()->fetchResults(true); updatePhysics(); _phTimeLeft -= simulationStepTime; // forest interaction for( forestId=0; forestId<forests.size(); forestId++ ) { forests[forestId]->simulateInteraction( _player ); } } //PHYSX3 //_scene->getPhScene()->visualize(); // player is over its activity? if( !_endOfPlayerActivity && _player->isOverActivity() ) { // raise local switch _endOfPlayerActivity = true; // hide HUD happen( this, EVENT_HUD_HIDE ); } // important action: TAB - show goals if( ( Gameplay::iGameplay->getKeyboardState()->keyState[0x0F] & 0x80 ) || _endOfPlayerActivity ) { if( !goalsIsVisible() ) { showGoals( true ); } } else { if( goalsIsVisible() ) { showGoals( false ); } } /// NETWORK NetworkData *packet = getScene()->network->consumePacketByReceiver(NET_REC_MISSION); while (packet != NULL) { consumePacket(packet); //delete packet; packet = getScene()->network->consumePacketByReceiver(NET_REC_MISSION); } // receive packets for jumpers //for (unsigned int i = 0; i < _children.size(); ++i) { // if (strcmp(_children[i]->getName(), "Jumper") != 0) continue; // NetworkData *packet = getScene()->network->consumePacketByReceiver(NET_REC_JUMPER, _children[i]->network_id); // while (packet != NULL) { // _children[i]->consumePacket(packet); // packet = getScene()->network->consumePacketByReceiver(NET_REC_JUMPER, _children[i]->network_id); // } //} }