Changeset 7542 for code/branches/lastmanstanding/src
- Timestamp:
- Oct 14, 2010, 11:02:57 PM (14 years ago)
- Location:
- code/branches/lastmanstanding/src/orxonox/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
r7485 r7542 48 48 } 49 49 50 void LastManStanding::spawnDeadPlayersIfRequested() 51 { 52 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 53 if (it->second.state_ == PlayerState::Dead) 54 { 55 bool alive = (0<playerLives_[it->first]); 56 if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_)) 57 this->spawnPlayer(it->first); 58 } 59 } 60 61 50 62 void LastManStanding::setConfigValues() 51 63 { … … 66 78 bool LastManStanding::allowPawnDeath(Pawn* victim, Pawn* originator) 67 79 { 68 if (!victim )// only for safety80 if (!victim||!victim->getPlayer())// only for safety 69 81 return true; 70 playerLives_[victim->getPlayer()] --;71 if ( !playerLives_[victim->getPlayer()])//if player lost all lives82 playerLives_[victim->getPlayer()]=playerLives_[victim->getPlayer()]-1; 83 if (playerLives_[victim->getPlayer()]<=0)//if player lost all lives 72 84 { 73 85 this->playersAlive--; … … 183 195 if(!player) 184 196 return; 185 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 197 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);//!!!!!!!!!!! 186 198 if (it != this->players_.end()) 187 199 { … … 189 201 it->second.killed_++; 190 202 191 playerLives_[player] --;//-----------datapart192 if ( !playerLives_[player])//if player lost all lives203 playerLives_[player]=playerLives_[player]-1;//-----------datapart 204 if (playerLives_[player]<=0)//if player lost all lives 193 205 { 194 206 this->playersAlive--; 195 const std::string& message = player->getName() + " has lost all lives";207 const std::string& message = player->getName() + " is out"; 196 208 COUT(0) << message << std::endl; 197 209 Host::Broadcast(message); 198 210 } 211 this->timeToAct_[player]=timeRemaining+3.0f;//reset timer 199 212 } 200 213 } … … 215 228 if (it->second<0.0f) 216 229 { 217 it->second=timeRemaining+3.0f; 218 this->killPlayer(it->first); 230 it->second=timeRemaining+3.0f;//reset timer 231 if (playerGetLives(it->first)>0) 232 this->killPlayer(it->first); 219 233 } 220 234 } … … 222 236 } 223 237 224 void LastManStanding::spawnDeadPlayersIfRequested()225 {226 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)227 if (it->second.state_ == PlayerState::Dead)228 {229 bool alive = (0<playerLives_[it->first]);230 if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))231 this->spawnPlayer(it->first);232 }233 }234 235 238 } -
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
r7485 r7542 60 60 float timeRemaining; //!< Each player has a certain time where he or she has to hit an opponent or will be punished. 61 61 std::map<PlayerInfo*, float> timeToAct_; //!< Each player's time till she/he will be punished is stored here. 62 virtual void spawnDeadPlayersIfRequested(); 62 virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn 63 63 64 64 public: … … 67 67 void setConfigValues(); //!< Makes values configurable. 68 68 69 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an oppone t, his punishment countdown will be resetted.70 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each lives.69 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponent, his punishment countdown will be resetted. 70 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives. 71 71 72 72 virtual void start(); //!< Sends a start message. … … 78 78 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 79 79 80 const int playerGetLives(PlayerInfo* player); 81 void killPlayer(PlayerInfo* player); 82 void tick (float dt); //used to end the game80 const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_" 81 void killPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining". 82 void tick (float dt); //!< used to end the game 83 83 }; 84 84 }
Note: See TracChangeset
for help on using the changeset viewer.