Changeset 9941 for code/trunk/src/orxonox
- Timestamp:
- Dec 29, 2013, 8:06:44 PM (11 years ago)
- Location:
- code/trunk/src/orxonox/gametypes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
r9667 r9941 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/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r9667 r9941 33 33 #include "infos/PlayerInfo.h" 34 34 #include "worldentities/pawns/Pawn.h" 35 #include "core/config/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"; -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
r9667 r9941 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/trunk/src/orxonox/gametypes/TeamGametype.cc
r9667 r9941 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 190 int TeamGametype::getTeamSize(int team) 191 { 192 int teamSize = 0; 193 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 194 { 195 if (it->second == team) 196 teamSize++; 197 } 198 return teamSize; 199 } 200 201 int TeamGametype::getHumansInTeam(int team) 202 { 203 int teamSize = 0; 204 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 205 { 206 if (it->second == team && it->first->isHumanPlayer()) 207 teamSize++; 208 } 209 return teamSize; 210 } 211 212 175 213 SpawnPoint* TeamGametype::getBestSpawnPoint(PlayerInfo* player) const 176 214 { … … 336 374 } 337 375 376 void TeamGametype::announceTeamWin(int winnerTeam) 377 { 378 for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3) 379 { 380 if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 381 continue; 382 if (it3->second == winnerTeam) 383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID()); 385 } 386 else 387 { 388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID()); 389 } 390 } 391 } 392 338 393 } -
code/trunk/src/orxonox/gametypes/TeamGametype.h
r9667 r9941 62 62 inline const ColourValue& getTeamColour(int teamnr) const 63 63 { return this->teamcolours_[teamnr]; } 64 int getTeamScore(PlayerInfo* player); 65 int getTeamSize(int team); 66 int getHumansInTeam(int team); 64 67 65 68 protected: … … 77 80 void setDefaultObjectColour(Pawn* pawn); 78 81 void colourPawn(Pawn* pawn, int teamNr); 82 void announceTeamWin(int winnerTeam); 83 79 84 }; 80 85 } -
code/trunk/src/orxonox/gametypes/UnderAttack.cc
r9667 r9941 38 38 namespace orxonox 39 39 { 40 const int attacker_ = 0; // teamnumber of the attacking team 41 const int defender_ = 1; // defender's teamnumber 42 40 43 RegisterUnloadableClass(UnderAttack); 41 44 … … 76 79 continue; 77 80 78 if (it->second == 0)81 if (it->second == attacker_) 79 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 80 83 else … … 188 191 } 189 192 } 193 194 void UnderAttack::playerEntered(PlayerInfo* player) 195 { 196 if (!player) 197 return; 198 TeamDeathmatch::playerEntered(player); 199 this->setTransporterHealth(); 200 } 201 202 void UnderAttack::setTransporterHealth() 203 { 204 if (this->destroyer_ != 0) 205 { 206 //Calculation: Each attacker deals about 3500 damage. A human attacker deals 1500 damage additionally. 207 //Each defender prevents 500 damage. If human 2000 damage will be additionally be prevented. 208 //TODO: use gametime and the damage dealt so far in order to calculate the transporter's life more precisely 209 float health = this->getTeamSize(attacker_)*2000.0f + this->getHumansInTeam(attacker_)*3000.0f - this->getTeamSize(defender_)*500.0f - this->getHumansInTeam(defender_)*2000.0f ; 210 this->destroyer_->setHealth(std::max(health, 5000.0f)); //the destoyer should have at least 5000.0f life. 211 } 212 } 213 214 190 215 } -
code/trunk/src/orxonox/gametypes/UnderAttack.h
r9667 r9941 51 51 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); 52 52 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); 53 virtual void playerEntered(PlayerInfo* player); 53 54 54 55 protected: 55 56 virtual void killedDestroyer(); 57 void setTransporterHealth(); 56 58 57 59 WeakPtr<Destroyer> destroyer_;
Note: See TracChangeset
for help on using the changeset viewer.