本文整理汇总了C++中Game函数的典型用法代码示例。如果您正苦于以下问题:C++ Game函数的具体用法?C++ Game怎么用?C++ Game使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Game函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Game
/************************************************************************
* 游戏剧情的章节转换
************************************************************************/
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();
}
示例2: GameServer
bool CGameWindow::KeyPress(int c)
{
if (BaseClass::KeyPress(c))
return true;
if (GameServer() && GameServer()->GetCamera())
GameServer()->GetCamera()->KeyDown(c);
if (Game())
{
for (size_t i = 0; i < Game()->GetNumLocalPlayers(); i++)
{
CPlayer* pPlayer = Game()->GetLocalPlayer(i);
pPlayer->KeyPress(c);
}
}
return false;
}
示例3: Game
void CGameServer::SetClientNickname(int iClient, const tstring& sNickname)
{
if (iClient == GetClientIndex() && Game()->GetNumLocalPlayers())
{
Game()->GetLocalPlayer(0)->SetPlayerName(sNickname);
return;
}
for (size_t i = 0; i < Game()->GetNumPlayers(); i++)
{
if (Game()->GetPlayer(i)->GetClient() == iClient)
{
Game()->GetPlayer(i)->SetPlayerName(sNickname);
return;
}
}
TMsg(sprintf(tstring("Can't find client %d to give nickname %s.\n"), iClient, sNickname.c_str()));
}
示例4: SetLoading
void CGameServer::RestartLevel()
{
SetLoading(false);
AllowPrecaches();
DestroyAllEntities(tvector<tstring>(), true);
m_bRestartLevel = true;
Game()->SetupGame(CVar::GetCVarValue("game_mode"));
m_bRestartLevel = false;
SetLoading(false);
}
示例5: GetRenderer
void CGame::Load()
{
m_iMonsterTexture = GetRenderer()->LoadTextureIntoGL("monster.png");
m_iCrateTexture = GetRenderer()->LoadTextureIntoGL("crate.png");
m_iNormalTexture = GetRenderer()->LoadTextureIntoGL("normal.png");
GraphReset();
m_projectile_initial_time = Game()->GetTime();
m_projectile_initial_position = Vector(2, 1, 2);
m_projectile_initial_velocity = Vector(-1, 3, -1) * 5;
m_projectile_gravity = Vector(0, -5, 0);
m_projectile_break_time = Game()->GetTime() + PredictProjectileMaximumHeightTime(m_projectile_initial_velocity, m_projectile_gravity);
m_projectile_number = 1;
// Fire the first one
m_projectile_position[0] = m_projectile_initial_position;
m_projectile_velocity[0] = m_projectile_initial_velocity;
}
示例6: SKGraph
Game RoxdokuGame::createGame(int difficulty, int symmetry) {
if(!m_graph) {
m_graph = new SKGraph(m_order, TypeRoxdoku);
m_graph->initRoxdoku();
}
Puzzle* puzzle = new Puzzle(m_graph, true);
puzzle->init(difficulty, symmetry);
return Game(puzzle);
}
示例7: GameServer
bool CGameServer::LoadFromFile(const tchar* pFileName)
{
if (!GameServer())
return false;
GameServer()->Initialize();
// Erase all existing entites. We're going to load in new ones!
GameServer()->DestroyAllEntities();
std::ifstream i;
i.open(pFileName, std::ios_base::binary|std::ios_base::in);
char szTag[8];
i.read(szTag, 8);
if (strncmp(szTag, "GameSave", 8) != 0)
return false;
CGameServer* pGameServer = GameServer();
size_t iLoadCRC;
i.read((char*)&iLoadCRC, sizeof(iLoadCRC));
if (iLoadCRC != pGameServer->m_iSaveCRC)
return false;
i.read((char*)&pGameServer->m_flGameTime, sizeof(pGameServer->m_flGameTime));
size_t iEntities;
i.read((char*)&iEntities, sizeof(iEntities));
for (size_t j = 0; j < iEntities; j++)
{
if (!CBaseEntity::UnserializeEntity(i))
return false;
}
for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
{
if (!CBaseEntity::GetEntity(i))
continue;
CBaseEntity::GetEntity(i)->ClientEnterGame();
}
Game()->EnterGame();
if (GameServer()->GetWorkListener())
GameServer()->GetWorkListener()->SetAction("Encountering resistance", 0);
GameServer()->SetLoading(false);
return true;
}
示例8: getGameInfo
void COverlappedWindow::startNewGame() {
getGameInfo().isFirstNextStep = true;
setWindowSize();
game = Game(getGameInfo().widthGridNumber, getGameInfo().heightGridNumber);
isGameStarted = true;
isDoneFirstStep = false;
::InvalidateRect(handle, 0, 0);
}
示例9: DeleteHelperItems
void CUIMpTradeWnd::OnBtnOkClicked(CUIWindow* w, void* d)
{
DeleteHelperItems();
CheckDragItemToDestroy ();
StorePreset (_preset_idx_last, true, false, false);
HideDialog ();
game_cl_mp* clgame = smart_cast<game_cl_mp*>(&(Game()));
VERIFY(clgame);
clgame->OnBuyMenu_Ok ();
//. StorePreset (_preset_idx_last, true, true);
}
示例10: CanAccelerate
bool CActor::CanSprint ()
{
bool can_Sprint = CanAccelerate() && !conditions().IsCantSprint() &&
Game().PlayerCanSprint(this)
&& CanRun()
&& !(mstate_real&mcLStrafe || mstate_real&mcRStrafe)
&& InventoryAllowSprint()
;
return can_Sprint;
}
示例11:
int game_cl_Deathmatch::GetPlayersPlace (game_PlayerState* ps)
{
if (!ps) return -1;
game_cl_GameState::PLAYERS_MAP_IT I=Game().players.begin();
game_cl_GameState::PLAYERS_MAP_IT E=Game().players.end();
// create temporary map (sort by kills)
xr_vector<game_PlayerState*> Players;
for (;I!=E;++I) Players.push_back(I->second);
std::sort (Players.begin(),Players.end(),DM_Compare_Players);
int Place = 1;
for (u32 i=0; i<Players.size(); i++)
{
if (Players[i] == ps)
return Place;
Place++;
};
return -1;
}
示例12: Game
s32 UITeamState::GetSummaryFrags() const
{
typedef game_cl_GameState::PLAYERS_MAP::const_iterator PlCIter;
game_cl_GameState::PLAYERS_MAP & playersMap = Game().players;
s32 sum = 0;
PlCIter eiter = playersMap.end();
for (PlCIter i = playersMap.begin(); i != eiter; ++i)
{
game_PlayerState* ps = i->second;
if (!ps)
continue;
game_cl_mp* tempGame = smart_cast<game_cl_mp*>(&Game());
R_ASSERT(tempGame);
if (static_cast<ETeam>(tempGame->ModifyTeam(ps->team)) == myTeam)
sum = sum + ps->m_iRivalKills;
}
return sum;
}
示例13: Game
/*
===============
idCommonLocal::NetReceiveUsercmds
===============
*/
void idCommonLocal::NetReceiveUsercmds( int peer, idBitMsg& msg )
{
int clientNum = Game()->MapPeerToClient( peer );
if( clientNum == -1 )
{
idLib::Warning( "NetReceiveUsercmds: Could not find client for peer %d", peer );
return;
}
NetReadUsercmds( clientNum, msg );
}
示例14: WinMain
int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/ )
{
#ifndef NDEBUG
int flag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); /* Get current flag */
flag ^= _CRTDBG_LEAK_CHECK_DF; /* Turn on leak-checking bit */
_CrtSetDbgFlag( flag ); /* Set flag to the new value */
#endif
Game();
return 0;
}
示例15: ShowStatus
void ShowStatus(class CCommand* pCommand, tvector<tstring>& asTokens, const tstring& sCommand)
{
TMsg(tstring("Level: ") + CVar::GetCVarValue("game_level") + "\n");
TMsg(sprintf(tstring("Clients: %d Entities: %d/%d\n"), GameNetwork()->GetClientsConnected(), CBaseEntity::GetNumEntities(), GameServer()->GetMaxEntities()));
for (size_t i = 0; i < Game()->GetNumPlayers(); i++)
{
const CPlayer* pPlayer = Game()->GetPlayer(i);
if (!pPlayer)
continue;
if (pPlayer->GetClient() < 0)
TMsg("Local: ");
else
TMsg(sprintf(tstring("%d: "), pPlayer->GetClient()));
TMsg(pPlayer->GetPlayerName());
TMsg("\n");
}
}