Changeset 2970
- Timestamp:
- May 11, 2009, 5:00:55 PM (16 years ago)
- Location:
- code/branches/gametypes/src/orxonox
- Files:
-
- 2 added
- 7 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_; -
code/branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
r2936 r2970 47 47 48 48 this->setStayActive(true); 49 this->setDistance(20); 50 bIsDestination_ = false; 49 this->setDistance(50); 50 this->bIsFirst_ = false; 51 this->bIsDestination_ = false; 51 52 this->setVisible(true); 52 53 } … … 60 61 SUPER(CheckPoint, XMLPort, xmlelement, mode); 61 62 63 XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false); 62 64 XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false); 65 XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30); 63 66 } 64 67 65 void CheckPoint::setDestination(bool isDestination)66 {67 bIsDestination_ = isDestination;68 }69 70 bool CheckPoint::getDestination()71 {72 return bIsDestination_;73 }74 75 76 68 void CheckPoint::triggered(bool bIsTriggered) 77 69 { 78 70 DistanceTrigger::triggered(bIsTriggered); 79 71 80 if (bIsTriggered && bIsDestination_) 81 { 82 Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); 83 if (gametype) 84 { 85 gametype->end(); 86 } 87 } 72 Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); 73 if (gametype) 74 { 75 gametype->addTime(addTime_); 76 77 if (bIsTriggered && bIsFirst_) 78 { 79 gametype->firstCheckpointReached(true); 80 } 81 82 if (bIsTriggered && bIsDestination_) 83 { 84 gametype->end(); 85 } 86 } 88 87 } 89 88 } -
code/branches/gametypes/src/orxonox/objects/worldentities/triggers/CheckPoint.h
r2936 r2970 57 57 private: 58 58 virtual void triggered(bool bIsTriggered); 59 virtual void setDestination(bool isDestination); 60 virtual bool getDestination(); 59 60 inline void setDestination(bool isDestination) 61 { bIsDestination_ = isDestination; } 62 63 inline bool getDestination() 64 { return bIsDestination_; } 65 66 inline void setFirst(bool isFirst) 67 { this->bIsFirst_ = isFirst; } 68 69 inline bool getFirst() 70 { return this->bIsFirst_; } 71 72 inline void setAddTime(float time) 73 { this->addTime_ = time; } 74 75 inline bool getAddTime() 76 { return this->addTime_; } 61 77 78 bool bIsFirst_; 62 79 bool bIsDestination_; 80 float addTime_; 63 81 }; 64 82 } -
code/branches/gametypes/src/orxonox/overlays/hud/CMakeLists.txt
r2710 r2970 5 5 HUDSpeedBar.cc 6 6 HUDHealthBar.cc 7 HUDTimer.cc 7 8 ChatOverlay.cc 8 9 GametypeStatus.cc
Note: See TracChangeset
for help on using the changeset viewer.