Changeset 7596 for code/branches/lastmanstanding/src/orxonox
- Timestamp:
- Oct 28, 2010, 12:05:01 AM (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
r7586 r7596 35 35 #include "core/ConfigValueIncludes.h" 36 36 #include "util/Convert.h" 37 37 //TODO: respawn delay 38 38 namespace orxonox 39 39 { … … 47 47 this->playersAlive=0; 48 48 this->timeRemaining=20.0f; 49 this->respawnDelay=4.0f; 49 50 this->setHUDTemplate("LastmanstandingHUD"); 50 51 } … … 55 56 if (it->second.state_ == PlayerState::Dead) 56 57 { 57 bool alive = (0<playerLives_[it->first] );58 bool alive = (0<playerLives_[it->first]&&(inGame_[it->first])); 58 59 if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_)) 60 { 59 61 this->spawnPlayer(it->first); 60 } 62 } 63 else if ((!inGame_[it->first])&&(0<playerLives_[it->first])) 64 { 65 if (it->first->getClientID()== CLIENTID_UNKNOWN) 66 return; 67 const std::string& message = "Respawn in " +multi_cast<std::string>(respawnDelay)+ " seconds." ; 68 this->gtinfo_->sendFadingMessage(message,it->first->getClientID()); 69 } 70 else if (0>=playerLives_[it->first]) 71 { 72 if (it->first->getClientID()== CLIENTID_UNKNOWN) 73 return; 74 const std::string& message2 = "You have lost all " +multi_cast<std::string>(lives)+ " lives." ; 75 this->gtinfo_->sendFadingMessage(message2,it->first->getClientID()); 76 } 77 } 61 78 } 62 79 … … 66 83 SetConfigValue(lives, 4); 67 84 SetConfigValue(timeRemaining, 20.0f); 85 SetConfigValue(respawnDelay, 4.0f); 68 86 } 69 87 … … 82 100 return true; 83 101 playerLives_[victim->getPlayer()]=playerLives_[victim->getPlayer()]-1; 102 this->inGame_[victim->getPlayer()]=false;//if player dies he, isn't allowed to respawn immediately 84 103 if (playerLives_[victim->getPlayer()]<=0)//if player lost all lives 85 104 { … … 117 136 this->playersAlive++; 118 137 this->timeToAct_[player]=timeRemaining; 138 this->playerDelayTime_[player]=respawnDelay; 139 this->inGame_[player]=true; 119 140 //Update: EachPlayer's "Players in Game"-HUD 120 141 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 151 172 if (!player) 152 173 return; 153 this->timeToAct_[player]=timeRemaining+3.0f;//reset timer 174 this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer 175 this->playerDelayTime_[player]=respawnDelay; 154 176 //Update: Individual Players "lifes"-HUD 155 177 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(player); 156 178 if (it2 != this->players_.end()) 157 179 { 180 if (it2->first->getClientID()== CLIENTID_UNKNOWN) 181 return; 158 182 const std::string& message = "Your Lives: " +multi_cast<std::string>(playerLives_[player]); 159 183 this->gtinfo_->sendFadingMessage(message,it2->first->getClientID()); … … 170 194 if (it->first->getClientID() == CLIENTID_UNKNOWN) 171 195 continue; 172 const std::string& message1 = "Remaining Players 196 const std::string& message1 = "Remaining Players: "+ multi_cast<std::string>(playersAlive); 173 197 this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 174 198 } … … 196 220 {return;} 197 221 pawn->kill(); 198 this->timeToAct_[player]=timeRemaining+3.0f ;//reset timer222 this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer 199 223 } 200 224 } … … 210 234 } 211 235 for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it) 212 { 213 it->second-=dt; 214 if (it->second<timeRemaining/6)//Warning message 215 { 236 { 237 if (playerGetLives(it->first)<=0)//Players without lives shouldn't be affected by time. 238 return; 239 it->second-=dt;//Decreases punishment time. 240 if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 241 { 242 playerDelayTime_[it->first]-=dt; 243 if (playerDelayTime_[it->first]<=0) 244 this->inGame_[it->first]=true; 245 } 246 else if (it->second<0.0f) 247 { 248 it->second=timeRemaining+3.0f;//reset punishment-timer 249 if (playerGetLives(it->first)>0) 250 this->killPlayer(it->first); 251 } 252 else if (it->second<timeRemaining/6)//Warning message 253 { 254 if (it->first->getClientID()== CLIENTID_UNKNOWN) 255 return; 216 256 const std::string& message = "Camper Warning! Don't forget to shoot."; 217 257 this->gtinfo_->sendFadingMessage(message,it->first->getClientID()); 218 258 } 219 if (it->second<0.0f)220 {221 it->second=timeRemaining+3.0f;//reset timer222 if (playerGetLives(it->first)>0)223 this->killPlayer(it->first);224 }225 259 } 226 260 } -
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
r7583 r7596 55 55 float timeRemaining; //!< Each player has a certain time where he or she has to hit an opponent or will be punished. 56 56 std::map<PlayerInfo*, float> timeToAct_; //!< Each player's time till she/he will be punished is stored here. 57 float respawnDelay; 58 std::map<PlayerInfo*, float> playerDelayTime_; //!< Stores each Player's delay time. 59 std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state. 57 60 virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn 58 61
Note: See TracChangeset
for help on using the changeset viewer.