Changeset ce2bb87 in network-game for common/Game.cpp
- Timestamp:
- Dec 20, 2013, 3:42:30 AM (11 years ago)
- Branches:
- master
- Children:
- b73bc28
- Parents:
- 6c9bcdd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
r6c9bcdd rce2bb87 1 1 #include "Game.h" 2 3 #include "Common.h" 2 4 3 5 using namespace std; … … 112 114 } 113 115 116 // returns the id of the picked-up flag or -1 if none was picked up 117 int Game::processFlagPickupRequest(Player* p) { 118 vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects(); 119 vector<WorldMap::Object>::iterator it; 120 int playerId = -1; 121 122 for (it = vctObjects->begin(); it != vctObjects->end(); it++) { 123 if (posDistance(p->pos, it->pos.toFloat()) < 10) { 124 switch (it->type) { 125 case WorldMap::OBJECT_BLUE_FLAG: 126 if (p->team == 1) { 127 p->hasBlueFlag = true; 128 playerId = it->id; 129 } 130 break; 131 case WorldMap::OBJECT_RED_FLAG: 132 if (p->team == 0) { 133 p->hasRedFlag = true; 134 playerId = it->id; 135 } 136 break; 137 } 138 139 if (playerId > -1) { 140 vctObjects->erase(it); 141 return playerId; 142 } 143 } 144 } 145 146 return playerId; 147 } 148 114 149 void Game::setRedScore(int score) { 115 150 this->redScore = score;
Note:
See TracChangeset
for help on using the changeset viewer.