Changeset 8940 for code/branches/spaceraceTwo
- Timestamp:
- Nov 16, 2011, 4:20:26 PM (13 years ago)
- Location:
- code/branches/spaceraceTwo/src/modules/gametypes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
r8934 r8940 45 45 46 46 this->bCheckpointIndex_ = 0; 47 this->bIsLast_ = false;47 //this->bIsLast_ = false; 48 48 this->bTimeLimit_ = 0; 49 49 this->isVisible_=false; … … 90 90 { 91 91 SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); 92 92 Vector3 v= Vector3(0,0,0); 93 93 XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); 94 94 XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false); 95 95 XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); 96 XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&) ;96 XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v); 97 97 } 98 98 … … 102 102 103 103 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 104 assert(gametype); 104 105 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player) && bIsTriggered) 105 106 { … … 115 116 else 116 117 { 117 gametype->newCheckpointReached(this );118 gametype->newCheckpointReached(this,player); 118 119 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 119 120 } … … 127 128 { 128 129 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 130 assert(gametype); 129 131 if (gametype) 130 132 { -
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
r8934 r8940 62 62 {return this->nextcheckpoints_;} 63 63 64 inline void setV isibility(bool b)64 inline void setV(bool b) 65 65 {this->isVisible_ = b;} 66 66 protected: -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
r8934 r8940 45 45 { 46 46 RegisterObject(SpaceRace); 47 this->checkpointReached_ = 0;47 48 48 this->bTimeIsUp_ = false; 49 49 this->numberOfBots_ = 0; 50 50 this->cantMove_=false; 51 51 52 52 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 53 {this->checkpointReached_[it->first]=0;} 53 54 } 54 55 … … 136 137 } 137 138 138 139 140 141 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index) 142 { 143 this->checkpointReached_=index; 139 void SpaceRace::setV(SpaceRaceManager* m){ 140 Vector3 v =Vector3(0,0,0); 141 int j=0; 142 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 143 { 144 j=this->getCheckpointReached(it->first); 145 RaceCheckPoint* r=m->getCheckpoint(j); 146 v=r->getNextcheckpoint(); 147 for(int i=1;i<4;i++){ 148 RaceCheckPoint* n=m->getCheckpoint(i); 149 n->setV(true); 150 } 151 } 152 } 153 154 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 155 { 156 this->checkpointReached_[pl]=index; 144 157 this->clock_.capture(); 145 158 int s = this->clock_.getSeconds(); … … 154 167 } 155 168 156 void SpaceRace::newCheckpointReached(RaceCheckPoint* p )169 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 157 170 { int index = p->getCheckpointIndex(); 158 this->checkpointReached_ =index;171 this->checkpointReached_[pl]=index; 159 172 this->clock_.capture(); 160 173 int s = this->clock_.getSeconds(); … … 169 182 } 170 183 171 int SpaceRace::getCheckpointReached(PlayerInfo* player){ 172 return this->currentCheckpoint_[player]; 173 } 184 174 185 175 186 void SpaceRace::playerEntered(PlayerInfo* player){ 176 this->c urrentCheckpoint_[player]=1;187 this->checkpointReached_[player]=0; 177 188 this->playersAlive_++; 178 189 } -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
r8934 r8940 53 53 { 54 54 friend class RaceCheckPoint; 55 friend class SpaceRaceManager;55 //friend class SpaceRaceManager; 56 56 57 57 public: … … 62 62 virtual void end(); 63 63 64 virtual void newCheckpointReached(SpaceRaceManager* p, int index );65 virtual void newCheckpointReached(RaceCheckPoint* p );64 virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl); 65 virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl); 66 66 67 inline void setCheckpointReached(int n )68 { this->checkpointReached_ = n;}69 inline int getCheckpointReached( )70 { return this->checkpointReached_ ; }67 inline void setCheckpointReached(int n, PlayerInfo* p) 68 { this->checkpointReached_[p] = n;} 69 inline int getCheckpointReached(PlayerInfo* p) 70 { return this->checkpointReached_[p]; } 71 71 72 72 inline void timeIsUp() … … 74 74 void tick(float dt); 75 75 76 int getCheckpointReached(PlayerInfo* player);77 76 78 77 void setV(SpaceRaceManager* m); 79 78 protected: 80 79 virtual void playerEntered(PlayerInfo* player); //!< Initializes values. … … 83 82 float maxSpeedBack_; float maxSpeedFront_; float maxSpeedLeftRight_; float maxSpeedUpDown_; 84 83 bool cantMove_; 85 intcheckpointReached_; //The number of the last check point reached by each player.84 std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player. 86 85 std::set<float> scores_; //The times of the players are saved in a set. 87 86 bool bTimeIsUp_; //True if one of the check points is reached too late. 88 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. 89 88 90 std::map<PlayerInfo*, int> currentCheckpoint_;89 91 90 int playersAlive_; 92 91 -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
r8934 r8940 29 29 #include "SpaceRaceManager.h" 30 30 #include "SpaceRace.h" 31 #include "infos/PlayerInfo.h" 31 32 32 33 #include "core/XMLPort.h" … … 39 40 namespace orxonox 40 41 { 41 Create UnloadableFactory(SpaceRaceManager);42 CreateFactory(SpaceRaceManager); 42 43 43 44 SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator) … … 74 75 75 76 //XMLPortParam(WaypointController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f); 76 //XMLPortObject(WaypointController, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode);77 XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint, xmlelement, mode); 77 78 } 78 79 … … 81 82 SUPER(SpaceRaceManager,tick,dt); 82 83 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 83 Vector3 v =Vector3(0,0,0); 84 int j=0; 85 for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it) 86 { 87 j=gametype->getCheckpointReached(it->first); 88 RaceCheckPoint* r=this->getCheckpoint(j); 89 v=r->getNextcheckpoint(); 90 for(int i=1;i<4;i++){ 91 RaceCheckPoint* n=this->getCheckpoint(i); 92 n->setVisibility(true); 93 } 94 } 84 gametype->setV(this); 85 86 95 87 96 88 } -
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
r8928 r8940 34 34 #include <set> 35 35 #include <string> 36 # 36 #include <vector> 37 37 38 38 #include <util/Clock.h>
Note: See TracChangeset
for help on using the changeset viewer.