Changeset 9260 for code/trunk/src/modules/gametypes/SpaceRace.cc
- Timestamp:
- Jun 2, 2012, 10:34:48 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/SpaceRace.cc
r9016 r9260 29 29 #include "SpaceRace.h" 30 30 31 32 31 #include "items/Engine.h" 33 32 … … 46 45 { 47 46 RegisterObject(SpaceRace); 48 47 48 this->cantMove_ = false; 49 49 this->bTimeIsUp_ = false; 50 this->numberOfBots_ = 0;51 this->cantMove_=false;52 53 50 } 54 55 56 // void SpaceRace::SetConfigValues(){57 //SUPER(Gametype,setConfigValues);58 //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}59 51 60 52 void SpaceRace::end() … … 62 54 this->Gametype::end(); 63 55 56 this->clock_.capture(); 57 int s = this->clock_.getSeconds(); 58 int ms = static_cast<int>(this->clock_.getMilliseconds() - 1000*s); 59 std::string message; 60 64 61 if (this->bTimeIsUp_) 65 62 { 66 this->clock_.capture(); 67 int s = this->clock_.getSeconds(); 68 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 69 const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 63 message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 70 64 + "You didn't reach the check point before the time limit. You lose!"; 71 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);72 ChatManager::message(message);73 65 } 74 66 else 75 67 { 76 this->clock_.capture(); 77 int s = this->clock_.getSeconds(); 78 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 79 const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s) 68 message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s) 80 69 + "." + multi_cast<std::string>(ms) + " seconds."; 81 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 82 ChatManager::message(message); 70 } 83 71 84 float time = this->clock_.getSecondsPrecise(); 85 this->scores_.insert(time); 86 std::set<float>::iterator it; 87 88 89 } 72 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 73 ChatManager::message(message); 90 74 } 91 75 92 76 void SpaceRace::start() 93 77 { 78 this->spawnPlayersIfRequested(); 79 Gametype::checkStart(); 80 this->cantMove_ = true; 94 81 95 this->spawnPlayersIfRequested(); 96 Gametype::checkStart(); 97 this->cantMove_=true; 98 99 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 100 { 82 for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 101 83 it->setActive(false); 102 103 } 104 this->addBots(this->numberOfBots_); 84 85 this->addBots(this->numberOfBots_); 105 86 } 106 87 107 88 void SpaceRace::tick(float dt) 108 89 { 109 90 SUPER(SpaceRace,tick,dt); 110 111 if (!this->isStartCountdownRunning() && this->cantMove_)91 92 if (!this->isStartCountdownRunning() && this->cantMove_) 112 93 { 113 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 114 { 94 for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 115 95 it->setActive(true); 116 117 } 96 118 97 this->cantMove_= false; 119 120 std::string message ("The match has started! Reach the check points as quickly as possible!");98 99 std::string message = "The match has started! Reach the check points as quickly as possible!"; 121 100 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 122 ChatManager::message(message); 101 ChatManager::message(message); 123 102 } 124 125 103 } 126 104 127 128 129 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 105 void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player) 130 106 { 131 this->checkpointReached_[pl]=index; 107 int index = checkpoint->getCheckpointIndex(); 108 this->checkpointReached_[player] = index; 132 109 this->clock_.capture(); 133 110 int s = this->clock_.getSeconds(); 134 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);111 int ms = this->clock_.getMilliseconds() % 1000; 135 112 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. 113 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds."; 138 114 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 139 115 ChatManager::message(message); 140 116 } 141 142 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 143 { 144 int index = p->getCheckpointIndex(); 145 this->checkpointReached_[pl]=index; 146 this->clock_.capture(); 147 int s = this->clock_.getSeconds(); 148 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 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."; 152 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 153 ChatManager::message(message); 154 } 155 156 117 157 118 void SpaceRace::playerEntered(PlayerInfo* player) 158 119 { 159 120 Gametype::playerEntered(player); 160 161 this->checkpointReached_[player]=-1; 162 //this->playersAlive_++; 121 122 this->checkpointReached_[player] = -1; 163 123 } 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 //}173 124 174 // return valid_player;175 }176 177 125 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 178 126 {
Note: See TracChangeset
for help on using the changeset viewer.