Changeset 9339 for code/branches/presentation2012merge
- Timestamp:
- Jul 30, 2012, 10:41:03 PM (12 years ago)
- Location:
- code/branches/presentation2012merge/src/orxonox/gametypes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/orxonox/gametypes/Dynamicmatch.cc
r9338 r9339 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; … … 342 334 numberOf[chaser]++; 343 335 Gametype::playerEntered(player); 336 orxout() << "# Players(2) : " << this->getNumberOfPlayers() <<endl; 337 orxout() << "# Players(3): " << this->getPlayerCount() <<endl; 344 338 const std::string& message = player->getName() + " entered the game"; 345 339 ChatManager::message(message); … … 361 355 //remove player from map 362 356 playerParty_.erase (player); 357 orxout() << "# Players(2) : " << this->getNumberOfPlayers() <<endl; 358 orxout() << "# Players(3): " << this->getPlayerCount() <<endl; 363 359 //adjust player parties 364 360 evaluatePlayerParties(); … … 375 371 if (this->hasStarted() && !gameEnded_) 376 372 { 377 orxout() << " number of chasers: " << numberOf[chaser] << endl;378 orxout() << " number of killers: " << numberOf[killer] << endl;379 orxout() << " number of victims: " << numberOf[piggy] << endl;380 373 pointsPerTime = pointsPerTime + dt; //increase points 381 374 gameTime_ = gameTime_ - dt; // decrease game time … … 419 412 for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden 420 413 { 421 if (it->second==piggy) 422 { 423 //Spieler mit der Pig-party frags++ 424 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first); 425 if (it2 != this->players_.end()) 426 { 427 it2->second.frags_++; 428 } 414 if (it->second==piggy)//Spieler mit der Pig-party frags++ 415 { 416 this->playerScored(it->first); 429 417 } 430 418 } … … 502 490 } 503 491 //killers: every 4th player is a killer 504 if (getPlayerCount()/4 > numberOf[killer])492 if (getPlayerCount()/4 > (int)numberOf[killer]) 505 493 { 506 494 notEnoughKillers=true; -
code/branches/presentation2012merge/src/orxonox/gametypes/Gametype.cc
r9261 r9339 183 183 this->players_[player].state_ = PlayerState::Joined; 184 184 this->gtinfo_->playerEntered(player); 185 orxout() << "# Players: " << this->getNumberOfPlayers() <<endl; 185 186 } 186 187 … … 191 192 { 192 193 this->players_.erase(it); 194 orxout() << "# Players: " << this->getNumberOfPlayers() <<endl; 193 195 return true; 194 196 } … … 301 303 } 302 304 303 void Gametype::playerScored(PlayerInfo* player )305 void Gametype::playerScored(PlayerInfo* player, int score) 304 306 { 305 307 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 306 308 if (it != this->players_.end()) 307 it->second.frags_ ++;309 it->second.frags_ += score; 308 310 } 309 311 -
code/branches/presentation2012merge/src/orxonox/gametypes/Gametype.h
r9260 r9339 90 90 virtual bool playerChangedName(PlayerInfo* player); 91 91 92 virtual void playerScored(PlayerInfo* player );92 virtual void playerScored(PlayerInfo* player, int score = 1); 93 93 94 94 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); … … 153 153 virtual void resetTimer(float t); 154 154 155 /** 156 @brief Get number of Players. 157 Note that only those players are counted that were added before the game started. 158 */ 155 159 inline unsigned int getNumberOfPlayers() const 156 160 { return this->gtinfo_->getNumberOfPlayers(); }
Note: See TracChangeset
for help on using the changeset viewer.