- Timestamp:
- Dec 7, 2011, 2:38:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
r8949 r8959 46 46 RegisterObject(SpaceRaceManager); 47 47 48 for (size_t i = 0; i < this->checkpoints_.size(); ++i) 49 this->setNext(this->checkpoints_[i]); 48 50 49 51 } … … 71 73 } 72 74 75 int SpaceRaceManager::getIndex(RaceCheckPoint* r) 76 { 77 78 for (size_t i = 0; i < this->checkpoints_.size(); ++i) 79 if (this->checkpoints_[i]==r){return i;} 80 81 82 83 return -1; 84 } 85 73 86 void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 87 { … … 85 98 gametype->setV(this); 86 99 100 101 for (size_t i = 0; i < this->checkpoints_.size(); ++i){ 102 if(this->checkpoints_[i]->reached_!=NULL) 103 this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_); 104 105 } 106 } 107 108 109 void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player){ 110 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 111 assert(gametype); 112 113 //if(gametype->getCheckpointReached(player)==-1) {orxout()<<"index -1"<<endl;} 114 115 bool b =false; 116 //DistanceMultiTrigger::fire(bIsTriggered,player); 117 int index=gametype->getCheckpointReached(player); 118 if (index>-1){ 119 RaceCheckPoint* tmp= this->getCheckpoint(index); 120 Vector3 v= tmp->getNextcheckpoint(); 121 122 // orxout()<<"index not -1"<<endl; 123 if (this->getCheckpoint(v.x)==check){ 124 b=true; 125 } 126 127 if (this->getCheckpoint(v.y)==check){ 128 b=true; 129 } 130 if (this->getCheckpoint(v.z)==check){ 131 b=true; 132 } } 133 else{b=(this->getIndex(check)==0);} 134 135 if (gametype && b) 136 { 137 gametype->clock_.capture(); 138 float time = gametype->clock_.getSecondsPrecise(); 139 if (check->bTimeLimit_!=0 && time > check->bTimeLimit_) 140 { 141 gametype->timeIsUp(); 142 gametype->end(); 143 } 144 else if (check->getLast()) 145 gametype->end(); 146 else 147 { 148 gametype->newCheckpointReached(check,player); 149 check->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 150 } 151 } 152 check->reached_=NULL; 153 } 154 155 156 157 void SpaceRaceManager::setNext(RaceCheckPoint* check){ 87 158 88 159 Vector3 v=check->getNextcheckpoint(); 160 check->setNext(0,this->getCheckpoint(v.x)); 161 check->setNext(1,this->getCheckpoint(v.y)); 162 check->setNext(2,this->getCheckpoint(v.z)); 163 } 164 165 89 166 } 90 }91 167 92 168 169
Note: See TracChangeset
for help on using the changeset viewer.