/************************************************************************ * 游戏剧情的章节转换 ************************************************************************/ void Controller::ChangeChapter(int nChapterID) { if (nChapterID != CHAPTER_1 && nChapterID != CHAPTER_2 && nChapterID != CHAPTER_3 && nChapterID != CHAPTER_4) { return; } vector<Player*> playerList = Game()->GetPlayerManager()->GetPlayerList(); if (m_nCurrentChapter != CHAPTER_0) { for (int i = 0; i < playerList.size(); ++i) { playerList[i]->Action(CodeMsg::code_player_static,right_direction); } } // 设置当前章节的ID m_nCurrentChapter = nChapterID; // 先让玩家停止 // 暂停游戏 SuspendGame(); // 移除地图上所有的怪物 Game()->GetMonsterManager()->RemoveAllMonster(); // 移除地图上所有的装备 Game()->GetEquipmentManager()->RemoveAllEquipment(); // 当前选中的怪物置为空 m_pCurrentSelectedMonster = 0; // 新建一个boss(每个章节的Boss都不一样) m_pBoss = Game()->GetMonsterManager()->CreateBoss(); // 场景转换 Game()->GetSceneManager()->ChangeScene(nChapterID); // 继续游戏 ContinueGame(); }
/* ======================== idMenuScreen_Shell_Singleplayer::HandleAction ======================== */ bool idMenuScreen_Shell_Singleplayer::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) { if ( menuData == NULL ) { return true; } if ( menuData->ActiveScreen() != SHELL_AREA_CAMPAIGN ) { return false; } widgetAction_t actionType = action.GetType(); const idSWFParmList & parms = action.GetParms(); switch ( actionType ) { case WIDGET_ACTION_GO_BACK: { menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE ); return true; } case WIDGET_ACTION_PRESS_FOCUSED: { if ( options == NULL ) { return true; } int selectionIndex = options->GetViewIndex(); if ( parms.Num() == 1 ) { selectionIndex = parms[0].ToInteger(); } canContinue = false; const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames(); canContinue = ( saveGameInfo.Num() > 0 ); if ( canContinue ) { if ( selectionIndex == 0 ) { ContinueGame(); } else if ( selectionIndex == 1 ) { class idSWFScriptFunction_NewGame : public idSWFScriptFunction_RefCounted { public: idSWFScriptFunction_NewGame( idMenuHandler * _menuData, bool _accept ) { menuData = _menuData; accept = _accept; } idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { common->Dialog().ClearDialog( GDM_DELETE_AUTOSAVE ); if ( accept ) { menuData->SetNextScreen( SHELL_AREA_NEW_GAME, MENU_TRANSITION_SIMPLE ); } return idSWFScriptVar(); } private: idMenuHandler * menuData; bool accept; }; common->Dialog().AddDialog( GDM_DELETE_AUTOSAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_NewGame( menuData, true ), new idSWFScriptFunction_NewGame( menuData, false ), true ); } else if ( selectionIndex == 2 ) { menuData->SetNextScreen( SHELL_AREA_LOAD, MENU_TRANSITION_SIMPLE ); } } else { if ( selectionIndex == 0 ) { menuData->SetNextScreen( SHELL_AREA_NEW_GAME, MENU_TRANSITION_SIMPLE ); } else if ( selectionIndex == 1 ) { menuData->SetNextScreen( SHELL_AREA_LOAD, MENU_TRANSITION_SIMPLE ); } } return true; } } return idMenuWidget::HandleAction( action, event, widget, forceHandled ); }