- Timestamp:
- Dec 13, 2008, 10:54:26 PM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2422 r2428 57 57 this->roll_ = 0; 58 58 this->setHudTemplate("spectatorhud"); 59 this->hudmode_ = 0;60 59 61 60 this->setDestroyWhenPlayerLeft(true); … … 96 95 REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 97 96 REGISTERDATA(this->bGreeting_, direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 98 REGISTERDATA(this->hudmode_, direction::toclient);99 97 } 100 98 … … 112 110 void Spectator::tick(float dt) 113 111 { 114 this->updateHUD();115 116 112 if (this->hasLocalController()) 117 113 { … … 193 189 } 194 190 } 195 196 void Spectator::updateHUD()197 {198 // <hack>199 if (Core::isMaster())200 {201 if (this->getPlayer() && this->getGametype())202 {203 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())204 {205 if (!this->getPlayer()->isReadyToSpawn())206 this->hudmode_ = 0;207 else208 this->hudmode_ = 1;209 }210 else if (!this->getGametype()->hasEnded())211 {212 if (this->getGametype()->isStartCountdownRunning())213 this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());214 else215 this->hudmode_ = 3;216 }217 else218 this->hudmode_ = 4;219 }220 else221 return;222 }223 224 if (this->getHUD())225 {226 std::string text;227 int hudmode = this->hudmode_ % 10;228 229 switch (hudmode)230 {231 case 0:232 text = "Press [Fire] to start the match";233 break;234 case 1:235 text = "Waiting for other players";236 break;237 case 2:238 text = convertToString((this->hudmode_ - 2) / 10);239 break;240 case 3:241 text = "Press [Fire] to respawn";242 break;243 case 4:244 text = "Game has ended";245 break;246 default:;247 }248 249 std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();250 for (; it != this->getHUD()->getOverlays().end(); ++it)251 {252 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")253 {254 OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);255 if (overlay)256 overlay->setCaption(text);257 break;258 }259 }260 }261 // </hack>262 }263 191 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.h
r2362 r2428 63 63 void changedGreeting(); 64 64 void changedFlareVisibility(); 65 void updateHUD();66 65 67 66 BillboardSet* greetingFlare_; … … 75 74 float pitch_; 76 75 float roll_; 77 78 int hudmode_;79 76 }; 80 77 }
Note: See TracChangeset
for help on using the changeset viewer.