Changeset 2970 for code/branches/gametypes/src/orxonox/objects/gametypes
- Timestamp:
- May 11, 2009, 5:00:55 PM (15 years ago)
- Location:
- code/branches/gametypes/src/orxonox/objects/gametypes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gametypes/src/orxonox/objects/gametypes/Asteroids.cc
r2936 r2970 43 43 { 44 44 RegisterObject(Asteroids); 45 this->firstCheckpointReached_ = false; 46 this->timeLimit_ = 30; 45 47 } 48 49 void Asteroids::tick(float dt) 50 { 51 SUPER(Asteroids, tick, dt); 52 53 if (firstCheckpointReached_) 54 { 55 this->timeLimit_ = this->time_; 56 this->startTimer(); 57 } 58 59 if (this->time_ < 0 && !this->hasEnded()) 60 { 61 this->end(); 62 } 63 64 } 65 46 66 47 67 void Asteroids::start() -
code/branches/gametypes/src/orxonox/objects/gametypes/Asteroids.h
r2905 r2970 42 42 virtual ~Asteroids() {} 43 43 44 virtual void tick(float dt); 45 44 46 virtual void start(); 45 47 virtual void end(); 48 49 inline void firstCheckpointReached(bool reached) 50 { this->firstCheckpointReached_ = reached; } 51 52 private: 53 bool firstCheckpointReached_; 54 bool gameEnded_; 55 46 56 }; 47 57 } -
code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.cc
r2952 r2970 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 … … 87 91 { 88 92 SUPER(Gametype, tick, dt); 93 94 //count timer 95 if (timerIsActive_) 96 { 97 if (this->timeLimit_ == 0) 98 this->time_ += dt; 99 else 100 this->time_ -= dt; 101 } 89 102 90 103 if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_) … … 393 406 } 394 407 } 408 409 void Gametype::addTime(float t) 410 { 411 if (this->timeLimit_ == 0) 412 this->time_ -= t; 413 else 414 this->time_ += t; 415 } 416 417 void Gametype::removeTime(float t) 418 { 419 if (this->timeLimit_ == 0) 420 this->time_ += t; 421 else 422 this->time_ -= t; 423 } 424 425 void Gametype::resetTimer() 426 { 427 this->resetTimer(timeLimit_); 428 } 429 430 void Gametype::resetTimer(float t) 431 { 432 this->timeLimit_ = t; 433 this->time_ = t; 434 } 395 435 } -
code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.h
r2952 r2970 126 126 { return this->players_.size(); } 127 127 128 virtual void addTime(float t); 129 virtual void removeTime(float t); 130 131 inline void startTimer() 132 { this->timerIsActive_ = true; } 133 134 inline void stopTimer() 135 { this->timerIsActive_ = false; } 136 137 inline float getTime() 138 { return this->time_; } 139 140 inline bool getTimerIsActive() 141 { return timerIsActive_; } 142 143 virtual void resetTimer(); 144 virtual void resetTimer(float t); 145 128 146 protected: 129 147 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; … … 140 158 bool bAutoStart_; 141 159 bool bForceSpawn_; 160 161 float time_; 162 float timeLimit_; 163 bool timerIsActive_; 142 164 143 165 float initialStartCountdown_;
Note: See TracChangeset
for help on using the changeset viewer.