Changeset 8552 for code/branches/spacerace/src
- Timestamp:
- May 23, 2011, 6:35:35 PM (14 years ago)
- Location:
- code/branches/spacerace/src/modules/gametypes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
r8548 r8552 45 45 this->bCheckpointIndex_ = 0; 46 46 this->bIsLast_ = false; 47 this->bTimeLimit_ =0;47 this->bTimeLimit_ = 0; 48 48 49 49 this->setRadarObjectColour(ColourValue::Red); … … 63 63 if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true); 64 64 else this->setRadarVisibility(false); 65 66 if (this->bTimeLimit_ != 0 && gametype->getTimerIsActive()) { 67 float time = gametype->getTime() - this->bTimeLimit_; 68 if (time > 0) { 69 gametype->timeIsUp(); 70 gametype->end(); 71 } 72 } 65 73 } 66 74 -
code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
r8428 r8552 43 43 RegisterObject(SpaceRace); 44 44 this->checkpointsReached_ = 0; 45 this->bTimeIsUp_ = false; 45 46 this->numberOfBots_ = 0; 46 47 } … … 53 54 void SpaceRace::end() 54 55 { 55 Gametype::end(); 56 this->clock_->capture(); 57 int s = this->clock_->getSeconds(); 58 int ms = this->clock_->getMilliseconds()-1000*s; 59 const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) + 60 "." + multi_cast<std::string>(ms) + " seconds."; 61 COUT(0) << message << std::endl; 62 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 63 Host::Broadcast(message); 64 float time = this->clock_->getSecondsPrecise(); 65 this->scores_.insert(time); 66 std::set<float>::iterator it; 67 for (it=this->scores_.begin(); it!=this->scores_.end(); it++) 56 Gametype::end(); 57 this->stopTimer(); 58 if (this->bTimeIsUp_) { 59 COUT(0) << "Time is up" << std::endl; 60 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up"); 61 } 62 else { 63 this->clock_->capture(); 64 int s = this->clock_->getSeconds(); 65 int ms = this->clock_->getMilliseconds()-1000*s; 66 const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) + 67 "." + multi_cast<std::string>(ms) + " seconds."; 68 COUT(0) << message << std::endl; 69 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 70 Host::Broadcast(message); 71 float time = this->clock_->getSecondsPrecise(); 72 this->scores_.insert(time); 73 std::set<float>::iterator it; 74 for (it=this->scores_.begin(); it!=this->scores_.end(); it++) 68 75 COUT(0) << multi_cast<std::string>(*it) << std::endl; 76 } 69 77 } 70 78 … … 73 81 Gametype::start(); 74 82 83 this->startTimer(); 75 84 clock_= new Clock(); 76 85 std::string message("The match has started! Reach the check points as quick as possible!"); -
code/branches/spacerace/src/modules/gametypes/SpaceRace.h
r8428 r8552 77 77 inline int getCheckpointsReached() 78 78 { return this->checkpointsReached_; } 79 inline void timeIsUp() 80 { this->bTimeIsUp_ = true;} 79 81 80 82 protected: … … 82 84 private: 83 85 int checkpointsReached_; 86 std::set<float> scores_; 84 87 Clock *clock_; 85 std::set<float> scores_; 86 88 bool bTimeIsUp_; 87 89 }; 88 90 }
Note: See TracChangeset
for help on using the changeset viewer.