Changeset 8959
- Timestamp:
- Dec 7, 2011, 2:38:31 PM (13 years ago)
- Location:
- code/branches/spaceraceTwo
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceraceTwo/data/levels/Spacerace2.oxw
r8949 r8959 39 39 <SpaceRaceManager> 40 40 <checkpoints> 41 <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="true"> 41 <RaceCheckPoint name="checkpoint1" position="0,-200,100" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints=(1,2,0)> 42 <attached> 43 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> 44 </attached> 45 <collisionShapes> 46 <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" /> 47 <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" /> 48 <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" /> 49 <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" /> 50 </collisionShapes> 51 </RaceCheckPoint> 52 53 <RaceCheckPoint name="checkpoint2" position="0,-200,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints=(3,0,0)> 54 <attached> 55 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> 56 </attached> 57 <collisionShapes> 58 <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" /> 59 <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" /> 60 <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" /> 61 <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" /> 62 </collisionShapes> 63 </RaceCheckPoint> 64 65 <RaceCheckPoint name="checkpoint3" position="0,-400,200" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints=(3,0,0)> 66 <attached> 67 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> 68 </attached> 69 <collisionShapes> 70 <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" /> 71 <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" /> 72 <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" /> 73 <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" /> 74 </collisionShapes> 75 </RaceCheckPoint> 76 77 <RaceCheckPoint name="checkpoint4" position="0,-400,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="true"> 42 78 <attached> 43 79 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> … … 53 89 </SpaceRaceManager> 54 90 55 <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 > 56 <templates> 57 <Template link=spaceshipassff /> 58 </templates> 59 <controller> 60 <WaypointPatrolController alertnessradius=1500 team=0 > 61 <waypoints> 62 <Model scale=0 position="0,2000,2000" /> 63 </waypoints> 64 </WaypointPatrolController> 65 </controller> 66 </SpaceShip> 91 67 92 68 93 -
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
r8954 r8959 33 33 #include "core/XMLPort.h" 34 34 #include "chat/ChatManager.h" 35 36 #include <infos/PlayerInfo.h> 35 37 36 38 #include "SpaceRace.h" … … 51 53 52 54 53 this->bCheckpointIndex_ = 0;54 //this->bIsLast_ = false;55 56 55 57 this->bTimeLimit_ = 0; 56 58 this->isVisible_=true; … … 60 62 this->setRadarVisibility(true); 61 63 64 this->reached_=NULL; 62 65 //this->addTarget("WorldEntity"); 63 66 … … 71 74 if (this->isInitialized()) 72 75 { 73 //for (size_t i = 0; i < 3; ++i)74 // this->nextcheckpoints_[i]->destroy();76 for (size_t i = 0; i < this->next_.size(); ++i) 77 this->next_[i]->destroy(); 75 78 } 76 79 //nextcheckpoints_.destroy; … … 121 124 DistanceMultiTrigger::fire((bool)bIsTriggered,player); 122 125 123 //SUPER(RaceCheckPoint,fire,bIsTriggered,player); 124 125 126 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 126 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 127 127 assert(gametype); 128 128 129 PlayerInfo* player2 = (PlayerInfo*)player; 130 assert(player2); 131 //DistanceMultiTrigger::fire(bIsTriggered,player); 129 130 131 // BaseObject b=*player; 132 // PlayerInfo* p = orxonox_cast<PlayerInfo*,Player>(player); 133 //assert(player); 134 //PlayerInfo* player3=((PlayerInfo*) player); 135 Player* player3=((Player*) player); 136 137 PlayerInfo* player2=( PlayerInfo*) player; 138 139 for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it) 140 { 141 unsigned int clientid1=0, clientid2=0,clientid3=0; 142 if(it->first !=NULL)clientid1 = it->first->getClientID(); 143 144 if(player3 != NULL && player3->info_ != NULL)clientid2 = player3->info_->getClientID(); 145 if(player2 != NULL )clientid3 = player2->getClientID(); 146 orxout()<<clientid1<<endl;orxout()<<clientid2<<endl;orxout()<<clientid3<<endl; 147 orxout()<<"for"<<endl;if(clientid1==clientid2) {orxout()<<"player"<<endl; player2=it->first;}if((it->first)==player2) {orxout()<<"player2"<<endl; }} 148 149 // PlayerInfo* player2 = orxonox_cast<PlayerInfo*>(player); 150 // assert(player); 151 //gametype->newCheckpointReached(this,player); 152 //if(bIsTriggered)this->reached_=player2; 153 154 /* for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it) 155 {if(gametype->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;if(player2==it->first)orxout()<<"e"<<endl;} 156 if(gametype->getCheckpointReached(player2)==-1) orxout()<<"my index -1"<<endl; 157 orxout()<<gametype->getCheckpointReached(player2)<<endl; 158 132 159 160 RaceCheckPoint* check=gametype->getCheckpointReached(player2); 133 161 162 bool b =false; 163 for(int i=0;i<3;i++){ 164 165 if (check->getNext[i]==this){ 166 b=true;} 167 } 168 134 169 135 136 137 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player2) && bIsTriggered) 170 if (gametype && b && bIsTriggered) 138 171 { 139 172 gametype->clock_.capture(); … … 147 180 gametype->end(); 148 181 else 182 gametype->newCheckpointReached(this,player2) 149 183 { 150 gametype->newCheckpointReached(this,player2);184 151 185 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 152 186 } 153 } 187 }*/ 188 189 190 191 154 192 } 155 193 -
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
r8954 r8959 32 32 #include "gametypes/GametypesPrereqs.h" 33 33 34 35 34 36 #include "objects/triggers/DistanceMultiTrigger.h" 35 37 #include "interfaces/RadarViewable.h" … … 62 64 {return this->nextcheckpoints_;} 63 65 66 inline void setNext(int index,RaceCheckPoint* p) 67 {this->next_[index]=p;} 68 inline void setLast(bool isLast) 69 { this->bIsLast_ = isLast; } 70 inline bool getLast() 71 { return this->bIsLast_; } 72 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 73 float bTimeLimit_; //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. 74 PlayerInfo* reached_; 75 64 76 inline void setV(bool b) 65 77 {this->isVisible_ = b;} 66 78 protected: 67 79 virtual void fire(bool bIsTriggered,BaseObject* player); 68 inline void setLast(bool isLast) 69 { this->bIsLast_ = isLast; } 70 inline bool getLast() 71 { return this->bIsLast_; } 72 80 73 81 74 75 82 76 83 virtual void setTimelimit(float timeLimit); … … 82 89 private: 83 90 int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes. 84 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 85 float bTimeLimit_; //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. 86 91 87 92 88 93 Vector3 nextcheckpoints_; //the indexes of the next check points 89 94 90 95 bool isVisible_; 91 96 97 98 std::vector<RaceCheckPoint*> next_; 92 99 }; 93 100 } -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
r8954 r8959 29 29 #include "SpaceRace.h" 30 30 31 //#include "SpaceRaceManager.h" 32 31 33 #include "items/Engine.h" 32 34 … … 54 56 55 57 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 56 {this->checkpointReached_[it->first]= 0;}58 {this->checkpointReached_[it->first]=-1;} 57 59 58 60 … … 140 142 141 143 } 142 143 144 } 145 146 void SpaceRace::setV(SpaceRaceManager* m){ 147 /*Vector3 v =Vector3(0,0,0); 144 // for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 145 // {if(this->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;} 146 147 } 148 149 void SpaceRace::setV(SpaceRaceManager* m){/* 150 Vector3 v =Vector3(0,0,0); 148 151 int j=0; 149 152 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 161 164 162 165 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 163 { 166 {/* 164 167 this->checkpointReached_[pl]=index; 165 168 this->clock_.capture(); … … 171 174 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 172 175 ChatManager::message(message); 173 176 */ 174 177 175 178 } … … 194 197 void SpaceRace::playerEntered(PlayerInfo* player){ 195 198 Gametype::playerEntered(player); 196 //this->checkpointReached_[player]=0; 199 200 this->checkpointReached_[player]=-1; 197 201 //this->playersAlive_++; 198 202 } -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
r8940 r8959 73 73 { this->bTimeIsUp_ = true;} 74 74 void tick(float dt); 75 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 75 76 76 77 … … 85 86 std::set<float> scores_; //The times of the players are saved in a set. 86 87 bool bTimeIsUp_; //True if one of the check points is reached too late. 87 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 88 88 89 89 90 90 int playersAlive_; -
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 -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
r8940 r8959 58 58 59 59 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 60 60 int getIndex(RaceCheckPoint* r); 61 61 void addCheckpoint(RaceCheckPoint* checkpoint); 62 62 RaceCheckPoint* getCheckpoint(unsigned int index) const; 63 63 64 void checkpointReached(RaceCheckPoint* check, PlayerInfo* player); 64 65 66 void setNext(RaceCheckPoint* check); 65 67 66 68 void tick(float dt);
Note: See TracChangeset
for help on using the changeset viewer.