Changeset 8968
- Timestamp:
- Dec 8, 2011, 6:07:32 PM (13 years ago)
- Location:
- code/branches/spaceraceTwo
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceraceTwo/data/levels/Spacerace2.oxw
r8959 r8968 39 39 <SpaceRaceManager> 40 40 <checkpoints> 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)>41 <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints="1,2,0"> 42 42 <attached> 43 43 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> … … 51 51 </RaceCheckPoint> 52 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)>53 <RaceCheckPoint name="checkpoint2" position="0,2100,2300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints="3,-1,-1"> 54 54 <attached> 55 55 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> … … 63 63 </RaceCheckPoint> 64 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)>65 <RaceCheckPoint name="checkpoint3" position="0,700,2700" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints="3,-1,-1"> 66 66 <attached> 67 67 <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" /> … … 90 90 91 91 92 92 <SpaceShip position="0,0,200" lookat="0,0,0"> 93 <templates> 94 <Template link=spaceshipassff /> 95 </templates> 96 <controller> 97 <WaypointPatrolController alertnessradius=1000 team=10> 98 <waypoints> 99 <Model mesh="cube.mesh" scale=8 position="0,-2000,1000" /> 100 <Model mesh="cube.mesh" scale=8 position="0,2100,2300" /> 101 <Model mesh="cube.mesh" scale=8 position="0,-400,300" /> 102 </waypoints> 103 </WaypointPatrolController> 104 </controller> 105 </SpaceShip> 93 106 94 107 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 /> -
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
r8960 r8968 35 35 36 36 #include <infos/PlayerInfo.h> 37 #include <worldentities/ControllableEntity.h> 37 38 38 39 #include "SpaceRace.h" … … 56 57 57 58 this->bTimeLimit_ = 0; 58 this->isVisible_=true;59 59 60 60 61 this->setRadarObjectColour(ColourValue::Blue); 61 62 this->setRadarObjectShape(RadarViewable::Triangle); 62 this->setRadarVisibility(true); 63 63 64 this->setRadarVisibility(false); 65 this->settingsChanged(); 64 66 this->reached_=NULL; 65 67 //this->addTarget("WorldEntity"); … … 72 74 { 73 75 74 if (this->isInitialized()) 75 { 76 for (size_t i = 0; i < this->next_.size(); ++i) 77 this->next_[i]->destroy(); 78 } 79 //nextcheckpoints_.destroy; 76 77 78 80 79 } 81 80 … … 86 85 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 87 86 assert(gametype); 88 if(this->isVisible_){this->setRadarVisibility(true);}89 else{this->setRadarVisibility(false);}90 87 91 92 93 94 /*this->setRadarVisibility(false);95 Vector3 v =Vector3(0,0,0);96 int j=0;97 for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)98 {99 j=gametype->getCheckpointReached(it->first);100 RaceCheckPoint* r=SpaceRaceManager::getCheckpoint(j);101 v=r->getNextcheckpoint();102 for(int i=1;i<4;i++){103 if (this->getCheckpointIndex() == v[i])104 this->setRadarVisibility(true);105 }*/106 //}107 88 } 108 89 … … 119 100 void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player) 120 101 { 121 122 //bool b= bIsTriggered;123 //PlayerInfo* pl= player;124 102 DistanceMultiTrigger::fire((bool)bIsTriggered,player); 125 103 126 104 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 127 105 assert(gametype); 128 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->second.info_ !=NULL)clientid1 = it->second.info_->getClientID();else orxout()<<"second NULL"<<endl; 143 if(it->first !=NULL)clientid1 = it->first->getClientID();else orxout()<<"first NULL"<<endl; 144 clientid1 = it->first->getClientID(); 145 if(player3 != NULL && player3->info_ != NULL)clientid2 = player3->info_->getClientID(); 146 if(player2 != NULL )clientid3 = player2->getClientID(); 147 orxout()<<clientid1<<endl;orxout()<<clientid2<<endl;orxout()<<clientid3<<endl; 148 orxout()<<"for"<<endl;if(clientid1==clientid2) {orxout()<<"player"<<endl; player2=it->first;}if((it->first)==player2) {orxout()<<"player2"<<endl; }} 149 150 // PlayerInfo* player2 = orxonox_cast<PlayerInfo*>(player); 151 // assert(player); 152 //gametype->newCheckpointReached(this,player); 153 //if(bIsTriggered)this->reached_=player2; 154 155 /* for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it) 156 {if(gametype->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;if(player2==it->first)orxout()<<"e"<<endl;} 157 if(gametype->getCheckpointReached(player2)==-1) orxout()<<"my index -1"<<endl; 158 orxout()<<gametype->getCheckpointReached(player2)<<endl; 159 160 161 RaceCheckPoint* check=gametype->getCheckpointReached(player2); 162 163 bool b =false; 164 for(int i=0;i<3;i++){ 165 166 if (check->getNext[i]==this){ 167 b=true;} 168 } 169 170 171 if (gametype && b && bIsTriggered) 172 { 173 gametype->clock_.capture(); 174 float time = gametype->clock_.getSecondsPrecise(); 175 if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) 176 { 177 gametype->timeIsUp(); 178 gametype->end(); 179 } 180 else if (this->getLast()) 181 gametype->end(); 182 else 183 gametype->newCheckpointReached(this,player2) 184 { 185 186 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 187 } 188 }*/ 189 190 191 192 106 ControllableEntity* entity=(ControllableEntity*) player; 107 108 PlayerInfo* player2=entity->getPlayer(); 109 110 if(bIsTriggered)this->reached_=player2; 193 111 } 194 112 -
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
r8959 r8968 64 64 {return this->nextcheckpoints_;} 65 65 66 inline void setNext(int index,RaceCheckPoint* p) 67 {this->next_[index]=p;} 66 68 67 inline void setLast(bool isLast) 69 68 { this->bIsLast_ = isLast; } … … 74 73 PlayerInfo* reached_; 75 74 76 inline void setV(bool b)77 {this->isVisible_ = b;}75 inline float getTimeLimit() 76 { return this->bTimeLimit_;} 78 77 protected: 79 78 virtual void fire(bool bIsTriggered,BaseObject* player); … … 82 81 83 82 virtual void setTimelimit(float timeLimit); 84 inline float getTimeLimit() 85 { return this->bTimeLimit_;} 83 86 84 inline const WorldEntity* getWorldEntity() const 87 85 { return this; } … … 93 91 Vector3 nextcheckpoints_; //the indexes of the next check points 94 92 95 bool isVisible_; 96 93 97 94 98 95 std::vector<RaceCheckPoint*> next_; -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
r8959 r8968 29 29 #include "SpaceRace.h" 30 30 31 //#include "SpaceRaceManager.h"32 31 33 32 #include "items/Engine.h" … … 100 99 void SpaceRace::start() 101 100 { 102 //Gametype::start(); 103 this->spawnPlayersIfRequested(); Gametype::checkStart(); 101 102 this->spawnPlayersIfRequested(); 103 104 Gametype::checkStart(); 104 105 this->cantMove_=true; 105 106 … … 142 143 143 144 } 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;} 145 146 146 147 147 } 148 148 149 void SpaceRace::setV(SpaceRaceManager* m){/* 150 Vector3 v =Vector3(0,0,0); 151 int j=0; 152 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 153 { 154 j=this->getCheckpointReached(it->first); 155 RaceCheckPoint* r=m->getCheckpoint(j); 156 v=r->getNextcheckpoint(); 157 for(int i=1;i<4;i++){ 158 if(v[i]==0){ 159 RaceCheckPoint* n=m->getCheckpoint(v[i]); 160 n->setV(true); 161 }} 162 }*/ 163 } 164 149 150 165 151 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 166 {/* 167 this->checkpointReached_[pl]=index;152 { 153 this->checkpointReached_[pl]=index; 168 154 this->clock_.capture(); 169 int s = this->clock_.getSeconds();155 int s = this->clock_.getSeconds(); 170 156 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 171 const std::string& message = "Checkpoint " + multi_cast<std::string>(index)157 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 172 158 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 173 + " seconds.";159 + " seconds."; 174 160 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 175 161 ChatManager::message(message); 176 */ 177 178 } 179 162 163 } 164 180 165 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 181 {int index = p->getCheckpointIndex();182 this->checkpointReached_[pl]=index;183 this->clock_.capture();184 int s = this->clock_.getSeconds();185 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);166 { int index = p->getCheckpointIndex(); 167 this->checkpointReached_[pl]=index; 168 this->clock_.capture(); 169 int s = this->clock_.getSeconds(); 170 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 186 171 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 187 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)172 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 188 173 + " seconds."; 189 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 190 ChatManager::message(message); 191 192 193 } 174 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 175 ChatManager::message(message); 176 177 178 } 179 194 180 195 181 … … 212 198 // return valid_player; 213 199 } 200 201 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 202 { 203 return false; 204 } 205 206 bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator) 207 { 208 return false; 209 } 210 211 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator) 212 { 213 return false; 214 } 214 215 } -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
r8959 r8968 76 76 77 77 78 void setV(SpaceRaceManager* m); 78 bool allowPawnHit(Pawn* victim, Pawn* originator); 79 80 bool allowPawnDamage(Pawn* victim, Pawn* originator); 81 82 bool allowPawnDeath(Pawn* victim, Pawn* originator); 79 83 protected: 80 84 virtual void playerEntered(PlayerInfo* player); //!< Initializes values. -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
r8959 r8968 21 21 * 22 22 * Author: 23 * Mauro Salomon23 * Celine Eggenberger 24 24 * Co-authors: 25 25 * ... … … 38 38 #include "util/Math.h" 39 39 40 41 40 42 namespace orxonox 41 43 { … … 46 48 RegisterObject(SpaceRaceManager); 47 49 48 for (size_t i = 0; i < this->checkpoints_.size(); ++i) 49 this->setNext(this->checkpoints_[i]); 50 50 this->firstcheckpointvisible_=false; 51 51 52 } 52 53 … … 95 96 { 96 97 SUPER(SpaceRaceManager,tick,dt); 97 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());98 gametype->setV(this);99 98 99 if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_) 100 {this->checkpoints_[0]->setRadarVisibility(true);this->firstcheckpointvisible_=false;} 100 101 101 102 for (size_t i = 0; i < this->checkpoints_.size(); ++i){ … … 111 112 assert(gametype); 112 113 113 //if(gametype->getCheckpointReached(player)==-1) {orxout()<<"index -1"<<endl;}114 114 115 115 116 bool b =false; 116 //DistanceMultiTrigger::fire(bIsTriggered,player);117 117 118 int index=gametype->getCheckpointReached(player); 119 Vector3 v=Vector3 (-1,-1,-1); 118 120 if (index>-1){ 119 121 RaceCheckPoint* tmp= this->getCheckpoint(index); 120 Vector3v= tmp->getNextcheckpoint();122 v= tmp->getNextcheckpoint(); 121 123 122 // orxout()<<"index not -1"<<endl;124 123 125 if (this->getCheckpoint(v.x)==check){ 124 126 b=true; … … 137 139 gametype->clock_.capture(); 138 140 float time = gametype->clock_.getSecondsPrecise(); 139 if (check-> bTimeLimit_!=0 && time > check->bTimeLimit_)141 if (check->getTimeLimit()!=0 && time > check->getTimeLimit()) 140 142 { 141 143 gametype->timeIsUp(); … … 146 148 else 147 149 { 150 if (index > -1)this->setRadVis(player,false); 148 151 gametype->newCheckpointReached(check,player); 149 152 check->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 153 154 155 156 this->setRadVis(player, true); 157 150 158 } 151 159 } … … 153 161 } 154 162 163 void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b){ 164 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 165 assert(gametype); 166 int index=gametype->getCheckpointReached(player); 167 Vector3 v=Vector3(-1,-1,-1); 168 RaceCheckPoint* tmp= this->getCheckpoint(index); 169 v= tmp->getNextcheckpoint(); 155 170 156 171 157 void SpaceRaceManager::setNext(RaceCheckPoint* check){ 158 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 } 172 if(v.x > -1){this->getCheckpoint(v.x)->setRadarVisibility(b); 173 this->getCheckpoint(v.x)->settingsChanged();} 174 if(v.y > -1){this->getCheckpoint(v.y)->setRadarVisibility(b); 175 this->getCheckpoint(v.y)->settingsChanged();} 176 if(v.z > -1){this->getCheckpoint(v.z)->setRadarVisibility(b); 177 this->getCheckpoint(v.z)->settingsChanged();} 178 179 } 180 181 164 182 165 183 -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
r8959 r8968 42 42 #include "RaceCheckPoint.h" 43 43 44 45 44 46 namespace orxonox 45 47 { … … 64 66 void checkpointReached(RaceCheckPoint* check, PlayerInfo* player); 65 67 66 void setNext(RaceCheckPoint* check);68 67 69 68 70 void tick(float dt); 69 71 protected: 70 72 void setRadVis(PlayerInfo* player, bool b); 71 73 private: 72 74 std::vector<RaceCheckPoint*> checkpoints_; 73 75 bool firstcheckpointvisible_; 74 76 75 77 -
code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc
r7184 r8968 78 78 79 79 void WaypointPatrolController::searchEnemy() 80 { 80 {/* 81 81 this->patrolTimer_.setInterval(rnd()); 82 82 … … 101 101 102 102 if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_)) 103 this->target_ = 0; 103 this->target_ = 0;*/ 104 104 } 105 105 } -
code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc
r8706 r8968 57 57 58 58 this->registerVariables(); 59 59 60 } 60 61
Note: See TracChangeset
for help on using the changeset viewer.