- Timestamp:
- Dec 13, 2008, 10:54:26 PM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects/worldentities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc
r2361 r2428 38 38 #include "objects/worldentities/Camera.h" 39 39 #include "objects/worldentities/CameraPosition.h" 40 #include "objects/gametypes/Gametype.h" 40 41 #include "overlays/OverlayGroup.h" 41 42 … … 59 60 this->bDestroyWhenPlayerLeft_ = false; 60 61 62 this->gtinfo_ = 0; 63 this->gtinfoID_ = OBJECTID_UNKNOWN; 64 this->changedGametype(); 65 61 66 this->velocity_ = Vector3::ZERO; 62 67 this->acceleration_ = Vector3::ZERO; … … 98 103 99 104 XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode); 105 } 106 107 void ControllableEntity::changedGametype() 108 { 109 SUPER(ControllableEntity, changedGametype); 110 111 this->gtinfo_ = 0; 112 this->gtinfoID_ = OBJECTID_UNKNOWN; 113 114 if (this->getGametype() && this->getGametype()->getGametypeInfo()) 115 { 116 this->gtinfo_ = this->getGametype()->getGametypeInfo(); 117 this->gtinfoID_ = this->gtinfo_->getObjectID(); 118 } 100 119 } 101 120 … … 199 218 } 200 219 220 void ControllableEntity::networkcallback_changedgtinfoID() 221 { 222 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 223 { 224 this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_)); 225 226 if (!this->gtinfo_) 227 this->gtinfoID_ = OBJECTID_UNKNOWN; 228 } 229 } 230 201 231 void ControllableEntity::startLocalHumanControl() 202 232 { … … 268 298 269 299 REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 300 REGISTERDATA(this->gtinfoID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID)); 270 301 } 271 302 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h
r2362 r2428 46 46 virtual void tick(float dt); 47 47 void registerVariables(); 48 49 virtual void changedGametype(); 48 50 49 51 virtual void setPlayer(PlayerInfo* player); … … 143 145 { return this->bHasHumanController_; } 144 146 147 inline const GametypeInfo* getGametypeInfo() const 148 { return this->gtinfo_; } 149 145 150 protected: 146 151 virtual void startLocalHumanControl(); … … 165 170 166 171 void networkcallback_changedplayerID(); 172 void networkcallback_changedgtinfoID(); 167 173 168 174 unsigned int server_overwrite_; … … 190 196 std::list<CameraPosition*> cameraPositions_; 191 197 std::string cameraPositionTemplate_; 198 199 const GametypeInfo* gtinfo_; 200 unsigned int gtinfoID_; 192 201 }; 193 202 } -
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.