Changeset 9363 for code/branches
- Timestamp:
- Sep 2, 2012, 6:45:40 PM (12 years ago)
- Location:
- code/branches/release2012/src/orxonox/gametypes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/release2012/src/orxonox/gametypes/LastTeamStanding.cc
r9348 r9363 242 242 party = it2->second; 243 243 } 244 //if (party < 0) return; //if search failed244 if (party < 0) return; //if search failed 245 245 //victory message to all team members, loose message to everyone else 246 for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3) 247 { 248 if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 249 continue; 250 if (it3->second == party) 251 {this->gtinfo_->sendAnnounceMessage("You have won the match!", it3->first->getClientID());} 252 else 253 {this->gtinfo_->sendAnnounceMessage("You have lost the match!", it3->first->getClientID());} 254 } 246 this->announceTeamWin(party); 247 255 248 return; 256 249 } -
code/branches/release2012/src/orxonox/gametypes/TeamDeathmatch.cc
r9348 r9363 33 33 #include "infos/PlayerInfo.h" 34 34 #include "worldentities/pawns/Pawn.h" 35 #include "core/ConfigValueIncludes.h" 35 36 36 37 namespace orxonox … … 41 42 { 42 43 RegisterObject(TeamDeathmatch); 44 45 this->setConfigValues(); 46 } 47 48 void TeamDeathmatch::setConfigValues() 49 { 50 SetConfigValue(maxScore_, 10); 43 51 } 44 52 … … 57 65 std::string message("The match has ended."); 58 66 ChatManager::message(message); 67 68 //find team that won the match 69 int winnerTeam = 0; 70 int highestScore = 0; 71 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 72 { 73 if ( this->getTeamScore(it->first) > highestScore ) 74 { 75 winnerTeam = this->getTeam(it->first); 76 highestScore = this->getTeamScore(it->first); 77 } 78 } 79 80 //announce win 81 this->announceTeamWin(winnerTeam); 59 82 } 60 83 … … 100 123 { 101 124 if (killer->getPlayer()) 125 { 102 126 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 127 if(this->isExactlyA(Class(TeamDeathmatch)) && (this->getTeamScore(killer->getPlayer()) >= (this->maxScore_ -1)) ) 128 this->end(); 129 } 103 130 else 104 131 message = victim->getPlayer()->getName() + " was killed"; … … 109 136 ChatManager::message(message); 110 137 } 111 112 138 Gametype::pawnKilled(victim, killer); 113 139 } … … 121 147 const std::string& message = player->getName() + " scores!"; 122 148 ChatManager::message(message); 149 123 150 } 124 151 } -
code/branches/release2012/src/orxonox/gametypes/TeamDeathmatch.h
r9348 r9363 41 41 virtual ~TeamDeathmatch() {} 42 42 43 void setConfigValues(); 43 44 virtual void start(); 44 45 virtual void end(); … … 49 50 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 50 51 virtual void playerScored(PlayerInfo* player, int score = 1); 52 protected: 53 int maxScore_; 51 54 }; 52 55 } -
code/branches/release2012/src/orxonox/gametypes/TeamGametype.cc
r9348 r9363 173 173 } 174 174 175 int TeamGametype::getTeamScore(PlayerInfo* player) 176 { 177 int teamscore = 0; 178 if(!player || this->getTeam(player) == -1) 179 return 0; 180 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 181 { 182 if ( this->getTeam(it->first) == this->getTeam(player) ) 183 { 184 teamscore += it->second.frags_; 185 } 186 } 187 return teamscore; 188 } 189 175 190 SpawnPoint* TeamGametype::getBestSpawnPoint(PlayerInfo* player) const 176 191 { … … 336 351 } 337 352 353 void TeamGametype::announceTeamWin(int winnerTeam) 354 { 355 for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3) 356 { 357 if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 358 continue; 359 if (it3->second == winnerTeam) 360 { 361 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID()); 362 } 363 else 364 { 365 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID()); 366 } 367 } 368 } 369 338 370 } -
code/branches/release2012/src/orxonox/gametypes/TeamGametype.h
r9348 r9363 62 62 inline const ColourValue& getTeamColour(int teamnr) const 63 63 { return this->teamcolours_[teamnr]; } 64 int getTeamScore(PlayerInfo* player); 65 64 66 65 67 protected: … … 77 79 void setDefaultObjectColour(Pawn* pawn); 78 80 void colourPawn(Pawn* pawn, int teamNr); 81 void announceTeamWin(int winnerTeam); 82 79 83 }; 80 84 }
Note: See TracChangeset
for help on using the changeset viewer.