Changeset 9348 for code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
- Timestamp:
- Aug 30, 2012, 11:08:17 PM (12 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r8858 r9348 31 31 //Low; Codeoptimierung und Dokumentation 32 32 33 /* 34 short gaming manual: 35 There are three different parties a player can belong to: victim, chaser or killer 36 Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them. 37 In order to win you have to earn as much points as possible: 38 - as victim by escaping the chasers 39 - as chaser by shooting the victim 40 - as killer by killing the chasers 41 42 43 What you shouldn't do is shooting at players of your own party. By doing so your score will decrease. 44 P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser. 33 /** 34 @brief 35 Short Gaming Manual: 36 There are three different parties a player can belong to: victim, chaser or killer 37 Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them. 38 In order to win you have to earn as much points as possible: 39 - as victim by escaping the chasers 40 - as chaser by shooting the victim 41 - as killer by killing the chasers 42 43 44 What you shouldn't do is shooting at players of your own party. By doing so your score will decrease. 45 P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser. 45 46 */ 46 47 #include "Dynamicmatch.h" … … 81 82 this->numberOf[killer]=0; 82 83 this->tutorial=true; 83 this->pointsPerTime= 0.0f;84 this->pointsPerTime=1.0f; 84 85 this->setHUDTemplate("DynamicmatchHUD"); 85 86 } … … 95 96 ColourValue(0.3f, 0.3f, 1.0f), //piggycolour 96 97 ColourValue(0.3f, 1.0f, 0.3f) //killercolour what about black: 0.0f, 0.0f, 0.0f 97 98 98 }; 99 99 static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue)); … … 111 111 if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ?? 112 112 { 113 int target= playerParty_[victim->getPlayer()];114 int source= playerParty_[originator->getPlayer()];113 int target = playerParty_[victim->getPlayer()]; 114 int source = playerParty_[originator->getPlayer()]; 115 115 116 116 //Case: Not Enough Pigs: party change (= party management) … … 151 151 152 152 //Give new pig boost 153 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);153 SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim); 154 154 this->grantPigBoost(spaceship); 155 155 } … … 245 245 } 246 246 //Give new pig boost 247 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);247 SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim); 248 248 this->grantPigBoost(spaceship); 249 249 } … … 276 276 else if (friendlyfire && (source == target)) 277 277 { 278 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer()); 279 if (it != this->players_.end()) 280 { 281 it->second.frags_--; 282 } 283 } 284 }// from far far away not to be removed! 278 this->playerScored(originator->getPlayer(), -1); 279 } 280 } 285 281 return false; //default: no damage 286 282 } … … 296 292 if (playerParty_[originator->getPlayer()] == killer) //reward the killer 297 293 { 298 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer()); 299 if (it != this->players_.end()) 300 { 301 it->second.frags_+=20; //value must be tested 302 } 303 } 304 return true; 294 this->playerScored(originator->getPlayer(), 25); 295 } 296 return true; 305 297 } 306 298 else return false; … … 309 301 /** 310 302 @brief 311 Grant the piggya boost.303 Grant the victim a boost. 312 304 @param spaceship 313 305 The SpaceShip to give the boost. … … 315 307 void Dynamicmatch::grantPigBoost(SpaceShip* spaceship) 316 308 { 317 // Give pigboost309 // Give victim boost 318 310 if (spaceship) 319 311 { 312 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship); 313 if(ptr == NULL) 314 return; 320 315 spaceship->addSpeedFactor(5); 321 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);322 316 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 323 317 executor->setDefaultValue(0, ptr); … … 374 368 375 369 if (this->hasStarted() && !gameEnded_) 376 { pointsPerTime =pointsPerTime + dt; 377 gameTime_ = gameTime_ - dt; 378 if (pointsPerTime > 2.0f)//hard coded!! should be changed 379 { 380 pointsPerTime=0.0f; 370 { 371 pointsPerTime = pointsPerTime + dt; //increase points 372 gameTime_ = gameTime_ - dt; // decrease game time 373 if (pointsPerTime > 2.0f) //hard coded points for victim! should be changed 374 { 375 pointsPerTime = 0.0f; 381 376 rewardPig(); 382 377 } … … 408 403 } 409 404 405 /** 406 @brief The reward function is called every 2 seconds via the tick function and makes the victim score points. 407 */ 410 408 void Dynamicmatch::rewardPig() 411 409 { 412 410 for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden 413 411 { 414 if (it->second==piggy) 415 { 416 //Spieler mit der Pig-party frags++ 417 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first);// still not sure if right syntax 418 if (it2 != this->players_.end()) 419 { 420 it2->second.frags_++; 421 } 412 if (it->second==piggy)//Spieler mit der Pig-party frags++ 413 { 414 this->playerScored(it->first); 422 415 } 423 416 } … … 426 419 { 427 420 std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player); 428 Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());421 Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity()); 429 422 if (pawn) 430 423 { … … 446 439 { 447 440 //pigs: 1 + every 6th player is a pig 448 if ( (1 +this->getNumberOfPlayers()/6) > numberOf[piggy])441 if ( (1 + getPlayerCount()/6) > numberOf[piggy]) 449 442 { 450 443 notEnoughPigs=true; … … 495 488 } 496 489 //killers: every 4th player is a killer 497 if ( getNumberOfPlayers()/4> numberOf[killer])490 if ( static_cast<unsigned int>(getPlayerCount()/4) > numberOf[killer]) 498 491 { 499 492 notEnoughKillers=true;
Note: See TracChangeset
for help on using the changeset viewer.