本文整理汇总了C++中PlayerEntity::getMode方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerEntity::getMode方法的具体用法?C++ PlayerEntity::getMode怎么用?C++ PlayerEntity::getMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerEntity
的用法示例。
在下文中一共展示了PlayerEntity::getMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPlayers
/**
Designer: Jeff Bayntun, Eric Tsang
Coder: Jeff Bayntun, Sanders Lee (Added code for getting player type)
* @brief ServerGameScene::createPlayers
* Creates all the vessels and deitys, this includes hooking them up
* across the network.
*/
void ServerGameScene::createPlayers()
{
std::map<Session*, PlayerEntity*> players = command->getGameState()->getPlayers();
PlayerEntity* currPlayer;
Session* currSession;
PLAYER_MODE mode;
PLAYER_TYPE type;
int vesselNo = 0;
int vesselX = 0;
int vesselY = 0;
// make ServerNetworkController for each vessel
for(auto it = players.begin(); it != players.end(); ++it)
{
currPlayer = it->second;
currSession = it->first;
mode = currPlayer->getMode();
type = currPlayer->getType();
currPlayer->setSGameScene(this);
currPlayer->setVessel(NULL);
switch(mode)
{
case PLAYER_MODE::VESSEL:
{
// create the controller, and bind it with the player
ServerNetworkController* cont = new ServerNetworkController();
currPlayer->setController(cont);
// register the vessel controller with all clients
EnemyControllerInit initData;
switch(type)
{
case PLAYER_TYPE::WARRIOR:
initData.type = ENTITY_TYPES::VESSEL_WARRIOR;
break;
case PLAYER_TYPE::SHAMAN:
initData.type = ENTITY_TYPES::VESSEL_SHAMAN;
break;
}
gMap->getVesselPosition(vesselNo++, &vesselX, &vesselY);
initData.x = (float) vesselX;
initData.y = (float) vesselY;
Message msg;
msg.data = (void*) &initData;
msg.len = sizeof(initData);
// create vessel, pass it server vessel controller too
Vessel* e = static_cast<Vessel*>(EntityFactory::getInstance()->makeEntityFromNetworkMessage(cMap,&msg,cont));
currPlayer->setVessel(e);
e->setPlayerEntity(currPlayer);
//Add player entities to the list of players
playerList.push_back(e);
// register the server controller with the player
msg.type = (int) ServerNetworkControllerClientNetworkControllerMsgType::FOLLOW_ME;
cont->registerSession(currSession,msg);
// register the server controller with clients
msg.type = (int) ServerNetworkControllerClientNetworkControllerMsgType::NORMAL;
command->getGameState()->registerWithAllPlayers(cont,&msg);
break;
}
case PLAYER_MODE::GHOST:
{
break;
}
case PLAYER_MODE::DEITY:
{
//SeverDeityController* deityController = new DeityController();
//p->setController(deityController);
//create deity, pass it controller too.
break;
}
}
}
}