Changeset 9262 for code/trunk/src
- Timestamp:
- Jun 2, 2012, 11:08:21 PM (13 years ago)
- Location:
- code/trunk/src/modules/gametypes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/RaceCheckPoint.h
r9260 r9262 56 56 inline void setNextcheckpoint(const Vector3& checkpoints) 57 57 { this->nextcheckpoints_ = checkpoints; } 58 inline void setNextcheckpoint(float x, float y, float z)59 { this->setNextcheckpoint(Vector3(x, y, z)); }60 58 inline const Vector3& getNextcheckpoint() const 61 59 { return this->nextcheckpoints_; } -
code/trunk/src/modules/gametypes/SpaceRace.cc
r9261 r9262 78 78 SUPER(SpaceRace,tick,dt); 79 79 80 // spawn the players already when the countdown starts, but deactivate their engines 80 81 if (this->isStartCountdownRunning() && !this->cantMove_) 81 82 { … … 87 88 } 88 89 90 // activate the engines again if the countdown ends 89 91 if (!this->isStartCountdownRunning() && this->cantMove_) 90 92 { … … 104 106 int index = checkpoint->getCheckpointIndex(); 105 107 this->checkpointReached_[player] = index; 108 106 109 this->clock_.capture(); 107 110 int s = this->clock_.getSeconds(); 108 111 int ms = this->clock_.getMilliseconds() % 1000; 109 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 112 113 const std::string& message = "Checkpoint " + multi_cast<std::string>(index + 1) 110 114 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."; 111 115 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); -
code/trunk/src/modules/gametypes/SpaceRace.h
r9261 r9262 61 61 virtual void end(); 62 62 63 virtual void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player); 64 65 inline void setCheckpointReached(int index, PlayerInfo* player) 66 { this->checkpointReached_[player] = index;} 63 void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player); 67 64 inline int getCheckpointReached(PlayerInfo* player) 68 65 { return this->checkpointReached_[player]; } … … 81 78 82 79 private: 83 bool cantMove_; 80 bool cantMove_; ///< Helper variable, used to stall the engines before the race starts. 84 81 std::map<PlayerInfo*, int> checkpointReached_; ///< The number of the last check point reached by each player. 85 82 bool bTimeIsUp_; ///< True if one of the check points is reached too late. -
code/trunk/src/modules/gametypes/SpaceRaceManager.cc
r9260 r9262 94 94 } 95 95 96 int SpaceRaceManager::getIndex(RaceCheckPoint* checkpoint) 96 /** 97 @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex). 98 */ 99 RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const 97 100 { 98 101 for (size_t i = 0; i < this->checkpoints_.size(); ++i) 99 if (this->checkpoints_[i] == checkpoint) 100 return i; 101 102 return -1; 102 if (this->checkpoints_[i]->getCheckpointIndex() == index) 103 return this->checkpoints_[i]; 104 return 0; 103 105 } 104 106 … … 113 115 if (index > -1) 114 116 { 115 Vector3 v = this-> getCheckpoint(index)->getNextcheckpoint();117 Vector3 v = this->findCheckpoint(index)->getNextcheckpoint(); 116 118 117 if (this-> getCheckpoint(v.x) == check)119 if (this->findCheckpoint(v.x) == check) 118 120 { 119 121 reachedValidCheckpoint = true; 120 122 } 121 if (this-> getCheckpoint(v.y) == check)123 if (this->findCheckpoint(v.y) == check) 122 124 { 123 125 reachedValidCheckpoint = true; 124 126 } 125 if (this-> getCheckpoint(v.z) == check)127 if (this->findCheckpoint(v.z) == check) 126 128 { 127 129 reachedValidCheckpoint = true; … … 130 132 else 131 133 { 132 reachedValidCheckpoint = ( this->getIndex(check) == 0);134 reachedValidCheckpoint = (check->getCheckpointIndex() == 0); 133 135 } 134 136 … … 147 149 { 148 150 if (index > -1) 149 this->setRad Vis(player, false);151 this->setRadarVisibility(player, false); 150 152 else 151 this-> getCheckpoint(0)->setRadarVisibility(false);153 this->findCheckpoint(0)->setRadarVisibility(false); 152 154 153 155 gametype->newCheckpointReached(check, player); 154 this->setRad Vis(player, true);156 this->setRadarVisibility(player, true); 155 157 } 156 158 } … … 159 161 } 160 162 161 void SpaceRaceManager::setRad Vis(PlayerInfo* player, bool bVisible)163 void SpaceRaceManager::setRadarVisibility(PlayerInfo* player, bool bVisible) 162 164 { 163 165 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 164 166 assert(gametype); 165 167 int index = gametype->getCheckpointReached(player); 166 Vector3 v = this-> getCheckpoint(index)->getNextcheckpoint();168 Vector3 v = this->findCheckpoint(index)->getNextcheckpoint(); 167 169 168 170 if (v.x > -1) 169 171 { 170 this-> getCheckpoint(v.x)->setRadarVisibility(bVisible);171 this-> getCheckpoint(v.x)->settingsChanged();172 this->findCheckpoint(v.x)->setRadarVisibility(bVisible); 173 this->findCheckpoint(v.x)->settingsChanged(); 172 174 } 173 175 if (v.y > -1) 174 176 { 175 this-> getCheckpoint(v.y)->setRadarVisibility(bVisible);176 this-> getCheckpoint(v.y)->settingsChanged();177 this->findCheckpoint(v.y)->setRadarVisibility(bVisible); 178 this->findCheckpoint(v.y)->settingsChanged(); 177 179 } 178 180 if (v.z > -1) 179 181 { 180 this-> getCheckpoint(v.z)->setRadarVisibility(bVisible);181 this-> getCheckpoint(v.z)->settingsChanged();182 this->findCheckpoint(v.z)->setRadarVisibility(bVisible); 183 this->findCheckpoint(v.z)->settingsChanged(); 182 184 } 183 185 } -
code/trunk/src/modules/gametypes/SpaceRaceManager.h
r9260 r9262 62 62 void addCheckpoint(RaceCheckPoint* checkpoint); 63 63 RaceCheckPoint* getCheckpoint(unsigned int index) const; 64 int getIndex(RaceCheckPoint* checkpoint); 64 65 RaceCheckPoint* findCheckpoint(int index) const; 65 66 66 67 void checkpointReached(RaceCheckPoint* check, PlayerInfo* player); … … 69 70 70 71 protected: 71 void setRad Vis(PlayerInfo* player, bool bVisible); ///< sets RadarVisibility of the checkpoints the player can reach.72 void setRadarVisibility(PlayerInfo* player, bool bVisible); ///< sets RadarVisibility of the checkpoints the player can reach. 72 73 73 74 private:
Note: See TracChangeset
for help on using the changeset viewer.