本文整理汇总了C++中PlayerManager::updateAll方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerManager::updateAll方法的具体用法?C++ PlayerManager::updateAll怎么用?C++ PlayerManager::updateAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerManager
的用法示例。
在下文中一共展示了PlayerManager::updateAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doTurn
//.........这里部分代码省略.........
for(std::set<uint32_t>::iterator itob = vis.begin(); itob != vis.end(); ++itob){
ObjectView* obv = playerview->getObjectView(*itob);
if(obv == NULL){
if(objectmanager->getObject(*itob)->isAlive()){
obv = new ObjectView();
obv->setObjectId(*itob);
obv->setCompletelyVisible(true);
playerview->addVisibleObject(obv);
}
objectmanager->doneWithObject(*itob);
}else{
IGObject* ro = objectmanager->getObject(*itob);
uint64_t obmt = ro->getModTime();
objectmanager->doneWithObject(*itob);
if(obmt > obv->getModTime()){
obv->setModTime(obmt);
playerview->updateObjectView(*itob);
}
}
}
// remove dead objects
std::set<uint32_t> goneobjects;
std::set<uint32_t> knownobjects = playerview->getVisibleObjects();
set_difference(knownobjects.begin(), knownobjects.end(), vis.begin(), vis.end(), inserter(goneobjects, goneobjects.begin()));
for(std::set<uint32_t>::iterator itob = goneobjects.begin(); itob != goneobjects.end(); ++itob){
ObjectView* obv = playerview->getObjectView(*itob);
if(!obv->isGone()){
obv->setGone(true);
playerview->updateObjectView(*itob);
}
}
//Replace colonist fleets
int fleets = 0;
IGObject* homePlanet;
for(std::set<uint32_t>::iterator itob = objects.begin(); itob != objects.end(); ++itob){
IGObject * ob = objectmanager->getObject(*itob);
if(ob->getName().compare("Colonist Fleet") == 0) {
uint32_t owner = ((OwnedObject*)(ob->getObjectBehaviour()))->getOwner(); if(owner == *itplayer) {
fleets++;
}
}
if(ob->getName().compare(string(player->getName() + "'s Home Planet")) == 0) {
homePlanet = ob;
}
}
for(int i = fleets; i < 6; i++) {
IGObject* fleet = fleetBuilder->createFleet(FleetBuilder::PASSENGER_FLEET, FleetBuilder::RANDOM_SHIP, player, homePlanet, "Colonist Fleet");
game->getObjectManager()->addObject(fleet);
ObjectView* obv = new ObjectView();
obv->setObjectId(fleet->getID());
obv->setCompletelyVisible(true);
player->getPlayerView()->addVisibleObject(obv);
}
//Send end of turn message to each player
Message * msg = new Message();
msg->setSubject("Turn complete");
stringstream out;
out << "Your Current Score: \n";
out << "Money: " << player->getScore(1) << "\n";
out << "Technology: " << player->getScore(2) << "\n";
out << "People: " << player->getScore(3) << "\n";
out << "Raw Materials: " << player->getScore(4) << "\n";
out << "Alien Artifacts: " << player->getScore(5);
msg->setBody(out.str());
player->postToBoard(msg);
//Alert players to the turn order for next round
msg = new Message();
msg->setSubject("Turn Order");
string body = "The order for the next turn is: ";
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();
}
body += playermanager->getPlayer(*itcurr)->getName();
body += " ";
itcurr++;
}
msg->setBody(body);
player->postToBoard(msg);
}
//Initialize combat if the next turn is a combat turn
if(combat) {
initCombat();
}
playermanager->updateAll();
}
示例2: doCombatTurn
//.........这里部分代码省略.........
}
for(std::set<uint32_t>::iterator itplayer = players.begin(); itplayer != players.end(); ++itplayer){
Player* player = playermanager->getPlayer(*itplayer);
PlayerView* playerview = player->getPlayerView();
//Update visibility
for(std::set<ObjectView*>::iterator i = views.begin(); i != views.end(); ++i) {
playerview->addVisibleObject(*i);
}
for(std::set<uint32_t>::iterator itob = vis.begin(); itob != vis.end(); ++itob){
ObjectView* obv = playerview->getObjectView(*itob);
if(obv == NULL){
if(objectmanager->getObject(*itob)->isAlive()){
obv = new ObjectView();
obv->setObjectId(*itob);
obv->setCompletelyVisible(true);
playerview->addVisibleObject(obv);
}
objectmanager->doneWithObject(*itob);
}else{
IGObject* ro = objectmanager->getObject(*itob);
uint64_t obmt = ro->getModTime();
objectmanager->doneWithObject(*itob);
if(obmt > obv->getModTime()){
obv->setModTime(obmt);
playerview->updateObjectView(*itob);
}
}
}
// remove dead objects
std::set<uint32_t> goneobjects;
std::set<uint32_t> knownobjects = playerview->getVisibleObjects();
set_difference(knownobjects.begin(), knownobjects.end(), vis.begin(), vis.end(), inserter(goneobjects, goneobjects.begin()));
for(std::set<uint32_t>::iterator itob = goneobjects.begin(); itob != goneobjects.end(); ++itob){
ObjectView* obv = playerview->getObjectView(*itob);
if(!obv->isGone()){
obv->setGone(true);
playerview->updateObjectView(*itob);
}
}
//Replace colonist fleets
int fleets = 0;
IGObject* homePlanet;
for(std::set<uint32_t>::iterator itob = objects.begin(); itob != objects.end(); ++itob){
IGObject * ob = objectmanager->getObject(*itob);
if(ob->getName().compare("Colonist Fleet") == 0) {
uint32_t owner = ((OwnedObject*)(ob->getObjectBehaviour()))->getOwner(); if(owner == *itplayer) {
fleets++;
}
}
if(ob->getName().compare(string(player->getName() + "'s Home Planet")) == 0) {
homePlanet = ob;
}
}
for(int i = fleets; i < 6; i++) {
IGObject* fleet = fleetBuilder->createFleet(FleetBuilder::PASSENGER_FLEET, FleetBuilder::RANDOM_SHIP, player, homePlanet, "Colonist Fleet");
game->getObjectManager()->addObject(fleet);
ObjectView* obv = new ObjectView();
obv->setObjectId(fleet->getID());
obv->setCompletelyVisible(true);
player->getPlayerView()->addVisibleObject(obv);
}
//Send end of turn message to each player
Message * msg = new Message();
msg->setSubject("Combat Complete!");
stringstream out;
Player* win = playermanager->getPlayer(winner);
out << win->getName() << " has won the battle with a strength of ";
out << strength[winner] << "!";
msg->setBody(out.str());
player->postToBoard(msg);
msg = new Message();
msg->setSubject("Turn complete");
stringstream out2;
out2 << "Your Current Score: \n";
out2 << "Money: " << player->getScore(1) << "\n";
out2 << "Technology: " << player->getScore(2) << "\n";
out2 << "People: " << player->getScore(3) << "\n";
out2 << "Raw Materials: " << player->getScore(4) << "\n";
out2 << "Alien Artifacts: " << player->getScore(5);
msg->setBody(out2.str());
player->postToBoard(msg);
}
if(combat) {
initCombat();
}
playermanager->updateAll();
}