Changeset 11720 for code/trunk/src/modules/gametypes/SpaceRace.cc
- Timestamp:
- Feb 4, 2018, 4:58:37 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/SpaceRace.cc
r11358 r11720 80 80 RegisterObject(SpaceRace); 81 81 82 this->botclass_ = Class(SpaceRaceBot); //ClassByString("")82 this->botclass_ = Class(SpaceRaceBot); 83 83 this->cantMove_ = false; 84 84 this->bTimeIsUp_ = false; 85 this->setConfigValues();86 85 87 86 this->numberOfBots_ = 5; // quick fix: don't allow default-bots to enter the race … … 89 88 } 90 89 91 void SpaceRace::setConfigValues()92 {93 94 95 }96 97 90 void SpaceRace::start() 98 91 { 99 // define spawn positions of the 5 bots92 // define spawn positions of the 5 bots 100 93 101 94 int startpos[15]; … … 120 113 startpos[13] =-40; 121 114 startpos[14] =80; 122 123 124 125 115 126 116 Gametype::start(); 127 if (true) 128 { 129 this->spawnPlayersIfRequested(); 130 this->cantMove_ = true; 131 //players are unable to move while countdown is running 132 for (Engine* engine : ObjectList<Engine>()){ 133 engine->setActive(false); 134 135 136 } 137 //append spawn positions to bots 138 int a,b,c; 139 a=0; 140 b=1; 141 c=2; 142 for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>()){ 143 bot->getControllableEntity()->setPosition(startpos[a],startpos[b],startpos[c]); 144 a= a+3; 145 b = b+3; 146 c+= 3; 147 } 148 149 150 } 151 152 117 118 this->spawnPlayersIfRequested(); 119 this->cantMove_ = true; 120 //players are unable to move while countdown is running 121 for (Engine* engine : ObjectList<Engine>()) 122 { 123 engine->setActive(false); 124 } 125 126 //append spawn positions to bots 127 int a,b,c; 128 a=0; 129 b=1; 130 c=2; 131 132 for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>()) 133 { 134 bot->getControllableEntity()->setPosition(startpos[a], startpos[b], startpos[c]); 135 a += 3; 136 b += 3; 137 c += 3; 138 } 153 139 154 140 std::string message("Use headphones to hear the countdown!"); … … 156 142 ChatManager::message(message); 157 143 158 //after 11 seconds , countdownFinished function is called to activate bots` engines159 Timer* countdownTimer = new Timer();144 //after 11 seconds , countdownFinished function is called to activate bots` engines 145 Timer* countdownTimer = new Timer(); 160 146 countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this))); 161 147 } … … 189 175 } 190 176 191 192 void SpaceRace::tick(float dt)193 {194 SUPER(SpaceRace,tick,dt);195 }196 197 177 void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player) 198 178 { … … 207 187 const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1) 208 188 + "after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."; 209 this->getGametypeInfo()->sendAnnounceMessage(message);210 ChatManager::message(message); 211 212 } 213 214 void SpaceRace::countdownFinished()//activates the engines of all players189 this->getGametypeInfo()->sendAnnounceMessage(message); 190 ChatManager::message(message); 191 192 } 193 194 void SpaceRace::countdownFinished()//activates the engines of all players 215 195 { 216 196 … … 220 200 221 201 222 for (Engine* engine : ObjectList<Engine>()) 223 engine->setActive(true); 224 225 226 227 } 228 229 void SpaceRace::playerEntered(PlayerInfo* player) 202 for (Engine* engine : ObjectList<Engine>()) 203 engine->setActive(true); 204 } 205 206 void SpaceRace::playerEntered(PlayerInfo* player) 230 207 { 231 208 Gametype::playerEntered(player); … … 236 213 237 214 238 void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game215 void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game 239 216 { 240 217 for (unsigned int i = 1; i <= amount; ++i){ … … 244 221 245 222 246 //set bot configurations223 //set bot configurations 247 224 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 248 225 { … … 255 232 } 256 233 257 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to early 258 //if they can 234 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to earlyif they can 259 235 { 260 236 return false;
Note: See TracChangeset
for help on using the changeset viewer.