Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 23, 2011, 6:35:35 PM (13 years ago)
Author:
msalomon
Message:
 
Location:
code/branches/spacerace/src/modules/gametypes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc

    r8548 r8552  
    4545        this->bCheckpointIndex_ = 0;
    4646        this->bIsLast_ = false;
    47         this->bTimeLimit_=0;
     47        this->bTimeLimit_ = 0;
    4848       
    4949        this->setRadarObjectColour(ColourValue::Red);
     
    6363        if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true);
    6464        else  this->setRadarVisibility(false);
     65       
     66        if (this->bTimeLimit_ != 0 && gametype->getTimerIsActive()) {
     67          float time = gametype->getTime() - this->bTimeLimit_;
     68          if (time > 0) {
     69            gametype->timeIsUp();
     70            gametype->end();
     71          }
     72        }
    6573    }
    6674
  • code/branches/spacerace/src/modules/gametypes/SpaceRace.cc

    r8428 r8552  
    4343        RegisterObject(SpaceRace);
    4444        this->checkpointsReached_ = 0;
     45        this->bTimeIsUp_ = false;
    4546        this->numberOfBots_ = 0;
    4647    }
     
    5354    void SpaceRace::end()
    5455    {
    55         Gametype::end();
    56         this->clock_->capture();
    57         int s = this->clock_->getSeconds();
    58         int ms = this->clock_->getMilliseconds()-1000*s;
    59         const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +
    60                                       "." + multi_cast<std::string>(ms) + " seconds.";
    61         COUT(0) << message << std::endl;
    62         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    63         Host::Broadcast(message);
    64         float time = this->clock_->getSecondsPrecise();
    65         this->scores_.insert(time);
    66         std::set<float>::iterator it;
    67         for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
     56        Gametype::end();
     57        this->stopTimer();
     58        if (this->bTimeIsUp_) {
     59            COUT(0) << "Time is up" << std::endl;
     60            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up");
     61        }
     62        else {
     63            this->clock_->capture();
     64            int s = this->clock_->getSeconds();
     65            int ms = this->clock_->getMilliseconds()-1000*s;
     66            const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +
     67                                          "." + multi_cast<std::string>(ms) + " seconds.";
     68            COUT(0) << message << std::endl;
     69            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     70            Host::Broadcast(message);
     71            float time = this->clock_->getSecondsPrecise();
     72            this->scores_.insert(time);
     73            std::set<float>::iterator it;
     74            for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
    6875            COUT(0) <<  multi_cast<std::string>(*it) << std::endl;
     76        }
    6977    }
    7078
     
    7381        Gametype::start();
    7482       
     83        this->startTimer();
    7584        clock_= new Clock();
    7685        std::string message("The match has started! Reach the check points as quick as possible!");
  • code/branches/spacerace/src/modules/gametypes/SpaceRace.h

    r8428 r8552  
    7777            inline int getCheckpointsReached()
    7878                { return this->checkpointsReached_; }
     79            inline void timeIsUp()
     80                { this->bTimeIsUp_ = true;}
    7981           
    8082        protected:
     
    8284        private:
    8385            int checkpointsReached_;
     86            std::set<float> scores_;
    8487            Clock *clock_;
    85             std::set<float> scores_;
    86            
     88            bool bTimeIsUp_;
    8789    };
    8890}
Note: See TracChangeset for help on using the changeset viewer.