Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 12, 2011, 12:31:23 AM (13 years ago)
Author:
dafrick
Message:

Merging tutoriallevel2 branch into tutoriallevel3 branch.

Location:
code/branches/tutoriallevel3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel3

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

    r8327 r8453  
    5959        this->defaultControllableEntity_ = Class(Spectator);
    6060
     61        this->bFirstTick_ = true;
     62       
    6163        this->bAutoStart_ = false;
    6264        this->bForceSpawn_ = false;
     
    112114        SUPER(Gametype, tick, dt);
    113115
     116        // Activate the GametypeInfo.
     117        if(this->bFirstTick_)
     118        {
     119            this->gtinfo_->setActive(true);
     120            this->bFirstTick_ = false;
     121        }
     122
    114123        //count timer
    115124        if (timerIsActive_)
     
    121130        }
    122131
    123         if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
    124             this->gtinfo_->startCountdown_ -= dt;
    125 
    126         if (!this->gtinfo_->bStarted_)
     132        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
     133            this->gtinfo_->countdownStartCountdown(dt);
     134
     135        if (!this->gtinfo_->hasStarted())
    127136            this->checkStart();
    128         else if (!this->gtinfo_->bEnded_)
     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)
     
    270279                }
    271280
     281                if(victim->getPlayer()->isHumanPlayer())
     282                    this->gtinfo_->pawnKilled(victim->getPlayer());
     283
    272284                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
    273285                if (victim->getCamera())
     
    346358                it->second.state_ = PlayerState::Dead;
    347359
    348                 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
     360                if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
    349361                {
    350362                    this->spawnPlayerAsDefaultPawn(it->first);
     
    357369    void Gametype::checkStart()
    358370    {
    359         if (!this->gtinfo_->bStarted_)
    360         {
    361             if (this->gtinfo_->bStartCountdownRunning_)
    362             {
    363                 if (this->gtinfo_->startCountdown_ <= 0)
    364                 {
    365                     this->gtinfo_->bStartCountdownRunning_ = false;
    366                     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);;
    367379                    this->start();
    368380                }
     
    384396                        if (it->first->isHumanPlayer())
    385397                            hashumanplayers = true;
     398
     399                        // Inform the GametypeInfo that the player is ready to spawn.
     400                        // TODO: Can it happen, that that changes?
     401                        if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
     402                            this->gtinfo_->playerReadyToSpawn(it->first);
    386403                    }
    387404                    if (allplayersready && hashumanplayers)
     
    389406                        // If in developer's mode, there is no start countdown.
    390407                        if(Core::getInstance().inDevMode())
    391                             this->gtinfo_->startCountdown_ = 0;
     408                            this->start();
    392409                        else
    393                             this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    394                         this->gtinfo_->bStartCountdownRunning_ = true;
     410                            this->gtinfo_->setStartCountdown(this->initialStartCountdown_);
     411                        this->gtinfo_->startStartCountdown();
    395412                    }
    396413                }
     
    402419    {
    403420        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     421        {
    404422            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    405423                this->spawnPlayer(it->first);
     424        }
    406425    }
    407426
     
    422441            player->startControl(spawnpoint->spawn());
    423442            this->players_[player].state_ = PlayerState::Alive;
     443
     444            if(player->isHumanPlayer())
     445                this->gtinfo_->playerSpawned(player);
     446           
    424447            this->playerPostSpawn(player);
    425448        }
Note: See TracChangeset for help on using the changeset viewer.