- Timestamp:
- Oct 10, 2018, 3:36:53 PM (6 years ago)
- Location:
- code/branches/mergeFS18
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/mergeFS18
- Property svn:mergeinfo changed
/code/branches/RacingBots_FS18 (added) merged: 11817,11840-11841,11857,11860,11893,11912-11913,11938,11964-11969,11977,11982,11986,11989,11997
- Property svn:mergeinfo changed
-
code/branches/mergeFS18/src/modules/gametypes/SpaceRace.cc
r11721 r12029 69 69 #include "SpaceRaceBot.h" 70 70 #include "items/Engine.h" 71 #include <vector> 71 #include <vector> 72 #include <iostream> 73 #include <string> 72 74 73 75 … … 83 85 this->cantMove_ = false; 84 86 this->bTimeIsUp_ = false; 85 86 87 this->numberOfBots_ = 5; // quick fix: don't allow default-bots to enter the race 88 this->bLost =false; 87 89 //we fixed the number of bots in order to have the same starting position all the time ! 88 90 } … … 101 103 startpos[4] =-40; 102 104 startpos[5] =100; 103 105 104 106 startpos[6] =100; 105 107 startpos[7] =-40; … … 117 119 118 120 this->spawnPlayersIfRequested(); 121 this->countdown_mode=true; 119 122 this->cantMove_ = true; 120 123 //players are unable to move while countdown is running … … 122 125 { 123 126 engine->setActive(false); 127 engine->addSpeedMultiply(1.7); 124 128 } 125 129 … … 138 142 } 139 143 140 std::string message("Use headphones to hear the countdown!"); 141 this->getGametypeInfo()->sendAnnounceMessage(message); 142 ChatManager::message(message); 143 144 //after 11 seconds , countdownFinished function is called to activate bots` engines 145 Timer* countdownTimer = new Timer(); 146 countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this))); 147 } 148 149 150 144 std::string message("Use headphones to hear the countdown! Press W for forward acceleration, press W+space for boost!"); 145 146 this->getGametypeInfo()->sendAnnounceMessage(message); 147 ChatManager::message(message); 148 149 150 151 152 } 153 154 // Counter in the beginning of the game 155 void SpaceRace::tick(float dt) { 156 SUPER(SpaceRace, tick, dt); 157 158 //countdown_mode is set true,when spawnIfRequested is called 159 if (countdown_mode) { 160 //10 seconds will be counted 161 this->time_passed -= dt; 162 163 //orxout() << "time: " <<(int) time_passed << "s" << endl; 164 165 std::string message=std::to_string((int)time_passed); 166 this->getGametypeInfo()->sendAnnounceMessage(message); 167 if (time_passed <= 1) { 168 169 this->countdownFinished(); 170 this->countdown_mode = false; 171 } 172 } 173 174 } 175 176 void SpaceRace::startmessage(int second){ 177 178 std::string message=std::to_string(second); 179 this->getGametypeInfo()->sendAnnounceMessage(message); 180 ChatManager::message(message); 181 182 183 184 } 151 185 152 186 void SpaceRace::end() 153 187 { 188 154 189 this->clock_.capture(); 155 190 int s = this->clock_.getSeconds(); 156 191 int ms = static_cast<int>(this->clock_.getMilliseconds() - 1000*s); 157 192 std::string message; 158 159 193 if (this->bTimeIsUp_) 160 194 { 161 message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 162 + "You lose!"; 163 } 195 message = "TIME IS UP! YOU LOOSE!"; 196 } 197 else if(this->bLost){ 198 message = "YOU LOOSE!"; 199 200 } 201 164 202 else 165 203 { … … 167 205 + "." + multi_cast<std::string>(ms) + " seconds."; 168 206 } 207 169 208 if (!this->hasEnded()) 170 209 { 210 171 211 this->getGametypeInfo()->sendAnnounceMessage(message); 172 212 ChatManager::message(message); … … 183 223 int ms = this->clock_.getMilliseconds() % 1000; 184 224 185 186 187 const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1) 225 226 std::string message(player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1) 227 + " after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."); 228 229 this->getGametypeInfo()->sendAnnounceMessage(message); 230 ChatManager::message(message); 231 /* const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1) 188 232 + "after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."; 189 233 this->getGametypeInfo()->sendAnnounceMessage(message); 190 ChatManager::message(message); 234 ChatManager::message(message);*/ 235 191 236 192 237 } … … 195 240 { 196 241 197 std::string message("RACE STARTED "); 198 this->getGametypeInfo()->sendAnnounceMessage(message); 199 ChatManager::message(message); 242 std::string message("RACE STARTED"); 243 this->getGametypeInfo()->sendAnnounceMessage(message); 244 ChatManager::message(message); 245 200 246 201 247 202 248 for (Engine* engine : ObjectList<Engine>()) 203 249 engine->setActive(true); 250 251 std::string message2("Press W for forward acceleration, press W+space for boost!"); 252 this->getGametypeInfo()->sendAnnounceMessage(message2); 253 ChatManager::message(message2); 204 254 } 205 255
Note: See TracChangeset
for help on using the changeset viewer.