Changeset 3033 for code/trunk/src/orxonox/objects/gametypes
- Timestamp:
- May 23, 2009, 9:57:52 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gametypes (added) merged: 2827,2903,2905-2906,2933-2936,2952,2954,2961,2970-2971,2978,2985-2986,3019-3020
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/gametypes/CMakeLists.txt
r2826 r3033 3 3 Deathmatch.cc 4 4 TeamDeathmatch.cc 5 TeamBaseMatch.cc 5 6 Pong.cc 7 UnderAttack.cc 8 Asteroids.cc 6 9 ) -
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r2896 r3033 60 60 this->numberOfBots_ = 0; 61 61 62 this->timeLimit_ = 0; 63 this->time_ = 0; 64 this->timerIsActive_ = false; 65 62 66 this->initialStartCountdown_ = 3; 63 67 … … 88 92 SUPER(Gametype, tick, dt); 89 93 94 //count timer 95 if (timerIsActive_) 96 { 97 if (this->timeLimit_ == 0) 98 this->time_ += dt; 99 else 100 this->time_ -= dt; 101 } 102 90 103 if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_) 91 104 this->gtinfo_.startCountdown_ -= dt; … … 93 106 if (!this->gtinfo_.bStarted_) 94 107 this->checkStart(); 95 else 108 else if (!this->gtinfo_.bEnded_) 96 109 this->spawnDeadPlayersIfRequested(); 97 110 … … 111 124 { 112 125 this->gtinfo_.bEnded_ = true; 126 127 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 128 { 129 if (it->first->getControllableEntity()) 130 { 131 ControllableEntity* oldentity = it->first->getControllableEntity(); 132 133 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator()); 134 if (oldentity->getCamera()) 135 { 136 entity->setPosition(oldentity->getCamera()->getWorldPosition()); 137 entity->setOrientation(oldentity->getCamera()->getWorldOrientation()); 138 } 139 else 140 { 141 entity->setPosition(oldentity->getWorldPosition()); 142 entity->setOrientation(oldentity->getWorldOrientation()); 143 } 144 145 it->first->stopControl(oldentity, true); 146 it->first->startControl(entity); 147 } 148 else 149 this->spawnPlayerAsDefaultPawn(it->first); 150 } 113 151 } 114 152 … … 267 305 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) 268 306 { 269 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 270 if (spawn) 271 { 272 // force spawn at spawnpoint with default pawn 273 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 274 spawn->spawn(entity); 275 it->first->startControl(entity); 276 it->second.state_ = PlayerState::Dead; 277 } 278 else 279 { 280 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 281 abort(); 282 } 307 this->spawnPlayerAsDefaultPawn(it->first); 308 it->second.state_ = PlayerState::Dead; 283 309 } 284 310 } … … 358 384 } 359 385 386 void Gametype::spawnPlayerAsDefaultPawn(PlayerInfo* player) 387 { 388 SpawnPoint* spawn = this->getBestSpawnPoint(player); 389 if (spawn) 390 { 391 // force spawn at spawnpoint with default pawn 392 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 393 spawn->spawn(entity); 394 player->startControl(entity); 395 } 396 else 397 { 398 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 399 abort(); 400 } 401 } 402 360 403 void Gametype::addBots(unsigned int amount) 361 404 { … … 376 419 } 377 420 } 421 422 void Gametype::addTime(float t) 423 { 424 if (this->timeLimit_ == 0) 425 this->time_ -= t; 426 else 427 this->time_ += t; 428 } 429 430 void Gametype::removeTime(float t) 431 { 432 if (this->timeLimit_ == 0) 433 this->time_ += t; 434 else 435 this->time_ -= t; 436 } 437 438 void Gametype::resetTimer() 439 { 440 this->resetTimer(timeLimit_); 441 } 442 443 void Gametype::resetTimer(float t) 444 { 445 this->timeLimit_ = t; 446 this->time_ = t; 447 } 378 448 } -
code/trunk/src/orxonox/objects/gametypes/Gametype.h
r2890 r3033 128 128 { return this->players_.size(); } 129 129 130 virtual void addTime(float t); 131 virtual void removeTime(float t); 132 133 inline void startTimer() 134 { 135 this->time_ = this->timeLimit_; 136 this->timerIsActive_ = true; 137 } 138 139 inline void stopTimer() 140 { this->timerIsActive_ = false; } 141 142 inline float getTime() 143 { return this->time_; } 144 145 inline bool getTimerIsActive() 146 { return timerIsActive_; } 147 148 inline void setTimeLimit(float t) 149 { this->timeLimit_ = t; } 150 151 virtual void resetTimer(); 152 virtual void resetTimer(float t); 153 130 154 protected: 131 155 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; … … 134 158 virtual void checkStart(); 135 159 virtual void spawnPlayer(PlayerInfo* player); 160 virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player); 136 161 virtual void spawnPlayersIfRequested(); 137 162 virtual void spawnDeadPlayersIfRequested(); … … 141 166 bool bAutoStart_; 142 167 bool bForceSpawn_; 168 169 float time_; 170 float timeLimit_; 171 bool timerIsActive_; 143 172 144 173 float initialStartCountdown_; -
code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
r3032 r3033 125 125 void TeamBaseMatch::showPoints() 126 126 { 127 128 COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl; 129 if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl; 130 if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl; 127 COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl; 128 if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl; 129 if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl; 131 130 } 132 131 … … 135 134 void TeamBaseMatch::winPoints() 136 135 { 137 138 136 int amountControlled = 0; 137 int amountControlled2 = 0; 139 138 140 139 for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it) 141 140 { 142 143 144 145 146 147 148 149 141 if((*it)->getState() == BaseState::controlTeam1) 142 { 143 amountControlled++; 144 } 145 if((*it)->getState() == BaseState::controlTeam2) 146 { 147 amountControlled2++; 148 } 150 149 } 151 150 -
code/trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc
r3028 r3033 127 127 { 128 128 TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it); 129 if (tsp && tsp->getTeamNumber() != desiredTeamNr)129 if (tsp && (int)tsp->getTeamNumber() != desiredTeamNr) 130 130 { 131 131 teamSpawnPoints.erase(it++); … … 189 189 return false; 190 190 } 191 192 int TeamDeathmatch::getTeam(PlayerInfo* player) 193 { 194 std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player); 195 if (it_player != this->teamnumbers_.end()) 196 return it_player->second; 197 else 198 return -1; 199 } 191 200 } -
code/trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h
r3028 r3033 55 55 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); 56 56 57 inline const ColourValue& getTeamColour(int teamnr) const 58 { return this->teamcolours_[teamnr]; } 59 57 60 protected: 58 61 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; 59 62 bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2); 63 int getTeam(PlayerInfo* player); 60 64 61 65 std::map<PlayerInfo*, int> teamnumbers_;
Note: See TracChangeset
for help on using the changeset viewer.