- 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/SpaceRaceController.cc
r11720 r12029 20 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 21 * 22 * Created on: Oct 8, 2012 22 * Created on: Oct 8, 2012findCheck 23 23 * Author: purgham 24 24 */ … … 30 30 #include "collisionshapes/CollisionShape.h" 31 31 #include "BulletCollision/CollisionShapes/btCollisionShape.h" 32 #include "SpaceRace.h" 32 33 33 34 … … 38 39 const int ADJUSTDISTANCE = 500; 39 40 const int MINDISTANCE = 5; 41 40 42 /* 41 43 * Idea: Find static Point (checkpoints the spaceship has to reach) … … 45 47 { 46 48 RegisterObject(SpaceRaceController); 49 //this->parentRace = nullptr; 50 47 51 std::vector<RaceCheckPoint*> checkpoints; 48 52 … … 63 67 64 68 int i; 65 for (i = -2; findCheckpoint(i) != nullptr; i--) 69 for (i = -2; findCheckpoint(i) != nullptr; i--) // WIESO? 66 70 { 67 71 continue; … … 103 107 return returnVec; 104 108 } 105 109 void SpaceRaceController::endtheGame() const { 110 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype()); 111 assert(gametype) 112 ; if (!gametype) 113 return; 114 gametype->bLost=true; 115 gametype->end(); 116 117 } 106 118 /* 107 119 * called from 'findStaticCheckpoints' … … 122 134 for (int checkpointIndex : currentCheckpoint->getNextCheckpoints()) 123 135 { 136 if (findCheckpoint(checkpointIndex) == nullptr){ 137 orxout(internal_warning) << "Problematic Point: " << checkpointIndex << endl; 138 } 124 139 if (currentCheckpoint == findCheckpoint(checkpointIndex)) 125 140 { 126 //orxout() << currentCheckpoint->getCheckpointIndex()<<endl;141 orxout() << currentCheckpoint->getCheckpointIndex()<<endl; 127 142 continue; 128 143 } 129 if (findCheckpoint(checkpointIndex) == nullptr) 130 orxout(internal_warning) << "Problematic Point: " << checkpointIndex << endl; 144 131 145 else 132 146 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(checkpointIndex), zaehler); 147 133 148 } 134 149 zaehler[currentCheckpoint] += numberOfWays; … … 162 177 { 163 178 RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(checkpointIndex); 179 164 180 float distance = recCalculateDistance(nextRaceCheckPoint, this->getControllableEntity()->getPosition()); 165 181 … … 168 184 minDistance = distance; 169 185 minNextRaceCheckPoint = nextRaceCheckPoint; 170 } 171 172 } 173 186 187 } 188 //There is a bug. If the user passes through the 19th checkpoint with the opponents, the game will end immediately 189 if(nextRaceCheckPoint->isLast()) 190 endtheGame(); 191 192 } 193 if(minNextRaceCheckPoint == nullptr) { orxout()<<"nullptr found @192 SpaceRaceController" << endl;} 174 194 return minNextRaceCheckPoint; 175 195 } … … 208 228 209 229 { 230 if(nextRaceCheckpoint_ == nullptr) orxout()<<"nullptr found @218 SpaceRaceController" << endl; 231 210 232 return nextRaceCheckpoint_; 211 233 } … … 213 235 214 236 { 237 if(nextRaceCheckpoint_ == nullptr) orxout()<<"nullptr found @223 SpaceRaceController" << endl; 238 215 239 return nextRaceCheckpoint_; 216 240 } … … 221 245 } 222 246 247 248 249 250 251 223 252 RaceCheckPoint* SpaceRaceController::findCheckpoint(int index) const 224 253 { 225 for (RaceCheckPoint* checkpoint : this->checkpoints_) 226 if (checkpoint->getCheckpointIndex() == index) 227 return checkpoint; 228 return nullptr; 229 } 254 RaceCheckPoint* res = nullptr; 255 for (RaceCheckPoint* checkpoint : this->checkpoints_){ 256 //conclusion: index=20 is not 257 if (checkpoint->getCheckpointIndex() == index){ 258 //if(checkpoint == nullptr) orxout()<<"returned nullptr @line 234 SpaceRaceController"<<endl; 259 //orxout()<< "index of the checkpoint "<< index <<endl; 260 res = checkpoint; 261 return res; 262 } 263 } 264 /* if(index>2 ) 265 this->endtheGame();*/ 266 267 return res; 268 } 269 270 230 271 231 272 /*RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , const Vector3& virtualCheckPointPosition ) … … 282 323 void SpaceRaceController::tick(float dt) 283 324 { 325 326 284 327 if (this->getControllableEntity() == nullptr || this->getControllableEntity()->getPlayer() == nullptr ) 285 328 { … … 312 355 { 313 356 nextRaceCheckpoint_ = adjustNextPoint(); 357 if(nextRaceCheckpoint_ == nullptr) orxout()<<"nullptr found @327 SpaceRaceController" << endl; 358 314 359 lastPositionSpaceship = this->getControllableEntity()->getPosition(); 315 360 } … … 325 370 } 326 371 //orxout(user_status) << "dt= " << dt << "; distance= " << (lastPositionSpaceship-this->getControllableEntity()->getPosition()).length() <<std::endl; 327 lastPositionSpaceship = this->getControllableEntity()->getPosition(); 328 372 /*lastPositionSpaceship = this->getControllableEntity()->getPosition(); 373 374 SpaceRace obj=new SpaceRace(); 375 obj.setParentRace(parentRace); 376 this->parentRace=obj.parentRace;*/ 377 329 378 this->boostControl(); 379 380 /*if(nextRaceCheckpoint_ == nullptr){ 381 this->parentRace->bLost=true; 382 this->parentRace->end(); 383 }*/ 384 // if(nextRaceCheckpoint_ == nullptr ){ 385 // // if( nextRaceCheckpoint_->getCheckpointIndex()==19) 386 // orxout()<<"nullptr @351 Line"<<endl; 387 // } 388 389 330 390 this->moveToPosition(nextRaceCheckpoint_->getPosition()); 391 331 392 this->boostControl(); 332 393 } 333 394 395 396 /*void SpaceRaceController::setParentRace(parentRace){ 397 this->parentRace=parentRace; 398 }*/ 334 399 // True if a coordinate of 'pointToPoint' is smaller then the corresponding coordinate of 'groesse' 335 400 bool SpaceRaceController::vergleicheQuader(const Vector3& pointToPoint, const Vector3& groesse)
Note: See TracChangeset
for help on using the changeset viewer.