- Timestamp:
- Apr 8, 2009, 12:58:47 AM (15 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc
r2907 r2908 36 36 #include "core/ConfigValueIncludes.h" 37 37 #include "core/Template.h" 38 #include "core/ GameMode.h"38 #include "core/Core.h" 39 39 #include "overlays/OverlayGroup.h" 40 40 #include "objects/infos/PlayerInfo.h" … … 44 44 #include "objects/worldentities/Camera.h" 45 45 46 #include "network/Host.h" 47 46 48 namespace orxonox 47 49 { … … 64 66 this->setConfigValues(); 65 67 68 this->addBots(this->numberOfBots_); 69 66 70 // load the corresponding score board 67 if ( GameMode::showsGraphics() && this->scoreboardTemplate_ != "")71 if (Core::showsGraphics() && this->scoreboardTemplate_ != "") 68 72 { 69 73 this->scoreboard_ = new OverlayGroup(this); … … 101 105 void Gametype::start() 102 106 { 103 this->addBots(this->numberOfBots_); 104 107 COUT(0) << "game started" << std::endl; 105 108 this->gtinfo_.bStarted_ = true; 106 109 … … 110 113 void Gametype::end() 111 114 { 115 COUT(0) << "game ended" << std::endl; 112 116 this->gtinfo_.bEnded_ = true; 113 117 } … … 116 120 { 117 121 this->players_[player].state_ = PlayerState::Joined; 118 } 119 120 bool Gametype::playerLeft(PlayerInfo* player) 122 123 std::string message = player->getName() + " entered the game"; 124 COUT(0) << message << std::endl; 125 Host::Broadcast(message); 126 } 127 128 void Gametype::playerLeft(PlayerInfo* player) 121 129 { 122 130 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); … … 124 132 { 125 133 this->players_.erase(it); 126 return true; 127 } 128 return false; 134 135 std::string message = player->getName() + " left the game"; 136 COUT(0) << message << std::endl; 137 Host::Broadcast(message); 138 } 129 139 } 130 140 … … 137 147 } 138 148 139 boolGametype::playerChangedName(PlayerInfo* player)149 void Gametype::playerChangedName(PlayerInfo* player) 140 150 { 141 151 if (this->players_.find(player) != this->players_.end()) … … 143 153 if (player->getName() != player->getOldName()) 144 154 { 145 return true; 146 } 147 } 148 return false; 155 std::string message = player->getOldName() + " changed name to " + player->getName(); 156 COUT(0) << message << std::endl; 157 Host::Broadcast(message); 158 } 159 } 149 160 } 150 161 … … 157 168 } 158 169 159 void Gametype::playerPreSpawn(PlayerInfo* player)160 {161 }162 163 void Gametype::playerPostSpawn(PlayerInfo* player)164 {165 }166 167 void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)168 {169 }170 171 void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)172 {173 }174 175 bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)176 {177 return true;178 }179 180 bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)181 {182 return true;183 }184 185 bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)186 {187 return true;188 }189 190 170 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 191 171 { 172 if (victim && victim->getPlayer()) 173 { 174 std::string message; 175 if (killer) 176 { 177 if (killer->getPlayer()) 178 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 179 else 180 message = victim->getPlayer()->getName() + " was killed"; 181 } 182 else 183 message = victim->getPlayer()->getName() + " died"; 184 185 COUT(0) << message << std::endl; 186 Host::Broadcast(message); 187 } 188 192 189 if (victim && victim->getPlayer()) 193 190 { … … 201 198 if (killer) 202 199 { 203 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer()); 204 if (it != this->players_.end()) 205 it->second.frags_++; 200 std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer()); 201 if (itKiller != this->players_.end()) 202 { 203 this->playerScored(itKiller->second); 204 } 205 else 206 COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl; 206 207 } 207 208 … … 224 225 } 225 226 226 void Gametype::playerScored(PlayerInfo* player) 227 { 228 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 229 if (it != this->players_.end()) 230 it->second.frags_++; 231 } 232 233 int Gametype::getScore(PlayerInfo* player) const 234 { 235 std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player); 236 if (it != this->players_.end()) 237 return it->second.frags_; 238 else 239 return 0; 227 void Gametype::playerScored(Player& player) 228 { 229 player.frags_++; 240 230 } 241 231 … … 346 336 if (spawnpoint) 347 337 { 348 this->playerPreSpawn(player);349 338 player->startControl(spawnpoint->spawn()); 350 339 this->players_[player].state_ = PlayerState::Alive; 351 this->playerPostSpawn(player);352 340 } 353 341 else … … 361 349 { 362 350 for (unsigned int i = 0; i < amount; ++i) 363 this->botclass_.fabricate(this);351 new Bot(this); 364 352 } 365 353
Note: See TracChangeset
for help on using the changeset viewer.