Changeset 6921
- Timestamp:
- May 17, 2010, 5:01:54 PM (15 years ago)
- Location:
- code/branches/dynamicmatch/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dynamicmatch/src/modules/overlays/hud/CMakeLists.txt
r5781 r6921 13 13 UnderAttackHealthBar.cc 14 14 TeamBaseMatchScore.cc 15 GametypeStaticMessage.cc 16 GametypeFadingMessage.cc 15 17 ) -
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc
r6848 r6921 26 26 * 27 27 */ 28 //TODO: killers integrieren ; ArtificialController anpassen);28 //TODO: 29 29 //pig punkte vergeben pro Zeit! 30 30 //killerfarbe schwarz; evtl. eigenes Raumfahrzeug; … … 81 81 this->tutorial=true; 82 82 this->pointsPerTime=0.0f; 83 this->setHUDTemplate("DynamicmatchHUD"); 84 83 85 } 84 86 … … 101 103 102 104 bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator) 103 { 105 { //TODO: static and fading message for the "human" player's 104 106 if (!originator||!victim) 105 {return false;} 107 return false; 108 if (!!originator->getPlayer()||!victim->getPlayer()) 109 return false; 106 110 if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ?? 107 111 { … … 112 116 if (notEnoughPigs) 113 117 { 114 115 118 numberOf[target]--; //decrease numberof victims's party 116 119 playerParty_[victim->getPlayer()]=piggy; //victim's new party: pig 117 120 setPlayerColour(victim->getPlayer()); //victim's new colour 118 121 numberOf[piggy]++; //party switch: number of players is not affected (decrease and increase) 122 if(tutorial) //announce party switch 123 { 124 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer()); 125 if (it2 != this->players_.end()) 126 { 127 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it2->first->getClientID()); 128 } 129 } 119 130 if (notEnoughKillers) //reward the originator 120 131 { … … 123 134 setPlayerColour(originator->getPlayer()); //originator's new colour 124 135 numberOf[killer]++; 136 if(tutorial) //announce party switch 137 { 138 std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer()); 139 if (it3 != this->players_.end()) 140 { 141 this->gtinfo_->sendStaticMessage("Take the chasers down.",it3->first->getClientID()); 142 } 143 } 125 144 } 126 145 evaluatePlayerParties(); //check if the party change has to trigger futher party changes … … 143 162 setPlayerColour(victim->getPlayer()); //victim colour 144 163 numberOf[killer]++; //party switch: number of players is not affected (decrease and increase) 164 if(tutorial) //announce party switch 165 { 166 std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer()); 167 if (it3 != this->players_.end()) 168 { 169 this->gtinfo_->sendStaticMessage("Take the chasers down.",it3->first->getClientID()); 170 } 171 } 145 172 evaluatePlayerParties(); //check if the party change has to trigger futher party changes 146 173 } … … 152 179 setPlayerColour(victim->getPlayer()); //victim colour 153 180 numberOf[chaser]++; //party switch: number of players is not affected (decrease and increase) 181 if(tutorial) //announce party switch 182 { 183 std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer()); 184 if (it3 != this->players_.end()) 185 { 186 if (numberOf[killer]>0) 187 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it3->first->getClientID()); 188 else 189 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it3->first->getClientID()); 190 } 191 } 154 192 evaluatePlayerParties(); //check if the party change has to trigger futher party changes 155 193 } … … 180 218 setPlayerColour(victim->getPlayer()); //victim colour 181 219 setPlayerColour(originator->getPlayer());//originator colour 182 220 221 //Announce pary switch 222 if(tutorial) 223 { 224 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer()); 225 if (it != this->players_.end()) 226 { 227 if (numberOf[killer]>0) 228 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID()); 229 else 230 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID()); 231 } 232 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer()); 233 if (it2 != this->players_.end()) 234 { 235 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it2->first->getClientID()); 236 } 237 } 183 238 //Give new pig boost 184 239 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim); … … 199 254 setPlayerColour(victim->getPlayer()); //victim colour 200 255 setPlayerColour(originator->getPlayer()); //originator colour 256 257 if(tutorial) //Announce pary switch 258 { 259 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer()); 260 if (it != this->players_.end()) 261 { 262 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID()); 263 } 264 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer()); 265 if (it2 != this->players_.end()) 266 { 267 this->gtinfo_->sendStaticMessage("Take the chasers down.",it2->first->getClientID()); 268 } 269 } 201 270 } 202 271 //Case: friendly fire … … 286 355 { pointsPerTime =pointsPerTime + dt; 287 356 gameTime_ = gameTime_ - dt; 288 if (pointsPerTime > 5)357 if (pointsPerTime > 3.0f)//hard coded!! should be changed 289 358 { 290 359 pointsPerTime=0.0f; 291 360 rewardPig(); 292 361 } 293 362 if (gameTime_<= 0) … … 320 389 void Dynamicmatch::rewardPig() 321 390 { 322 //durch alle Spieler iterieren 323 /*std::string message("Game started!"); 324 COUT(0) << message << std::endl; 325 Host::Broadcast(message);*/ 326 // allen Spielern mit der Pig-party frags++ 327 ; 391 for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden 392 { 393 if (it->second==piggy) 394 { 395 //Spieler mit der Pig-party frags++ 396 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first);// still not sure if right syntax 397 if (it2 != this->players_.end()) 398 { 399 it2->second.frags_++; 400 } 401 } 402 } 328 403 } 329 404 void Dynamicmatch::setPlayerColour(PlayerInfo* player) // sets a players colour … … 333 408 if (pawn) 334 409 { 335 pawn->setRadarObjectColour(this->partyColours_[it_player->second]); //does this work? //what about playerParty_[it_player] instead of it_player->second410 pawn->setRadarObjectColour(this->partyColours_[it_player->second]); 336 411 337 412 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); … … 350 425 { 351 426 //pigs: 1 + every 6th player is a pig 352 if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy]) {notEnoughPigs=true;} 353 else {notEnoughPigs=false;} 427 if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy]) 428 { 429 notEnoughPigs=true; 430 if (tutorial) // Announce selectionphase 431 { 432 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 433 { 434 if (!it->first)//in order to catch nullpointer 435 continue; 436 if (it->first->getClientID() == CLIENTID_UNKNOWN) 437 continue; 438 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID()); 439 } 440 } 441 } 442 else 443 { 444 notEnoughPigs=false; 445 if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over 446 { 447 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 448 { 449 if (!it->first)//in order to catch nullpointer 450 continue; 451 if (it->first->getClientID() == CLIENTID_UNKNOWN) 452 continue; 453 else if (it->second==chaser) 454 { 455 if (numberOf[killer]>0) 456 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID()); 457 else 458 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID()); 459 } 460 else if (it->second==piggy) 461 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID()); 462 else if (it->second==killer) 463 this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID()); 464 } 465 466 } 467 } 354 468 //killers: every 4th player is a killer 355 if (getNumberOfPlayers()/4 > numberOf[killer]) {notEnoughKillers=true;} 356 else {notEnoughKillers=false;} 469 if (getNumberOfPlayers()/4 > numberOf[killer]) 470 { 471 notEnoughKillers=true; 472 if (tutorial) // Announce selectionphase 473 { 474 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 475 { 476 if (!it->first)//in order to catch nullpointer 477 continue; 478 if (it->first->getClientID() == CLIENTID_UNKNOWN) 479 continue; 480 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID()); 481 } 482 } 483 } 484 else 485 { 486 notEnoughKillers=false; 487 if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over 488 { 489 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 490 { 491 if (!it->first) 492 continue; 493 if (it->first->getClientID() == CLIENTID_UNKNOWN) 494 continue; 495 else if (it->second==chaser) 496 { 497 if (numberOf[killer]>0) 498 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID()); 499 else 500 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID()); 501 } 502 else if (it->second==piggy) 503 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID()); 504 else if (it->second==killer) 505 this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID()); 506 } 507 508 } 509 510 } 357 511 //chasers: there are more chasers than killers + pigs 358 if (numberOf[piggy]+numberOf[killer] > numberOf[chaser]) {notEnoughChasers=true;} 359 else {notEnoughChasers=false;} 512 if (numberOf[piggy]+numberOf[killer] > numberOf[chaser]) 513 { 514 notEnoughChasers=true; 515 if (tutorial) // Announce selectionphase 516 { 517 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 518 { 519 if (!it->first)//in order to catch nullpointer 520 continue; 521 if (it->first->getClientID() == CLIENTID_UNKNOWN) 522 continue; 523 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID()); 524 } 525 } 526 } 527 else 528 { 529 notEnoughChasers=false; 530 if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over 531 { 532 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 533 { 534 if (!it->first) 535 continue; 536 if (it->first->getClientID() == CLIENTID_UNKNOWN) 537 continue; 538 else if (it->second==chaser) 539 { 540 if (numberOf[killer]>0) 541 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID()); 542 else 543 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID()); 544 } 545 else if (it->second==piggy) 546 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID()); 547 else if (it->second==killer) 548 this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID()); 549 } 550 551 } 552 } 360 553 } 361 554 … … 392 585 if(!tutorial) 393 586 { 394 std::string message(" Gamestarted!");587 std::string message("Dynamicmatch started!"); 395 588 COUT(0) << message << std::endl; 396 589 Host::Broadcast(message); 397 590 } 398 else if(tutorial) //in order to explain how this gametype works briefly 399 { 400 std::string tutotrialmessage("Shoot at other players as long as every player is red.\n\nIf you are fast enough you're spaceship will become green.\n\nIf you are hit you'll become blue."); 401 COUT(0) << tutotrialmessage << std::endl; 402 Host::Broadcast(tutotrialmessage); 403 callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::instructions, this))); 591 else if(tutorial) // Announce selectionphase 592 { 593 for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) 594 { 595 if (it->first->getClientID() == CLIENTID_UNKNOWN) 596 continue; 597 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID()); 598 } 404 599 } 405 600 } 406 601 407 void Dynamicmatch::instructions()602 /*void Dynamicmatch::instructions() 408 603 { 409 604 std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!"); … … 418 613 COUT(0) << message << std::endl; 419 614 Host::Broadcast(message); 420 } 615 }*/ 421 616 void Dynamicmatch::end() 422 617 { -
code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h
r6848 r6921 47 47 bool notEnoughKillers; 48 48 bool notEnoughChasers; 49 50 //three different parties 51 int chaser; 52 int piggy; 53 int killer; 54 49 55 virtual void evaluatePlayerParties(); 50 56 int getParty(PlayerInfo* player); 51 57 void setPlayerColour(PlayerInfo* player);//own function 52 58 void setConfigValues();//done 59 60 bool friendlyfire; //goal: player can switch it on/off 61 bool tutorial; //goal: new players recieve messages how the new gametype works - later it can be switched off. 62 53 63 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //ok - score function and management of parties 54 64 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //ok - simple … … 59 69 virtual bool playerLeft(PlayerInfo* player); 60 70 virtual bool playerChangedName(PlayerInfo* player);//unchanged 61 virtual void instructions(); 62 virtual void furtherInstructions(); 71 72 /*virtual void instructions(); 73 virtual void furtherInstructions();*/ 63 74 virtual void rewardPig(); 64 75 void resetSpeedFactor(WeakPtr<Engine>* ptr); 65 76 void tick (float dt);// used to end the game 66 77 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; 67 //three different parties 68 int chaser; 69 int piggy; 70 int killer; 71 72 bool friendlyfire; //goal: player can switch it on/off 73 bool tutorial; //goal: new players recieve messages how the new gametype works - later it can be switched off. 78 74 79 protected: 75 76 80 77 81 std::map< PlayerInfo*, int > playerParty_; //player's parties are recorded here 78 82 std::vector<ColourValue> partyColours_; //aus TeamDeathmatch … … 82 86 bool gameEnded_; // true if game is over 83 87 int timesequence_; //used for countdown 84 Timer callInstructions_;88 //Timer callInstructions_; 85 89 }; 86 90 } -
code/branches/dynamicmatch/src/orxonox/infos/GametypeInfo.cc
r5781 r6921 42 42 registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage); 43 43 registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage); 44 registerMemberNetworkFunction(GametypeInfo, dispatchStaticMessage); 45 registerMemberNetworkFunction(GametypeInfo, dispatchFadingMessage); 44 46 45 47 GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator) … … 110 112 } 111 113 114 void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID) 115 { 116 if (GameMode::isMaster()) 117 { 118 if (clientID == CLIENTID_SERVER) 119 this->dispatchStaticMessage(message); 120 else 121 callMemberNetworkFunction(GametypeInfo, dispatchStaticMessage, this->getObjectID(), clientID, message); 122 } 123 } 124 125 void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID) 126 { 127 if (GameMode::isMaster()) 128 { 129 if (clientID == CLIENTID_SERVER) 130 this->dispatchFadingMessage(message); 131 else 132 callMemberNetworkFunction(GametypeInfo, dispatchFadingMessage, this->getObjectID(), clientID, message); 133 } 134 } 135 112 136 void GametypeInfo::dispatchAnnounceMessage(const std::string& message) 113 137 { … … 127 151 it->deathmessage(this, message); 128 152 } 153 154 void GametypeInfo::dispatchStaticMessage(const std::string& message) 155 { 156 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) 157 it->staticmessage(this, message); 158 } 159 160 void GametypeInfo::dispatchFadingMessage(const std::string& message) 161 { 162 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) 163 it->fadingmessage(this, message); 164 } 129 165 } -
code/branches/dynamicmatch/src/orxonox/infos/GametypeInfo.h
r5781 r6921 64 64 void sendKillMessage(const std::string& message, unsigned int clientID); 65 65 void sendDeathMessage(const std::string& message, unsigned int clientID); 66 void sendStaticMessage(const std::string& message, unsigned int clientID); 67 void sendFadingMessage(const std::string& message, unsigned int clientID); 66 68 67 69 void dispatchAnnounceMessage(const std::string& message); 68 70 void dispatchKillMessage(const std::string& message); 69 71 void dispatchDeathMessage(const std::string& message); 72 void dispatchStaticMessage(const std::string& message); 73 void dispatchFadingMessage(const std::string& message); 70 74 71 75 private: -
code/branches/dynamicmatch/src/orxonox/interfaces/GametypeMessageListener.h
r5781 r6921 44 44 virtual void killmessage(const GametypeInfo* gtinfo, const std::string& message) {} 45 45 virtual void deathmessage(const GametypeInfo* gtinfo, const std::string& message) {} 46 virtual void staticmessage(const GametypeInfo* gtinfo, const std::string& message) {} 47 virtual void fadingmessage(const GametypeInfo* gtinfo, const std::string& message) {} 46 48 }; 47 49 }
Note: See TracChangeset
for help on using the changeset viewer.