Changeset 7485
- Timestamp:
- Sep 23, 2010, 11:22:22 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
r7481 r7485 26 26 * 27 27 */ 28 //Haupt-Problem: Wie kann ich Spieler vom Spiel ausschliessen, wenn sie alle Leben verlohren haben? (Kann man respawn unterbinden?) 29 //Aktuelle Notloesung: Spieler wird unsichtbar und kann keinen Schaden austeilen, aber: setradarinvisibility funktioniert scheinbar nicht 30 //Lösungsidee2: Spieler werden als passive Drohnen respawned, wenn sie keine Leben mehr haben (noch nicht implementiert) 31 // 28 32 29 #include "LastManStanding.h" 33 30 … … 46 43 RegisterObject(LastManStanding); 47 44 this->bForceSpawn_=true; 48 this->lives= 2;45 this->lives=4; 49 46 this->playersAlive=0; 50 47 this->timeRemaining=20.0f; … … 53 50 void LastManStanding::setConfigValues() 54 51 { 55 SetConfigValue(lives, 2); 56 } 57 58 bool LastManStanding::allowPawnHit(Pawn* victim, Pawn* originator) 52 SetConfigValue(lives, 4); 53 SetConfigValue(timeRemaining, 20.0f); 54 } 55 56 bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator) 59 57 { 60 58 if (originator && originator->getPlayer())// only for safety 61 59 { 62 if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to hit any pawn63 return false;64 }65 return true;66 }67 68 bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator)69 {70 if (originator && originator->getPlayer())// only for safety71 {72 60 this->timeToAct_[originator->getPlayer()]=timeRemaining; 73 if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to damage any pawn74 return false;75 61 } 76 62 … … 163 149 } 164 150 165 void LastManStanding::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)//makes dead players invisible166 {167 if (playerLives_[pawn->getPlayer()]<=0)//if player is dead168 {169 pawn->setVisible(false);170 pawn->setRadarVisibility(false);171 //removePlayer(pawn->getPlayer());172 }173 }174 void LastManStanding::pawnPostSpawn(Pawn* pawn)175 {/*176 if (playerLives_[pawn->getPlayer()]<=0)//if player is dead177 {178 pawn->setVisible(false); --->Seltsames Verhalten, wenn diese Zeile aktiv ist179 pawn->setRadarVisibility(false);180 } */181 }182 183 151 void LastManStanding::pawnKilled(Pawn* victim, Pawn* killer) 184 152 { … … 229 197 Host::Broadcast(message); 230 198 } 231 /*232 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());233 if (victim->getCamera())234 {235 entity->setPosition(victim->getCamera()->getWorldPosition());236 entity->setOrientation(victim->getCamera()->getWorldOrientation());237 }238 else239 {240 entity->setPosition(victim->getWorldPosition());241 entity->setOrientation(victim->getWorldOrientation());242 }243 it->first->startControl(entity);*/244 199 } 245 200 } … … 267 222 } 268 223 269 /*void LastManStanding::removePlayer(PlayerInfo* player) //----------> Dieser Versuch führt zu einem Programmabsturz 270 { 271 std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player); 272 if (it != this->players_.end()) 273 { 274 if (it->first->getControllableEntity()) 275 { 276 ControllableEntity* oldentity = it->first->getControllableEntity(); 277 278 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity); 279 if (oldentity->getCamera()) 280 { 281 entity->setPosition(oldentity->getCamera()->getWorldPosition()); 282 entity->setOrientation(oldentity->getCamera()->getWorldOrientation()); 283 } 284 else 285 { 286 entity->setPosition(oldentity->getWorldPosition()); 287 entity->setOrientation(oldentity->getWorldOrientation()); 288 } 289 290 it->first->startControl(entity); 291 } 292 else 293 this->spawnPlayerAsDefaultPawn(it->first); 294 } 295 296 }*/ 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 } 297 234 298 235 } -
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
r7480 r7485 31 31 */ 32 32 /* BY THE WAY 33 //You have to add bots (or any other further players) before actually starting a match. 33 //!You have to ADD BOTS (or any other further players) BEFORE actually starting a match! 34 //Maybe a warning should be added in the menu, if a player starts a Last Man Standing match alone. 34 35 //Whenever there is only on player in the game, this player will be declared as winner. 35 //How "death" is managed: Death players become invisivle and aren't allowed to damage any player. 36 //Though they can recieve damage and they are not invisible on the radar- 36 //How "death" is managed: dead players cannot respawn. 37 37 */ 38 38 #ifndef _LastManStanding_H__ … … 55 55 */ 56 56 protected: 57 int lives; //!< Standard amount of lives. 57 int lives; //!< Standard amount of lives. Each player starts a game with so many lives. 58 58 std::map< PlayerInfo*, int > playerLives_; //!< Each player's lives are stored here. 59 59 int playersAlive; //!< Counter counting players with more than 0 lives. 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 63 63 64 public: … … 66 67 void setConfigValues(); //!< Makes values configurable. 67 68 68 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); //!< Prevents hits by players with no lives. 69 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted. Prevents damage by players with no lives. 69 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted. 70 70 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each lives. 71 71 … … 76 76 virtual bool playerChangedName(PlayerInfo* player); 77 77 78 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);//makes dead players invisible79 virtual void pawnPostSpawn(Pawn* pawn); //just for test case80 78 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 81 79 82 80 const int playerGetLives(PlayerInfo* player); 83 81 void killPlayer(PlayerInfo* player); 84 //void removePlayer(PlayerInfo* player);85 82 void tick (float dt);// used to end the game 86 83 };
Note: See TracChangeset
for help on using the changeset viewer.