本文整理汇总了C++中PlayerManager::getNumPlayers方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerManager::getNumPlayers方法的具体用法?C++ PlayerManager::getNumPlayers怎么用?C++ PlayerManager::getNumPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerManager
的用法示例。
在下文中一共展示了PlayerManager::getNumPlayers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doTurn
void TaeTurn::doTurn(){
//check to make sure the game is still ging and this is not a combat turn
if(isGameOver) {
gameOver();
return;
} else if(combat) {
doCombatTurn();
return;
}
std::set<uint32_t>::iterator itcurr;
Game* game = Game::getGame();
OrderManager* ordermanager = game->getOrderManager();
ObjectManager* objectmanager = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
PlayerManager* playermanager = game->getPlayerManager();
//build map for storing orders
std::map<uint32_t, std::list<IGObject*> > playerOrders;
containerids.clear();
//separate orders by player
std::set<uint32_t> objects = objectmanager->getAllIds();
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject * ob = objectmanager->getObject(*itcurr);
if(ob->getType() == planettype || ob->getType() == fleettype){
OrderQueueObjectParam* oqop = dynamic_cast<OrderQueueObjectParam*>(ob->getParameterByType(obpT_Order_Queue));
if(oqop != NULL){
OrderQueue* orderqueue = ordermanager->getOrderQueue(oqop->getQueueId());
if(orderqueue != NULL){
Order * currOrder = orderqueue->getFirstOrder();
if(currOrder != NULL){
uint32_t owner = ((OwnedObject*)(ob->getObjectBehaviour()))->getOwner();
std::list<IGObject*>::iterator i = playerOrders[owner].end();
playerOrders[owner].insert(i, ob);
}
}
}
}
}
//Do orders for players in the correct order
//The order in which orders are processed is rotated each turn
std::set<uint32_t> players = playermanager->getAllIds();
itcurr = players.begin();
for(int i = 0; i < playerTurn; i++) {
itcurr++;
}
for(int it = 0; it < players.size(); it++) {
if(itcurr == players.end()) {
itcurr = players.begin();
}
if(playerOrders[*itcurr].size() > 0) {
for(std::list<IGObject*>::iterator i = playerOrders[*itcurr].begin(); i != playerOrders[*itcurr].end(); i++) {
OrderQueue* orderqueue = ordermanager->getOrderQueue(((OrderQueueObjectParam*)((*i)->getParameterByType(obpT_Order_Queue)))->getQueueId());
Order* currOrder = orderqueue->getFirstOrder();
if(currOrder!= NULL) {
if(currOrder->doOrder(*i)) {
orderqueue->removeFirstOrder();
} else {
orderqueue->updateFirstOrder();
}
}
if((*i)->getContainerType() >= 1){
containerids.insert((*i)->getID());
}
objectmanager->doneWithObject((*i)->getID());
}
}
itcurr++;
}
awardArtifacts();
//Check for end game condition of less than 3 artifacts remaining
objects = objectmanager->getAllIds();
int numArtifacts = 0;
for(itcurr = objects.begin(); itcurr != objects.end(); itcurr++) {
IGObject * ob = objectmanager->getObject(*itcurr);
if(ob->getType() == obtm->getObjectTypeByName("Planet")) {
Planet* p = (Planet*) ob->getObjectBehaviour();
if(p->getResource(3) > 0) {
numArtifacts++;
}
}
}
if(numArtifacts < 3) {
isGameOver = true;
gameOver();
return;
}
//Update which player's turn it is
playerTurn = (playerTurn + 1) % playermanager->getNumPlayers();
objectmanager->clearRemovedObjects();
// to once a turn
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
//.........这里部分代码省略.........