Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2011, 10:03:32 PM (13 years ago)
Author:
msalomon
Message:

RaceCheckPoints with a time limit and the version of the level for the presentation.

File:
1 edited

Legend:

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

    r8552 r8616  
    3232#include "core/XMLPort.h"
    3333#include "SpaceRace.h"
     34#include "util/Convert.h"
    3435
    3536namespace orxonox
     
    4748        this->bTimeLimit_ = 0;
    4849       
    49         this->setRadarObjectColour(ColourValue::Red);
    50         this->setRadarObjectShape(RadarViewable::Dot);
     50        this->setRadarObjectColour(ColourValue::Blue);
     51        this->setRadarObjectShape(RadarViewable::Triangle);
    5152        this->setRadarVisibility(false);
    5253    }
     
    6364        if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true);
    6465        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         }
    7366    }
    7467
     
    9285            if (this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
    9386            {
    94                 if (this->getLast())
     87                gametype->clock_->capture();
     88                float time = gametype->clock_->getSecondsPrecise();
     89                if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) {
     90                  gametype->timeIsUp();
     91                  gametype->end();
     92                }
     93                else if (this->getLast())
    9594                {
    9695                  gametype->end();
     
    105104    }
    106105   
     106    void RaceCheckPoint::setTimelimit(float timeLimit)
     107            {
     108              this->bTimeLimit_ = timeLimit;
     109              if (this->bTimeLimit_ != 0)
     110              {
     111                  SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     112                  if (gametype)
     113                  {
     114                     const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
     115                                                   + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1) + "\n";
     116                     COUT(0) << message;
     117                     const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
     118                  }
     119              }
     120            }
     121   
    107122}
Note: See TracChangeset for help on using the changeset viewer.