Changeset 11841 for code/branches
- Timestamp:
- Mar 29, 2018, 4:02:41 PM (7 years ago)
- Location:
- code/branches/RacingBots_FS18/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/RacingBots_FS18/src/libraries/tools/Timer.cc
r11840 r11841 200 200 } 201 201 202 /*void Timer::setTimer(float interval, bool bKillAfterCall)203 {204 this->setInterval(interval);205 this->bActive_ = true;206 this->time_ = this->interval_;207 this->bKillAfterCall_ = bKillAfterCall;208 }209 */210 202 211 203 /** -
code/branches/RacingBots_FS18/src/libraries/tools/Timer.h
r11071 r11841 113 113 void run(); 114 114 115 115 116 /// Re-starts the timer: The executor will be called after @a interval seconds. 116 117 inline void startTimer() -
code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRace.cc
r11840 r11841 70 70 #include "items/Engine.h" 71 71 #include <vector> 72 #include <iostream> 73 #include <string> 74 72 75 73 76 namespace orxonox … … 100 103 startpos[4] =-40; 101 104 startpos[5] =100; 102 105 103 106 startpos[6] =100; 104 107 startpos[7] =-40; … … 137 140 } 138 141 139 140 std::string message("Use headphones to hear the countdown!"); 142 std::string message("Use headphones to hear the countdown! It is useful to start with a boost!"); 143 141 144 this->getGametypeInfo()->sendAnnounceMessage(message); 142 145 ChatManager::message(message); 143 146 147 148 /*for(int i=10; i>0;i=i-1){ 149 startmessage(i); 150 }*/ 144 151 145 152 146 153 //after 11 seconds , countdownFinished function is called to activate bots` engines 147 Timer* countdownTimer = new Timer(); 148 countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this))); 149 150 } 151 154 //Timer* countdownTimer = new Timer(); 155 //countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this))); 156 157 /* 158 while(countdownTimer->getRemainingTime()!=0){ 159 if(countdownTimer->getRemainingTime()==1){ 160 startmessage(1); 161 } 162 }*/ 163 164 165 166 167 168 169 170 /*unsigned long long float time_notification=countdownTimer.getRealMicroSeconds(); 171 while(this->bTimeIsUp_==false){ 172 173 std::ostream stream; 174 stream<<time_notification; 175 std::string chat_notification(stream.str()); 176 this->getGametypeInfo()->sendAnnounceMessage(chat_notification); 177 ChatManager::message(chat_notification); 178 179 }*/ 180 181 182 } 183 184 185 186 void SpaceRace::tick(float dt) { 187 SUPER(SpaceRace, tick, dt); 188 this->time_passed -= dt; 189 190 if (countdown_mode) { 191 192 //orxout() << "time: " <<(int) time_passed << "s" << endl; 193 std::string message=std::to_string((int)time_passed); 194 this->getGametypeInfo()->sendAnnounceMessage(message); 195 if (time_passed <= 1) { 196 this->countdownFinished(); 197 this->countdown_mode = false; 198 } 199 } 200 201 } 202 203 void SpaceRace::startmessage(int second){ 204 205 std::string message=std::to_string(second); 206 this->getGametypeInfo()->sendAnnounceMessage(message); 207 ChatManager::message(message); 208 209 210 211 } 152 212 153 213 -
code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRace.h
r11840 r11841 62 62 63 63 virtual void addBots(unsigned int amount) override; //<! overwrite function in order to bypass the addbots command. 64 virtual void tick(float dt) override; 65 virtual void startmessage(int second); 64 66 65 67 … … 84 86 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override; 85 87 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator) override; 88 bool countdown_mode = true; 89 float time_passed = 11.0f; 86 90 87 91 private:
Note: See TracChangeset
for help on using the changeset viewer.