Changeset 8956
- Timestamp:
- Nov 30, 2011, 5:12:00 PM (13 years ago)
- Location:
- code/branches/gamecontent
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamecontent/data/levels/lastTeamStanding.oxw
r8891 r8956 17 17 name = "Last Team Standing" 18 18 description = "testmap for gametype last team standing" 19 gametype = " LastTeamStanding"19 gametype = "TeamGametype" 20 20 > 21 21 <templates> -
code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc
r8930 r8956 133 133 this->gtinfo_->playerReadyToSpawn(it->first); 134 134 } 135 135 136 136 this->checkStart(); 137 137 } … … 440 440 if(player->isHumanPlayer()) 441 441 this->gtinfo_->playerSpawned(player); 442 442 443 443 this->playerPostSpawn(player); 444 444 } -
code/branches/gamecontent/src/orxonox/gametypes/Gametype.h
r8930 r8956 126 126 void killBots(unsigned int amount = 0); 127 127 128 inline unsigned int getNumberOfPlayers() const129 { return this->players_.size(); }130 131 128 virtual void addTime(float t); 132 129 virtual void removeTime(float t); … … 151 148 152 149 //inline bool getForceSpawn() 153 // { return this->bForceSpawn_; } 150 // { return this->bForceSpawn_; } 154 151 155 152 virtual void resetTimer(); -
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
r8951 r8956 46 46 RegisterObject(TeamGametype); 47 47 48 this->teams_ = 2; 48 this->teams_ = 2; //most team gametypes use two different teams 49 49 this->allowFriendlyFire_ = false; 50 50 //this->playersPerTeam_ = 0; 51 this->maxPlayers_ = 0;51 this->maxPlayers_ = 2; //TEST 52 52 this->setConfigValues(); 53 53 } … … 78 78 if(player == NULL) return; 79 79 this->findAndSetTeam(player); 80 if( getNumberOfPlayers() < maxPlayers_ || maxPlayers_ == 0) 80 if( this->players_.size() <= maxPlayers_ || maxPlayers_ == 0) 81 { 81 82 this->allowedInGame_[player]= true; 83 } 82 84 else 85 { 83 86 this->allowedInGame_[player]= false; 87 orxout() << "not allowed in game: players = " << this->players_.size() << " > maximum: " << maxPlayers_ << endl; 88 } 84 89 } 85 90 … … 110 115 { 111 116 bool valid_player = Gametype::playerLeft(player); 117 if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list" 118 { 119 for (std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it) 120 { 121 if(it->second == false) // waiting player found 122 {it->second = true; break;} // allow player to enter 123 } 124 } 112 125 113 126 if (valid_player) 127 { // clean up the maps 114 128 this->teamnumbers_.erase(player); 129 this->allowedInGame_.erase(player); 130 } 131 115 132 116 133 return valid_player; … … 121 138 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\ 122 139 { 123 if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow 124 //continue; 140 if(allowedInGame_[it->first] == false)//check if dead player is allowed to enter 141 { 142 continue; 143 } 125 144 if (it->second.state_ == PlayerState::Dead) 126 145 { … … 135 154 136 155 bool TeamGametype::allowPawnHit(Pawn* victim, Pawn* originator) 137 {// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed 156 {// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed 138 157 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator || this->allowFriendlyFire_); 139 158 } … … 262 281 if(pawn == NULL) 263 282 return; 264 283 265 284 int teamnumber = pawn->getTeam(); 266 285 … … 292 311 void TeamGametype::colourPawn(Pawn* pawn, int teamNr) 293 312 {// catch no-colouring-case and wrong input 294 if(teamNr < 0 || pawn == NULL) return; 313 if(teamNr < 0 || pawn == NULL) return; 295 314 pawn->setRadarObjectColour(this->teamcolours_[teamNr]); 296 315 -
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
r8942 r8956 67 67 bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2); 68 68 69 bool allowFriendlyFire_; // <!friendlyfire is per default switched off: friendlyFire_ = false;69 bool allowFriendlyFire_; //!< friendlyfire is per default switched off: friendlyFire_ = false; 70 70 std::map<PlayerInfo*, int> teamnumbers_; 71 71 std::vector<ColourValue> teamcolours_; 72 unsigned int teams_; // <!Number of teams. Value 0 : no teams!73 //unsigned int playersPerTeam_; // <!Defines Maximum for players per team. Value 0: no maximum!74 unsigned int maxPlayers_; //<!Defines Maximum for number of players. Value 0 : no maximum!72 unsigned int teams_; //!< Number of teams. Value 0 : no teams! 73 //unsigned int playersPerTeam_; //!< Defines Maximum for players per team. Value 0: no maximum! 74 unsigned int maxPlayers_; //!< Defines Maximum for number of players. Value 0 : no maximum! 75 75 std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'. 76 76 void setTeamColour(PlayerInfo* player, Pawn* pawn);
Note: See TracChangeset
for help on using the changeset viewer.