📄 game.cpp
字号:
{
m_pEngine->GetSound()->stopMIDI();
m_GameState=GS_MATCH;
InitMatchState();
}
break;
case GS_MATCH:
UpdateMatch(); // game logic for a match
if(m_MatchState==MS_MATCH_EXIT)
{
ReleaseLocalResource();
m_pMenu->ResetState();
#ifdef ONLINE
if(m_bOnlineMode)// online mode, go to the ranking board
{
m_pMenu->SetState(STATE_MAINMENU);
m_pMenu->SetState(STATE_ONLINEMODE);
m_pMenu->SetState(STATE_INITCONNECT);
m_pMenu->SetState(STATE_NICKNAME);
m_pEngine->GetNetwork()->stopConnect();
m_GameState=GS_MENU;
m_bOnlineMode=false;
}
else
{
m_pMenu->SetState(STATE_MAINMENU); // back to main menu
m_GameState=GS_MENU;
}
#else
m_pMenu->SetState(STATE_MAINMENU); // back to main menu
m_GameState=GS_MENU;
#endif
break;
}
break;
case GS_STORYMODE:
UpdateStoryMode(); // game logic for a match
if(m_StoryModeState==SMS_MODE_EXIT)
{
m_iDrawCount =0;
m_pMatch->SetMatchFinish(false);
m_pMatch->SetDrawMatchFinish(false);
ReleaseLocalResource();
m_pMenu->ResetState();
if(m_pMatch->m_mode==MODE_BONUS)
{
m_pMenu->SetState(STATE_BONUSMODE);
}
m_pMenu->SetState(STATE_MAINMENU); // back to mainmenu
m_GameState=GS_MENU;
}
break;
case GS_CAMERAVIEW_LOADING:
if(Loading(m_step)) //loading
{
m_pScene->SetCurHint(ID_HINT_VIEW_SCENE);
m_GameState=GS_CAMERAVIEW;
}
m_step++;
//Milo 03-30
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_CLR))
{
m_step = 0;
ReleaseLocalResource();
m_pMenu->ResetState();
m_pMenu->SetState(STATE_MAINMENU); // back to main menu
resumeMIDI();
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_MENU),1);
m_GameState=GS_MENU;
}
break;
case GS_CAMERAVIEW:
// key press for pause menu
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_PAUSE))
{
m_pause=true;
m_pMenu->ResetState();
m_pMenu->SetState(STATE_PAUSE);
//don't show view score menu item
m_pMenu->SetState(STATE_BONUSMODE);
}
if(m_pEngine->GetInput()->KeyPressed(gk_STAR))
m_pScene->CameraViewInit();
m_pScene->CameraView();
break;
case GS_END:
saveGeneralRecord(SAVE_OPTION);
DBGPRINTF("RUNING OVER");
m_running=false;
break;
default:
break;
}
#ifdef ONLINE
if (m_bOnlineMode)// online mode, update the online state
{
onlineStateUpdate();
}
#endif
}
// game logic for story mode
void CGame::UpdateStoryMode()
{
switch(m_StoryModeState)
{
case SMS_MODE_INIT:
// load storymode info from datamanager
m_pMatch->m_smIsStoryMode=true;
m_pDataManager->LoadStoryMode(m_pMatch->m_smPlayerId, &(m_pMatch->m_pCurStoryMode));
m_pMatch->SetInitPinMode(ALL_TENPINS_STAND);
m_pDataManager->LoadPlayerInfo(m_pMatch->m_smPlayerId,&m_pMatch->m_player[0]);
m_pMatch->SetPlayerAI(0,false);
m_pMatch->SetPlayerAI(1,true);
m_pMatch->m_smStageIndex=0;
m_StoryModeState=SMS_LEVEL_LOADING;
break;
case SMS_LEVEL_LOADING:
if(Loading(m_step))
{
m_pScene->m_object[RENDER_BALL]->SetHideProperty(TRUE);
m_pScene->m_object[RENDER_SETTING_TENPIN]->SetHideProperty(TRUE);
m_pScene->m_object[RENDER_GRABBING_TENPIN]->SetHideProperty(TRUE);
m_pScene->m_object[RENDER_PLAYER]->SetHideProperty(TRUE);
if(0==m_pMatch->m_pCurStage->place)
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_CLUB_1), 0);
else if(1==m_pMatch->m_pCurStage->place)
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_CLUB_2), 0);
else if(2==m_pMatch->m_pCurStage->place)
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_CLUB_3), 0);
m_pScene->m_render3D.GetG3d()->setZDist(FOV_CAMERA_VIEW);
m_pScene->m_cCamera->SetStage(CCSS_INTRODUCTION);
m_pScene->m_cCamera->UpdateCamera();
m_StoryModeState=SMS_LEVEL_INTRODUCTION;
}
m_step++;
//Milo 03-30
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_CLR))
{
m_step = 0;
ReleaseLocalResource();
m_pMenu->ResetState();
m_pMenu->SetState(STATE_MAINMENU); // back to main menu
loadGeneralRecord();
resumeMIDI();
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_MENU),1);
m_GameState=GS_MENU;
}
break;
case SMS_LEVEL_INTRODUCTION:
// call camera and update
m_pScene->m_cCamera->UpdateCamera();
if(m_pScene->m_cCamera->m_bFinished || m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SKIP | VKEY_MENU_CLR))
{
m_pEngine->GetSound()->stopMIDI();
// prepare words for talk
m_pMatch->m_smWordsIndex=2; // index 0 is for win words, index 1 is for lose words.
// from index 2 is for talk words
m_pMatch->m_smWordsFinished=false;
m_pMatch->m_smWordsNextPage=false;
m_pMatch->m_smWordsPlayerId=m_pMatch->m_pCurStage->words[m_pMatch->m_smWordsIndex].person;
int i=m_pMatch->m_pCurStage->words[m_pMatch->m_smWordsIndex].stringId;
m_pMatch->m_smpWords=m_pDataManager->m_pStringItem[i];
// set camera for talk
int cid=getTalkCamera(m_pMatch->GetLane(), 0, m_pMatch->m_pCurStage->words_count-2, m_pMatch->m_smWordsPlayerId==m_pMatch->GetPlayerID(0));
m_pScene->m_cCamera->SetStage(cid);
m_pScene->m_cCamera->UpdateCamera();
m_pScene->SetStage(DS_STORY_PRE_TALK);
m_StoryModeState=SMS_LEVEL_PRE_TALK;
}
break;
case SMS_LEVEL_PRE_TALK:
m_pScene->m_cCamera->UpdateCamera();
m_pScene->UpdateScene(0);
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SKIP | VKEY_MENU_CLR))
{
// skip to match
InitMatchState();
m_pMatch->SetMatchType(MATCH_TYPE_VS);
m_StoryModeState=SMS_LEVEL_MATCH;
return;
}
else if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SELECT))
{
// next sentence
if(m_pMatch->m_smWordsFinished)
{
m_pMatch->m_smWordsIndex++;
((CPlayer*)m_pScene->m_object[RENDER_PLAYER])->SetAnimationOption(PLAYER_ANI_TALKING);
((CPlayer*)m_pScene->m_object[RENDER_PLAYER2])->SetAnimationOption(PLAYER_ANI_TALKING);
if(m_pMatch->m_smWordsIndex>=m_pMatch->m_pCurStage->words_count)
{
InitMatchState();
m_pMatch->SetMatchType(MATCH_TYPE_VS);
m_StoryModeState=SMS_LEVEL_MATCH;
return;
}
m_pMatch->m_smWordsPlayerId=m_pMatch->m_pCurStage->words[m_pMatch->m_smWordsIndex].person;
int i=m_pMatch->m_pCurStage->words[m_pMatch->m_smWordsIndex].stringId;
m_pMatch->m_smpWords=m_pDataManager->m_pStringItem[i];
m_pMatch->m_smWordsNextPage=false;
// cut camera
int cid=getTalkCamera(m_pMatch->GetLane(), m_pMatch->m_smWordsIndex-2, m_pMatch->m_pCurStage->words_count-2, m_pMatch->m_smWordsPlayerId==m_pMatch->GetPlayerID(0));
m_pScene->m_cCamera->SetStage(cid);
}
else
m_pMatch->m_smWordsNextPage=true;
}
else
m_pMatch->m_smWordsNextPage=false;
// update scene
break;
case SMS_LEVEL_MATCH:
// call gamelogic of a match inside the story mode
UpdateMatch();
if(m_MatchState==MS_DELIVERY_END)
{
// saveStoryInfo(); // save delivery info into a buffer, after each delivery
}
else if(m_MatchState==MS_MATCH_EXIT)
{
// saveStoryInfo();
// saveGeneralRecord(SAVE_GENERAL); // save info into save file, after each level
m_pScene->UpdateScene(0);
m_pScene->SetStage(DS_STORY_MATCHEND);
m_StoryModeState=SMS_LEVEL_MATCH_RESULT_ANI;
}
m_step = 0;
break;
case SMS_LEVEL_MATCH_RESULT_ANI: // win animation or lose animation
m_pScene->UpdateScene(0);
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SELECT) || m_pEngine->GetInput()->KeyPressed(VKEY_MENU_RETRY)
|| ((m_pMatch->m_smStageIndex>=5 && m_pEngine->GetInput()->KeyPressed(VKEY_MENU_CLR))))
{
// press Next or Retry to next level
m_StoryModeState=SMS_LEVEL_END;
}
else if((m_pMatch->m_MatchResult == 0 && m_pEngine->GetInput()->KeyPressed(VKEY_MENU_EXIT))
|| (m_pEngine->GetInput()->KeyPressed(VKEY_MENU_CLR)))
// press Exit to exit story mode
m_StoryModeState=SMS_MODE_EXIT;
break;
case SMS_LEVEL_END:
if(m_pMatch->m_MatchResult)
{
// open balls and bonus as the coins you passed
// m_pScene->CoinResultProcess();
m_pMatch->m_smStageIndex++;
}
if(m_pMatch->m_smStageIndex>=5)
{
// finish whole story mode.
m_StoryModeState=SMS_MODE_END;
m_step=0;
m_pScene->m_stringEffectTimer=0;
}
else
{
m_StoryModeState=SMS_LEVEL_LOADING;
m_step=0;
}
break;
case SMS_MODE_END:
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SELECT|VKEY_MENU_CLR))
{
m_step++;
m_pScene->m_stringEffectTimer=0;
if(m_step>=2)
{
// mode end,
m_SaveStoryPassed=true;
m_SaveCanContinue=false;
// unlock
// unlockCloth();
unlockLane();
unlockLaneView();
saveStoryInfo();// init the story save
saveGeneralRecord(SAVE_GENERAL);
ReleaseLocalResource();
m_GameState=GS_MENU;
m_pMenu->ResetState();
m_pMenu->SetState(STATE_MAINMENU);
m_pMenu->SetState(STATE_CREDIT);
}
}
break;
case SMS_MODE_EXIT:
break;
case SMS_CONTINUE:
////
// load storymode info from datamanager
/*m_pMatch->m_smIsStoryMode=true;
m_pDataManager->LoadStoryMode(m_pMatch->m_smPlayerId, &(m_pMatch->m_pCurStoryMode));
m_pMatch->SetInitPinMode(ALL_TENPINS_STAND);
m_pDataManager->LoadPlayerInfo(m_pMatch->m_smPlayerId,&m_pMatch->m_player[0]);
m_pMatch->SetPlayerAI(0,false);
m_pMatch->SetPlayerAI(1,true);
m_pMatch->m_smStageIndex=0;
loadGeneralRecord();*/
/*matchInit();
m_pMatch->m_smIsStoryMode=true;
m_pDataManager->LoadStoryMode(m_pMatch->m_smPlayerId, &(m_pMatch->m_pCurStoryMode));
m_pMatch->SetInitPinMode(ALL_TENPINS_STAND);
m_pDataManager->LoadPlayerInfo(m_pMatch->m_smPlayerId,&m_pMatch->m_player[0]);
m_pMatch->SetPlayerAI(0,false);
m_pMatch->SetPlayerAI(1,true);
m_pMatch->m_smStageIndex=0;
loadGeneralRecord();*/
////
//Milo 03-30
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_CLR))
{
m_step = 0;
ReleaseLocalResource();
m_pMenu->ResetState();
m_pMenu->SetState(STATE_MAINMENU); // back to main menu
resumeMIDI();
m_pEngine->GetSound()->playMIDI(ConvertSoundID(ID_SOUND_MENU),1);
m_GameState=GS_MENU;
}
////
if(m_step == 0)
{
loadStoryInfo(); //load story info buffer
++m_step;
}
else if(m_step == 1)
{
m_pScene->SetIsDraw((m_SaveIsDraw==1)); // for draw game in the StoryMode
forContinueStory(); //prepare for continue this story.
//m_iDrawCount = m_SaveIsDraw==1 ? 1:0;
++m_step;
}
else if(m_step == 2)
{
if(!m_pMatch->GetMatchFinish())
{
m_pScene->SetStage(DS_DELIVERY_INIT,m_pMatch->GetCurPlayerAI());
m_MatchState=MS_DELIVERY_INIT;
}
else
{//for match finsh stage
//
const Bg *pBg = m_pDataManager->GetBgInfo(m_pMatch->GetLane());
m_pScene->m_object[RENDER_SCENE]->SetModelID(pBg->modelIndex);
m_pScene->m_object[RENDER_FLOOR]->SetModelID(pBg->floorModelIndex);
//Milo 01-18
m_pScene->m_object[RENDER_FREEZE_AUDIENCE]->SetModelID(pBg->audienceIndex);//SetModelID(MODEL_FREEZE_AUD);
m_pScene->m_object[RENDER_FURNITURE]->SetModelID(pBg->furnitureIndex);//SetModelID(MODEL_FREEZE_AUD); //Milo 01-17
m_pScene->m_object[RENDER_COIN]->SetModelID(MODEL_COIN);
m_pScene->m_object[RENDER_TV]->SetModelID(MODEL_TV);
m_pScene->m_object[RENDER_GRABBING_TENPIN]->SetModelID(MODEL_GRBBING);
m_pScene->m_object[RENDER_SETTING_TENPIN]->SetModelID(MODEL_SETTING_PINS);
//optional
m_pScene->m_object[RENDER_FIRST_AUDIENCE]->SetModelID(MODEL_AUD1);
m_pScene->m_object[RENDER_SECOND_AUDIENCE]->SetModelID(MODEL_AUD2);
m_pScene->m_object[RENDER_THIRD_AUDIENCE]->SetModelID(MODEL_AUD3);
//
m_pScene->m_object[RENDER_SCENE]->SetHideProperty(false);
m_pScene->m_object[RENDER_FLOOR]->SetHideProperty(false);
m_pScene->m_object[RENDER_FREEZE_AUDIENCE]->SetHideProperty(false);
m_pScene->m_object[RENDER_FURNITURE]->SetHideProperty(false);
}
++m_step;
}
else if(m_step == 3)
{
m_pMatch->SetMatchType(MATCH_TYPE_VS);
m_StoryModeState=SMS_LEVEL_MATCH;
++m_step;
}
break;
default:
break;
}
}
//// process match loop, which base on the state variable m_MatchState
void CGame::UpdateMatch()
{
boolean key=m_pEngine->GetInput()->KeyPressed(VKEY_MENU_NEXT|VKEY_MENU_SELECT|VKEY_MENU_CLR);
switch(m_MatchState)
{
case MS_MATCH_INIT:
matchInit();
break;
case MS_QUICK_PRESHOW:
if(m_pEngine->GetInput()->KeyPressed(VKEY_MENU_SKIP | VKEY_MENU_CLR | gk_NUM5 | gk_MSOFT))
{
//for BUG that the player2 will show in VS COM MODE // Milo 03-04
m_pScene->m_object[RENDER_PLAYER2]->SetHideProperty(true);
////
m_MatchState=MS_DELIVERY_INIT;
break;
}
if(m_step>100)
{
//for BUG that the player2 will show in VS COM MODE // Milo 03-04
m_pScene->m_object[RENDER_PLAYER2]->SetHideProperty(true);
////
m_MatchState=MS_DELIVERY_INIT;
break;
}
m_step++;
//if( FOV_CAMERA_VIEW - m_step*6 > FOV_OTHERS )
{
int fov = m_pScene->m_render3D.GetG3d()->getZDist();
if( fov > FOV_FORWARD+36 )
m_pScene->m_render3D.GetG3d()->setZDist( fov - 5 );
else if( fov > FOV_FORWARD+18 )
m_pScene->m_render3D.GetG3d()->setZDist( fov - 4 );
else if( fov > FOV_FORWARD+8 )
m_pScene->m_render3D.GetG3d()->setZDist( fov - 3 );
else if( fov > FOV_FORWARD )
m_pScene->m_render3D.GetG3d()->setZDist( fov - 2 );
}
m_pScene->m_cCamera->UpdateCamera();
break;
case MS_DELIVERY_INIT:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -