- Timestamp:
- Dec 16, 2012, 6:07:37 PM (11 years ago)
- Location:
- code/branches/presentationHS12
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS12
- Property svn:mergeinfo changed
/code/branches/Racingbot (added) merged: 9388,9399,9412,9432,9436,9441,9451,9459,9470,9487,9490,9507-9508,9512-9513
- Property svn:mergeinfo changed
-
code/branches/presentationHS12/src/modules/gametypes/RaceCheckPoint.cc
r9348 r9523 43 43 CreateFactory(RaceCheckPoint); 44 44 45 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) 45 RaceCheckPoint::RaceCheckPoint(BaseObject* creator) : DistanceMultiTrigger(creator), 46 RadarViewable(creator, static_cast<WorldEntity*> (this)) 46 47 { 47 48 RegisterObject(RaceCheckPoint); 48 49 49 this->setDistance(100); 50 50 this->setBeaconMode("off"); … … 60 60 this->bIsLast_ = false; 61 61 this->timeLimit_ = 0; 62 this->player_ = NULL; 63 } 64 65 66 RaceCheckPoint::~RaceCheckPoint() 67 { 68 } 62 //this->players_ = vector<PlayerInfo*>(); 63 64 myPosition_= this->getPosition(); //eingefuegt 65 //orxout(user_status) << "test" << std::endl; 66 } 67 68 RaceCheckPoint::~RaceCheckPoint() 69 { 70 71 } 69 72 70 73 void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 86 89 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator); 87 90 if (entity) 88 this->player _ = entity->getPlayer();91 this->players_.push_back(entity->getPlayer()); 89 92 } 90 93 } … … 95 98 if (this->timeLimit_ != 0) 96 99 { 97 std::string message = 98 100 std::string message = "You have " + multi_cast<std::string>(this->timeLimit_) 101 + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1); 99 102 this->getGametype()->getGametypeInfo()->sendAnnounceMessage(message); 100 103 ChatManager::message(message); … … 102 105 } 103 106 107 //Must not be called before setNextCheckpointsAsVector3 at least once has been called 108 void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){ 109 /*std::set<int> lastcheckpoints=this->nextCheckpoints_; 110 nextCheckpoints_.clear(); 111 std::set<int>::iterator it = lastcheckpoints.begin(); 112 if(checkpoints.x<-1){ 113 virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it))); 114 it++; 115 } 116 if(checkpoints.x!=-1) 117 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly 118 119 if(checkpoints.y<-1){ 120 virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it))); 121 it++; 122 } 123 if(checkpoints.y!=-1) 124 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5)); 125 126 if(checkpoints.z<-1){ 127 virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it))); 128 it++; 129 } 130 if(checkpoints.z!=-1) 131 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));*/ 132 nextCheckpointsVirtual_.clear(); 133 if(checkpoints.x!=-1) 134 nextCheckpointsVirtual_.insert(checkpoints.x); 135 if(checkpoints.y!=-1) 136 nextCheckpointsVirtual_.insert(checkpoints.y); 137 if(checkpoints.z!=-1) 138 nextCheckpointsVirtual_.insert(checkpoints.z); 139 } 140 104 141 void RaceCheckPoint::setNextCheckpointsAsVector3(const Vector3& checkpoints) 105 142 { … … 107 144 108 145 if (checkpoints.x > -1) 109 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));146 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly 110 147 if (checkpoints.y > -1) 111 148 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5)); 112 149 if (checkpoints.z > -1) 113 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5)); 114 } 115 116 Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() const 150 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5)); 151 152 this->nextCheckpointsVirtual_=nextCheckpoints_; 153 } 154 155 PlayerInfo* RaceCheckPoint::getPlayer(unsigned int clientID) const 156 { 157 if (players_.size() > 0) 158 { 159 for (int i = 0; i < players_.size(); i++) 160 { 161 if (this->players_[i]->getClientID() == clientID) 162 { 163 return players_[i]; 164 } 165 } 166 } 167 return NULL; 168 } 169 170 bool RaceCheckPoint::playerWasHere(PlayerInfo* player) const 171 { 172 if (players_.size() > 0) 173 { 174 for (int i = 0; i < players_.size(); i++) 175 { 176 if (this->players_[i] == player) 177 { 178 return true; 179 } 180 } 181 } 182 return false; 183 } 184 185 Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() 186 { 187 Vector3 checkpoints(-1,-1,-1); int count=0; 188 for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ ){ 189 switch (count) 190 { 191 case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break; 192 case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break; 193 case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break; 194 } 195 ++count; 196 } 197 return checkpoints; 198 //= getVirtualNextCheckpointsAsVector3(); 199 int j[3]; 200 j[0]=changeVirtualToRealCheckPoint(checkpoints.x); 201 j[1]=changeVirtualToRealCheckPoint(checkpoints.y); 202 j[2]=changeVirtualToRealCheckPoint(checkpoints.z); 203 204 205 return Vector3(j[0],j[1],j[2]); 206 207 208 } 209 210 int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) { 211 int temp=checkpointID; 212 while(temp<-1){ 213 temp = this->virtualToRealCheckPoints_[temp]; 214 } 215 return temp; 216 } 217 218 219 Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const 117 220 { 118 221 Vector3 checkpoints = Vector3(-1, -1, -1); 119 222 120 223 size_t count = 0; 121 for (std::set<int>::iterator it = this->nextCheckpoints _.begin(); it != this->nextCheckpoints_.end(); ++it)224 for (std::set<int>::iterator it = this->nextCheckpointsVirtual_.begin(); it != this->nextCheckpointsVirtual_.end(); ++it) 122 225 { 123 226 switch (count)
Note: See TracChangeset
for help on using the changeset viewer.