Changeset 9016 for code/trunk/src/modules/gametypes/SpaceRace.cc
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/gametypes/SpaceRace.cc
r8858 r9016 29 29 #include "SpaceRace.h" 30 30 31 32 #include "items/Engine.h" 33 31 34 #include "core/CoreIncludes.h" 32 35 #include "chat/ChatManager.h" 33 36 #include "util/Convert.h" 34 37 #include "util/Math.h" 38 39 #include "items/Engine.h" 35 40 36 41 namespace orxonox … … 41 46 { 42 47 RegisterObject(SpaceRace); 43 this->checkpointsReached_ = 0;48 44 49 this->bTimeIsUp_ = false; 45 50 this->numberOfBots_ = 0; 51 this->cantMove_=false; 52 46 53 } 54 55 56 // void SpaceRace::SetConfigValues(){ 57 //SUPER(Gametype,setConfigValues); 58 //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);} 47 59 48 60 void SpaceRace::end() … … 56 68 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 57 69 const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 58 + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1) 59 + " before the time limit. You lose!"; 70 + "You didn't reach the check point before the time limit. You lose!"; 60 71 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 61 72 ChatManager::message(message); … … 70 81 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 71 82 ChatManager::message(message); 72 /* 83 73 84 float time = this->clock_.getSecondsPrecise(); 74 85 this->scores_.insert(time); 75 86 std::set<float>::iterator it; 76 for (it=this->scores_.begin(); it!=this->scores_.end(); it++) 77 orxout(level::message) << multi_cast<std::string>(*it) << endl; 78 */ 87 88 79 89 } 80 90 } … … 82 92 void SpaceRace::start() 83 93 { 84 Gametype::start();85 94 86 std::string message("The match has started! Reach the check points as quickly as possible!"); 95 this->spawnPlayersIfRequested(); 96 Gametype::checkStart(); 97 this->cantMove_=true; 98 99 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 100 { 101 it->setActive(false); 102 103 } 104 this->addBots(this->numberOfBots_); 105 } 106 107 void SpaceRace::tick(float dt) 108 { 109 SUPER(SpaceRace,tick,dt); 110 111 if(!this->isStartCountdownRunning() && this->cantMove_) 112 { 113 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 114 { 115 it->setActive(true); 116 117 } 118 this->cantMove_= false; 119 120 std::string message("The match has started! Reach the check points as quickly as possible!"); 121 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 122 ChatManager::message(message); 123 } 124 125 } 126 127 128 129 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 130 { 131 this->checkpointReached_[pl]=index; 132 this->clock_.capture(); 133 int s = this->clock_.getSeconds(); 134 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 135 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 136 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 137 + " seconds.";// Message is too long for a normal screen. 87 138 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 88 139 ChatManager::message(message); 89 140 } 90 91 void SpaceRace::newCheckpointReached() 92 { 93 this->checkpointsReached_++; 141 142 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 143 { 144 int index = p->getCheckpointIndex(); 145 this->checkpointReached_[pl]=index; 94 146 this->clock_.capture(); 95 147 int s = this->clock_.getSeconds(); 96 148 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 97 const std::string& message = "Checkpoint " + multi_cast<std::string>( this->getCheckpointsReached())98 99 149 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 150 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 151 + " seconds."; 100 152 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 101 153 ChatManager::message(message); 102 154 } 155 156 157 void SpaceRace::playerEntered(PlayerInfo* player) 158 { 159 Gametype::playerEntered(player); 160 161 this->checkpointReached_[player]=-1; 162 //this->playersAlive_++; 163 } 164 165 bool SpaceRace::playerLeft(PlayerInfo* player) 166 { 167 return Gametype::playerLeft(player); 168 // bool valid_player = true; 169 //if (valid_player) 170 // { 171 // this->playersAlive_--; 172 //} 103 173 174 // return valid_player; 175 } 176 177 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 178 { 179 return false; 180 } 181 182 bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator) 183 { 184 return false; 185 } 186 187 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator) 188 { 189 return false; 190 } 104 191 }
Note: See TracChangeset
for help on using the changeset viewer.