Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 10:54:26 PM (15 years ago)
Author:
landauf
Message:
  • Moved some variables from Gametype to GametypeInfo (Gametype exists only on the Server while GametypeInfo is synchronized)
  • Created a new HUD-element, GametypeStatus, based on GametypeInfo (the same effect was formerly achieved by using a hack in Spectator and a TextOverlay)
  • HumanController creates a HUD (additionally to the SpaceShips HUD) which includes GametypeStatus and ChatOverlay and even more in the future
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2422 r2428  
    5757        this->roll_ = 0;
    5858        this->setHudTemplate("spectatorhud");
    59         this->hudmode_ = 0;
    6059
    6160        this->setDestroyWhenPlayerLeft(true);
     
    9695        REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    9796        REGISTERDATA(this->bGreeting_,             direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    98         REGISTERDATA(this->hudmode_,               direction::toclient);
    9997    }
    10098
     
    112110    void Spectator::tick(float dt)
    113111    {
    114         this->updateHUD();
    115 
    116112        if (this->hasLocalController())
    117113        {
     
    193189        }
    194190    }
    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                     else
    208                         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                     else
    215                         this->hudmode_ = 3;
    216                 }
    217                 else
    218                     this->hudmode_ = 4;
    219             }
    220             else
    221                 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     }
    263191}
Note: See TracChangeset for help on using the changeset viewer.