Changeset 6848 for code/branches/dynamicmatch/src
- Timestamp:
- May 3, 2010, 4:57:54 PM (15 years ago)
- Location:
- code/branches/dynamicmatch/src/orxonox/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc
r6812 r6848 56 56 #include "items/Engine.h" 57 57 #include "tools/Timer.h" 58 #include "worldentities/TeamSpawnPoint.h" 58 59 59 60 namespace orxonox … … 99 100 } 100 101 101 bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator) //tested - works fine102 bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator) 102 103 { 103 104 if (!originator||!victim) … … 113 114 114 115 numberOf[target]--; //decrease numberof victims's party 115 const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);116 116 playerParty_[victim->getPlayer()]=piggy; //victim's new party: pig 117 117 setPlayerColour(victim->getPlayer()); //victim's new colour 118 118 numberOf[piggy]++; //party switch: number of players is not affected (decrease and increase) 119 const std::string& message1 = std::string(" Pig") + multi_cast<std::string>(numberOf[piggy]); COUT(0) << message1 << std::endl; Host::Broadcast(message1);120 119 if (notEnoughKillers) //reward the originator 121 120 { 122 121 numberOf[source]--; //decrease numberof originator's party 123 const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);124 122 playerParty_[originator->getPlayer()]=killer; //originator's new party: killer 125 123 setPlayerColour(originator->getPlayer()); //originator's new colour 126 124 numberOf[killer]++; 127 const std::string& message2 = std::string(" Killers ") + multi_cast<std::string>(numberOf[killer]); COUT(0) << message2 << std::endl; Host::Broadcast(message2);128 125 } 129 126 evaluatePlayerParties(); //check if the party change has to trigger futher party changes … … 137 134 new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true); 138 135 } 139 std::string message5("First victim.");// for testing purposes140 COUT(0) << message5 << std::endl;141 Host::Broadcast(message5);142 136 } 143 137 … … 149 143 setPlayerColour(victim->getPlayer()); //victim colour 150 144 numberOf[killer]++; //party switch: number of players is not affected (decrease and increase) 151 const std::string& message = std::string(" Killers ") + multi_cast<std::string>(numberOf[killer]); COUT(0) << message << std::endl; Host::Broadcast(message);152 145 evaluatePlayerParties(); //check if the party change has to trigger futher party changes 153 146 } … … 159 152 setPlayerColour(victim->getPlayer()); //victim colour 160 153 numberOf[chaser]++; //party switch: number of players is not affected (decrease and increase) 161 const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);162 154 evaluatePlayerParties(); //check if the party change has to trigger futher party changes 163 155 } … … 184 176 playerParty_[victim->getPlayer()]=piggy; 185 177 playerParty_[originator->getPlayer()]=chaser; 186 //announce187 const std::string& messageVictim = victim->getPlayer()->getName() + " is victim";188 COUT(0) << messageVictim << std::endl;189 Host::Broadcast(messageVictim);190 178 191 179 //party switch -> colour switch … … 203 191 204 192 } 205 // TODO:killer vs piggy193 // killer vs piggy 206 194 else if (source==killer &&target==piggy) //party and colour switch 207 195 { … … 260 248 return; 261 249 playerParty_[player]=chaser; //Set playerparty 262 numberOf[chaser]++; const std::string& message = std::string(" Chasers ") + multi_cast<std::string>(numberOf[chaser]); COUT(0) << message << std::endl; Host::Broadcast(message);250 numberOf[chaser]++; 263 251 Gametype::playerEntered(player); 264 252 const std::string& message6 = player->getName() + " entered the game"; … … 290 278 } 291 279 292 293 294 295 280 296 281 void Dynamicmatch::tick(float dt) 297 282 { 298 SUPER(Dynamicmatch, tick, dt); //TODO - was bedeutet diese Zeile283 SUPER(Dynamicmatch, tick, dt); 299 284 300 285 if (this->hasStarted() && !gameEnded_) … … 336 321 { 337 322 //durch alle Spieler iterieren 323 /*std::string message("Game started!"); 324 COUT(0) << message << std::endl; 325 Host::Broadcast(message);*/ 338 326 // allen Spielern mit der Pig-party frags++ 339 327 ; … … 369 357 //chasers: there are more chasers than killers + pigs 370 358 if (numberOf[piggy]+numberOf[killer] > numberOf[chaser]) {notEnoughChasers=true;} 371 else {notEnoughChasers=false; const std::string& message = "Players Evaluated";COUT(0) << message << std::endl; Host::Broadcast(message);} 372 const std::string& messagetest = multi_cast<std::string>(numberOf[piggy]+numberOf[chaser]+numberOf[killer]) + " players!"; 373 COUT(0) << messagetest << std::endl; Host::Broadcast(messagetest); 359 else {notEnoughChasers=false;} 374 360 } 375 361 … … 440 426 COUT(0) << message << std::endl; 441 427 Host::Broadcast(message); 442 /*for (std::map<PlayerInfo*, int>::iterator it = this-> teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)428 /*for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 443 429 { 444 430 if (it->first->getClientID() == CLIENTID_UNKNOWN) … … 451 437 }*/ 452 438 } 439 SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const 440 { 441 int desiredTeamNr = -1; 442 std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player); 443 if (it_player != this->playerParty_.end()) 444 desiredTeamNr = it_player->second; 445 446 // Only use spawnpoints of the own team (or non-team-spawnpoints) 447 std::set<SpawnPoint*> teamSpawnPoints = this->spawnpoints_; 448 for (std::set<SpawnPoint*>::iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ) 449 { 450 if ((*it)->isA(Class(TeamSpawnPoint))) 451 { 452 TeamSpawnPoint* tsp = orxonox_cast<TeamSpawnPoint*>(*it); 453 if (tsp && static_cast<int>(tsp->getTeamNumber()) != desiredTeamNr)//getTeamNumber!! 454 { 455 teamSpawnPoints.erase(it++); 456 continue; 457 } 458 } 459 460 ++it; 461 } 462 463 if (teamSpawnPoints.size() > 0) 464 { 465 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 466 unsigned int index = 0; 467 for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it) 468 { 469 if (index == randomspawn) 470 return (*it); 471 472 ++index; 473 } 474 } 475 476 return 0; 477 } 453 478 454 479 } -
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h
r6812 r6848 64 64 void resetSpeedFactor(WeakPtr<Engine>* ptr); 65 65 void tick (float dt);// used to end the game 66 //three different parties TODO const machen! 66 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; 67 //three different parties 67 68 int chaser; 68 69 int piggy; … … 78 79 unsigned int numberOf[3]; //array to count number of chasers, pigs, killers 79 80 float pointsPerTime; 80 float gameTime_; // from UnderAttack better: use gametype interface!!!81 float gameTime_; // from UnderAttack 81 82 bool gameEnded_; // true if game is over 82 83 int timesequence_; //used for countdown
Note: See TracChangeset
for help on using the changeset viewer.