Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2011, 5:10:01 PM (13 years ago)
Author:
dafrick
Message:

Merging tutoriallevel3 branch into presentation branch.

Location:
code/branches/presentation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/gametypes/Gametype.cc

    r8631 r8637  
    5858
    5959        this->defaultControllableEntity_ = Class(Spectator);
    60 
     60       
    6161        this->bAutoStart_ = false;
    6262        this->bForceSpawn_ = false;
     
    121121        }
    122122
    123         if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
    124             this->gtinfo_->startCountdown_ -= dt;
    125 
    126         if (!this->gtinfo_->bStarted_)
     123        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
     124            this->gtinfo_->countdownStartCountdown(dt);
     125
     126        if (!this->gtinfo_->hasStarted())
     127        {
     128            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     129            {
     130                // Inform the GametypeInfo that the player is ready to spawn.
     131                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
     132                    this->gtinfo_->playerReadyToSpawn(it->first);
     133            }
     134                   
    127135            this->checkStart();
    128         else if (!this->gtinfo_->bEnded_)
     136        }
     137        else if (!this->gtinfo_->hasEnded())
    129138            this->spawnDeadPlayersIfRequested();
    130139
     
    136145        this->addBots(this->numberOfBots_);
    137146
    138         this->gtinfo_->bStarted_ = true;
     147        this->gtinfo_->start();
    139148
    140149        this->spawnPlayersIfRequested();
     
    143152    void Gametype::end()
    144153    {
    145         this->gtinfo_->bEnded_ = true;
     154        this->gtinfo_->end();
    146155
    147156        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    173182    {
    174183        this->players_[player].state_ = PlayerState::Joined;
     184        this->gtinfo_->playerEntered(player);
    175185    }
    176186
     
    269279                    }
    270280                }
     281
     282                if(victim->getPlayer()->isHumanPlayer())
     283                    this->gtinfo_->pawnKilled(victim->getPlayer());
    271284
    272285                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
     
    345358                it->second.state_ = PlayerState::Dead;
    346359
    347                 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
     360                if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
    348361                {
    349362                    this->spawnPlayerAsDefaultPawn(it->first);
     
    356369    void Gametype::checkStart()
    357370    {
    358         if (!this->gtinfo_->bStarted_)
    359         {
    360             if (this->gtinfo_->bStartCountdownRunning_)
    361             {
    362                 if (this->gtinfo_->startCountdown_ <= 0)
    363                 {
    364                     this->gtinfo_->bStartCountdownRunning_ = false;
    365                     this->gtinfo_->startCountdown_ = 0;
     371        if (!this->gtinfo_->hasStarted())
     372        {
     373            if (this->gtinfo_->isStartCountdownRunning())
     374            {
     375                if (this->gtinfo_->getStartCountdown() <= 0.0f)
     376                {
     377                    this->gtinfo_->stopStartCountdown();
     378                    this->gtinfo_->setStartCountdown(0.0f);;
    366379                    this->start();
    367380                }
     
    388401                        // If in developer's mode, there is no start countdown.
    389402                        if(Core::getInstance().inDevMode())
    390                             this->gtinfo_->startCountdown_ = 0;
     403                            this->start();
    391404                        else
    392                             this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    393                         this->gtinfo_->bStartCountdownRunning_ = true;
     405                            this->gtinfo_->setStartCountdown(this->initialStartCountdown_);
     406                        this->gtinfo_->startStartCountdown();
    394407                    }
    395408                }
     
    401414    {
    402415        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     416        {
    403417            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    404418                this->spawnPlayer(it->first);
     419        }
    405420    }
    406421
     
    421436            player->startControl(spawnpoint->spawn());
    422437            this->players_[player].state_ = PlayerState::Alive;
     438
     439            if(player->isHumanPlayer())
     440                this->gtinfo_->playerSpawned(player);
     441           
    423442            this->playerPostSpawn(player);
    424443        }
  • code/branches/presentation/src/orxonox/gametypes/Gametype.h

    r8178 r8637  
    7878
    7979            inline bool hasStarted() const
    80                 { return this->gtinfo_->bStarted_; }
     80                { return this->gtinfo_->hasStarted(); }
    8181            inline bool hasEnded() const
    82                 { return this->gtinfo_->bEnded_; }
     82                { return this->gtinfo_->hasEnded(); }
    8383
    8484            virtual void start();
     
    114114
    115115            inline bool isStartCountdownRunning() const
    116                 { return this->gtinfo_->bStartCountdownRunning_; }
     116                { return this->gtinfo_->isStartCountdownRunning(); }
    117117            inline float getStartCountdown() const
    118                 { return this->gtinfo_->startCountdown_; }
     118                { return this->gtinfo_->getStartCountdown(); }
    119119
    120120            inline void setHUDTemplate(const std::string& name)
    121                 { this->gtinfo_->hudtemplate_ = name; }
     121                { this->gtinfo_->setHUDTemplate(name); }
    122122            inline const std::string& getHUDTemplate() const
    123                 { return this->gtinfo_->hudtemplate_; }
     123                { return this->gtinfo_->getHUDTemplate(); }
    124124
    125125            void addBots(unsigned int amount);
     
    167167
    168168            SmartPtr<GametypeInfo> gtinfo_;
    169 
     169           
    170170            bool bAutoStart_;
    171171            bool bForceSpawn_;
Note: See TracChangeset for help on using the changeset viewer.