Changeset 2495 for code/branches/presentation/src/orxonox/objects
- Timestamp:
- Dec 17, 2008, 4:05:25 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc
r2494 r2495 35 35 #include "core/CoreIncludes.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "core/Loader.h" 38 #include "core/XMLFile.h" 37 #include "core/Template.h" 38 #include "core/Core.h" 39 #include "overlays/OverlayGroup.h" 39 40 #include "objects/infos/PlayerInfo.h" 40 41 #include "objects/infos/Bot.h" … … 68 69 this->addBots(this->numberOfBots_); 69 70 70 this->statsOverlay_ = 0;71 72 71 setConfigValues(); 73 72 74 73 // load the corresponding score board 75 //this->statsOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/" + this->statsOverlayName_); 76 //Loader::open(statsOverlay_); 77 //this->setGametype(this); 74 if (Core::showsGraphics() && this->scoreboardTemplate_ != "") 75 { 76 this->scoreboard_ = new OverlayGroup(this); 77 this->scoreboard_->addTemplate(this->scoreboardTemplate_); 78 this->scoreboard_->setGametype(this); 79 } 80 else 81 this->scoreboard_ = 0; 78 82 } 79 83 … … 84 88 SetConfigValue(bForceSpawn_, false); 85 89 SetConfigValue(numberOfBots_, 0); 86 SetConfigValue(s tatsOverlayName_, "stats.oxo");90 SetConfigValue(scoreboardTemplate_, "defaultScoreboard"); 87 91 } 88 92 … … 118 122 void Gametype::playerEntered(PlayerInfo* player) 119 123 { 120 this->players_[player] = PlayerState::Joined;124 this->players_[player].state_ = PlayerState::Joined; 121 125 122 126 std::string message = player->getName() + " entered the game"; … … 127 131 void Gametype::playerLeft(PlayerInfo* player) 128 132 { 129 std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.find(player);133 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 130 134 if (it != this->players_.end()) 131 135 { … … 188 192 if (victim && victim->getPlayer()) 189 193 { 190 std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.find(victim->getPlayer());194 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(victim->getPlayer()); 191 195 if (it != this->players_.end()) 192 196 { 193 it->second = PlayerState::Dead; 197 it->second.state_ = PlayerState::Dead; 198 it->second.killed_++; 199 200 // Reward killer 201 if (killer) 202 { 203 std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer()); 204 if (itKiller != this->players_.end()) 205 { 206 this->playerScored(itKiller->second); 207 } 208 else 209 COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl; 210 } 194 211 195 212 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); … … 211 228 } 212 229 213 void Gametype::playerScored(PlayerInfo* player) 214 { 230 void Gametype::playerScored(Player& player) 231 { 232 player.frags_++; 215 233 } 216 234 … … 234 252 void Gametype::assignDefaultPawnsIfNeeded() 235 253 { 236 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)254 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 237 255 { 238 256 if (!it->first->getControllableEntity()) 239 257 { 240 it->second = PlayerState::Dead;258 it->second.state_ = PlayerState::Dead; 241 259 242 260 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) … … 249 267 spawn->spawn(entity); 250 268 it->first->startControl(entity); 251 it->second = PlayerState::Dead;269 it->second.state_ = PlayerState::Dead; 252 270 } 253 271 else … … 284 302 bool allplayersready = true; 285 303 bool hashumanplayers = false; 286 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)304 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 287 305 { 288 306 if (!it->first->isReadyToSpawn()) … … 303 321 void Gametype::spawnPlayersIfRequested() 304 322 { 305 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)323 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 306 324 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 307 325 this->spawnPlayer(it->first); … … 310 328 void Gametype::spawnDeadPlayersIfRequested() 311 329 { 312 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)313 if (it->second == PlayerState::Dead)330 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 331 if (it->second.state_ == PlayerState::Dead) 314 332 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 315 333 this->spawnPlayer(it->first); … … 322 340 { 323 341 player->startControl(spawnpoint->spawn()); 324 this->players_[player] = PlayerState::Alive;342 this->players_[player].state_ = PlayerState::Alive; 325 343 } 326 344 else -
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.h
r2492 r2495 53 53 } 54 54 55 struct Player 56 { 57 PlayerInfo* info_; 58 PlayerState::Enum state_; 59 int frags_; 60 int killed_; 61 }; 62 55 63 class _OrxonoxExport Gametype : public BaseObject, public Tickable 56 64 { 57 65 friend class PlayerInfo; 58 friend class ClassIdentifier<Gametype>;59 66 60 67 public: … … 82 89 virtual void playerChangedName(PlayerInfo* player); 83 90 84 virtual void playerScored(Player Info*player);91 virtual void playerScored(Player& player); 85 92 86 93 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); … … 88 95 virtual void pawnPostSpawn(Pawn* pawn); 89 96 90 inline const std::map<PlayerInfo*, Player State::Enum>& getPlayers() const97 inline const std::map<PlayerInfo*, Player>& getPlayers() const 91 98 { return this->players_; } 92 99 … … 104 111 inline unsigned int getNumberOfPlayers() const 105 112 { return this->players_.size(); } 106 107 inline std::string getPlayersName() const108 { return "StatsBot77"; }109 110 inline unsigned int getPlayersFrags() const111 { return 123; }112 113 113 114 private: … … 131 132 unsigned int numberOfBots_; 132 133 133 std::map<PlayerInfo*, Player State::Enum> players_;134 std::map<PlayerInfo*, Player> players_; 134 135 std::set<SpawnPoint*> spawnpoints_; 135 136 SubclassIdentifier<ControllableEntity> defaultControllableEntity_; 136 137 137 XMLFile* statsOverlay_;138 OverlayGroup* scoreboard_; 138 139 139 140 // Config Values 140 std::string s tatsOverlayName_;141 std::string scoreboardTemplate_; 141 142 }; 142 143 }
Note: See TracChangeset
for help on using the changeset viewer.