本文整理汇总了C++中Level::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Level::GetId方法的具体用法?C++ Level::GetId怎么用?C++ Level::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level::GetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLevelById
Level* WorldBuilder::GetLevelById(int id)
{
for(int i = 0; i < (int)this->m_levels.size(); i++)
{
Level* level = this->m_levels.at(i);
if(level != NULL && (level->GetId() == id))
{
return level;
}
}
return NULL;
}
示例2: Intersects
bool PoolCue::Intersects()
{
Level* pLevel = LevelServer::Instance()->GetCurrentLevel().GetPtr();
// Get end points of cue
m_v1 = GetBall()->GetOrientation()->GetVertex();
// Offset this end of the cue to the cue contact pos.
// TODO
float yr = Engine::Instance()->GetGameState()->GetCurrentPlayerInfo()->m_golfStroke.m_yRot;
m_v2 = m_v1;
// Get endpoint of cue - use elev and yr.
// NB Length is not critical
float len = 20.0f;
// Get (x, z);
m_v2.x -= len * sin(DegToRad(yr));
m_v2.z -= len * cos(DegToRad(yr));
float elev = Engine::Instance()->GetGameState()->GetCurrentPlayerInfo()->m_golfStroke.m_cueElevationDegs;
m_v2.y += len * sin(DegToRad(elev));
// Radius of pool cue capsule
float radius = 0.2f; // A rough radius of the cue section
bool intersectsScene = pLevel->GetScene()->LineIntersects(m_v1, m_v2, radius);
if (intersectsScene)
{
return true;
}
// Test ball intersection - ignore cue ball
int levelId = pLevel->GetId();
int roomId = pLevel->GetRoomId();
GameObjectMap& objs = Engine::Instance()->GetGameObjects(levelId, roomId);
// Iterate through map of Game Objects.
for (GameObjectMap::iterator it = objs.begin(); it != objs.end(); ++it)
{
PPoolGameObject pGo = it->second;
PoolBall* pBall = dynamic_cast<PoolBall*>(pGo.GetPtr());
if (pBall && !IsCueBall(pBall))
{
// Test ball-capsule intersection
if (pBall->GetBoundingSphere()->Intersects(m_v1, m_v2, radius))
{
#ifdef CUE_DEBUG
std::cout << "CUE INTERSECTS BALL: " << pBall->GetId() << "\n";
#endif
return true;
}
}
}
return false;
}
示例3: SetStateToSnapshot
void PoolSnapshot::SetStateToSnapshot() const
{
// Set the state of all game objects we have stored.
for (unsigned int i = 0; i < m_objInfo.size(); i++)
{
const ObjInfo& info = m_objInfo[i];
#ifdef UNDO_DEBUG
if (info.m_pGo->GetId() == 10)
{
std::cout << "** UNDO: Restoring cue ball: pos is: "
<< ToString(info.m_or)
<< "\n";
}
else // NB NOT #else
{
std::cout << "** UNDO: Restoring obj: " << info.m_pGo->GetId()
<< " (" << info.m_pGo->GetTypeName()
<< ") or: "
<< ToString(info.m_or) << "\n";
}
#endif
info.m_pGo->SetOrientation(info.m_or);
info.m_pGo->SetState(info.m_state);
}
for (unsigned int i = 0; i < m_playerInfo.size(); i++)
{
Engine::Instance()->GetGameState()->SetPlayerInfo(i, m_playerInfo[i]);
}
// Set Rules state
Level* pLevel = LevelServer::Instance()->GetCurrentLevel().GetPtr();
//Rules* pRules = GetRules(pLevel);
//int id = pRules->GetId();
// This was an attempt to assign the object into the one held by the Engine.
// This won't work - it just assigns to the local variable!
//*pRules = *(m_pRules.GetPtr());
// Replace the Rules object held by the Engine with this new object.
Engine::Instance()->HoldGameObject(pLevel->GetId(), pLevel->GetRoomId(),
m_pRules.GetPtr());
}
示例4: CreateFromCurrentState
void PoolSnapshot::CreateFromCurrentState()
{
// Get the state of all game objects in the current room.
Level* pLevel = LevelServer::Instance()->GetCurrentLevel().GetPtr();
int levelId = pLevel->GetId();
int roomId = pLevel->GetRoomId();
GameObjectMap& objs = Engine::Instance()->GetGameObjects(levelId, roomId);
// Iterate through map of Game Objects.
for (GameObjectMap::iterator it = objs.begin(); it != objs.end(); ++it)
{
PPoolGameObject pGo = it->second;
Assert(pGo.GetPtr());
#ifdef UNDO_DEBUG
if (gameObjId == 10)
std::cout << "** UNDO: Storing cue ball: pos is "
<< ToString(*(pGo->GetOrientation()))
<< "\n";
#endif
ObjInfo info;
info.m_pGo = pGo;
if (pGo->GetOrientation())
{
info.m_or = *(pGo->GetOrientation());
}
info.m_state = pGo->GetState();
m_objInfo.push_back(info);
}
// No of ball spotted by each player
int numPlayers = Engine::Instance()->GetGameState()->GetNumberOfPlayers();
for (int i = 0; i < numPlayers; i++)
{
m_playerInfo.push_back(
*(Engine::Instance()->GetGameState()->GetPlayerInfo(i)));
}
// Store the state of the Rules - like is this a free ball, can the
// ball be placed anywhere, etc.
m_pRules = GetRules(pLevel)->Clone();
}