Changeset 9441
- Timestamp:
- Nov 12, 2012, 4:13:27 PM (12 years ago)
- Location:
- code/branches/Racingbot/src/modules/gametypes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc
r9432 r9441 43 43 CreateFactory(RaceCheckPoint); 44 44 45 RaceCheckPoint::RaceCheckPoint(BaseObject* creator) : 46 DistanceMultiTrigger(creator), RadarViewable(creator, 47 static_cast<WorldEntity*> (this)) 45 RaceCheckPoint::RaceCheckPoint(BaseObject* creator) : DistanceMultiTrigger(creator), 46 RadarViewable(creator, static_cast<WorldEntity*> (this)) 48 47 { 49 RegisterObject(RaceCheckPoint) 50 ;this->setDistance(100);48 RegisterObject(RaceCheckPoint); 49 this->setDistance(100); 51 50 this->setBeaconMode("off"); 52 51 this->setBroadcast(false); … … 62 61 this->timeLimit_ = 0; 63 62 //this->players_ = vector<PlayerInfo*>(); 63 64 myPosition_= this->getPosition(); 65 orxout(user_status) << "test" << std::endl; 66 64 67 } 65 68 … … 87 90 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator); 88 91 if (entity) 89 this->players_.push_back(entity->getPlayer());92 this->players_.push_back(entity->getPlayer()); 90 93 } 91 94 } -
code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h
r9412 r9441 104 104 float timeLimit_; ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses. 105 105 std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint 106 Vector3 myPosition_; 106 107 }; 107 108 } -
code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
r9436 r9441 23 23 * Author: purgham 24 24 */ 25 25 /** 26 * Conventions: 27 * -first Checkpoint has index 0 28 * 29 */ 26 30 #include <gametypes/SpaceRaceController.h> 27 31 #include "core/CoreIncludes.h" … … 29 33 #include "gametypes/SpaceRaceManager.h" 30 34 31 // WEnn RAcer nach start erstellt wird fehler in Tick 32 // Fuer beide Spieler wird next point angezeigt 35 36 37 33 38 namespace orxonox 34 39 { … … 50 55 51 56 OrxAssert(!checkpoints.empty(), "No Checkpoints in Level"); 57 //OrxAssert(1==2, "Orxassert test"); 52 58 checkpoints_=checkpoints; 53 59 staticRacePoints_ = findStaticCheckpoints(checkpoints); 60 for (int i=0; true; i++){ 61 if(checkpoints_[i]->getCheckpointIndex()==0){ 62 nextRaceCheckpoint_=checkpoints_[i]; 63 break; 64 } 65 } 54 66 55 67 } … … 66 78 RaceCheckPoint* SpaceRaceController::nextPointFind(RaceCheckPoint* raceCheckpoint) 67 79 { 68 int distances[] = 69 { -1, -1, -1}; 80 int distances[] ={ -1, -1, -1}; 70 81 int temp_i = 0; 71 82 for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it) 72 83 { 73 distances[temp_i] = recCalculateDistance(raceCheckpoint, this->getControllableEntity()->getPosition());84 distances[temp_i] = recCalculateDistance(raceCheckpoint, this->getControllableEntity()->getPosition()); 74 85 temp_i++; 75 86 } … … 119 130 int SpaceRaceController::recCalculateDistance(RaceCheckPoint* currentCheckPoint, Vector3 currentPosition) 120 131 { 132 orxout()<< "rec Aufruf" << endl; 121 133 // if ( staticCheckPoint was reached) 122 134 if (std::find(staticRacePoints_.begin(), staticRacePoints_.end(),currentCheckPoint) != staticRacePoints_.end()) … … 127 139 { 128 140 int minimum = std::numeric_limits<int>::max(); 141 int temp=0; 129 142 for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it!= currentCheckPoint->getNextCheckpoints().end(); ++it) 130 { 131 minimum= std::min(minimum,(int) (currentPosition- currentCheckPoint->getPosition()).length() + recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition())); 132 }//TODO: fix cast 143 { //temp++; 144 WorldEntity* ttt= dynamic_cast<WorldEntity*> (currentCheckPoint); 145 OrxAssert(!(ttt==NULL), "WorldEntity null"); 146 OrxAssert(!(ttt->getNode()==NULL), "Node of WorldEntity is null"); 147 148 //orxout()<< temp <<endl; 149 //if(temp==1){orxout()<<currentCheckPoint << " == null? => "<<(currentCheckPoint==NULL)<<currentPosition<<endl;} 150 Vector3 t=(currentPosition- ttt->getPosition()); //TODO: Find Crash Reason. Why can't currentCheck access node. 151 int tt=static_cast<int>(t.length()); 152 //OrxAssert(!currentCheckPoint.empty(), "currentCheckPoint == null"); 153 //OrxAssert(!(it == currentCheckPoint->getNextCheckpoints().end()), "it is null"); 154 minimum= std::min(minimum, tt+ recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition())); 155 // minimum of distanz from 'currentPosition' to the next static Checkpoint 156 }//Error tritt manchmal auf 133 157 return minimum; 134 158 } … … 204 228 void SpaceRaceController::tick(float dt) 205 229 { 206 if (this->getControllableEntity() == NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<< endl; return;}230 if (this->getControllableEntity() == NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<< " in tick"<<endl; return;} 207 231 if (nextRaceCheckpoint_->playerWasHere(this->getControllableEntity()->getPlayer())) 208 232 {//Checkpoint erreicht -
code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h
r9432 r9441 40 40 private: 41 41 std::vector<RaceCheckPoint*> staticRacePoints_; 42 RaceCheckPoint* nextRaceCheckpoint_; 43 RaceCheckPoint* currentRaceCheckpoint_; 42 RaceCheckPoint* nextRaceCheckpoint_; // checkpoint that should be reached 43 RaceCheckPoint* currentRaceCheckpoint_; // last checkPoint (already reached) 44 44 std::vector<RaceCheckPoint*> checkpoints_; 45 45 int lastDistance;
Note: See TracChangeset
for help on using the changeset viewer.