Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Location:
code/branches/spacerace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spacerace/data/levels/spaceRace.oxw

    r8573 r8616  
    4040
    4141    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     42
     43    <SimpleNotification message="Reach the last check point within 150 seconds!!" />
    4244
    4345    <!-- ------------------SpawnPoint----------------- -->
     
    7274    <attached>
    7375      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    74       <SpawnPoint position="0,0,0" lookat="0,700,2700" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     76      <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    7577        <events>
    7678          <activity>
     
    106108    <attached>
    107109      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    108       <SpawnPoint position="0,0,0" lookat="0,2100,2300" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     110      <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    109111        <events>
    110112          <activity>
     
    141143      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    142144      <DistanceTrigger name="trigger3" position="0,0,0" distance=40 stayActive="true" />
    143       <SpawnPoint position="0,0,0" lookat="0,2200,500" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     145      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    144146        <events>
    145147          <activity>
     
    176178      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    177179      <DistanceTrigger name="trigger4" position="0,0,0" distance=40 stayActive="true" />
    178       <SpawnPoint position="0,0,0" lookat="0,1500,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     180      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    179181         <events>
    180182          <activity>
     
    211213      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    212214      <DistanceTrigger name="trigger5" position="0,0,0" distance=40 stayActive="true" />
    213       <SpawnPoint position="0,0,0" lookat="0,200,-1900" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     215      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    214216        <events>
    215217          <activity>
     
    246248      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    247249      <DistanceTrigger name="trigger6" position="0,0,0" distance=40 stayActive="true" />
    248       <SpawnPoint position="0,0,0" lookat="0,-700,-1400" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     250      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    249251        <events>
    250252          <activity>
     
    281283      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    282284      <DistanceTrigger name="trigger7" position="0,0,0" distance=40 stayActive="true" />
    283       <SpawnPoint position="0,0,0" lookat="0,-1300,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     285      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    284286        <events>
    285287          <activity>
     
    316318      <Model mass="50" scale="50" mesh="checkPoint.mesh" />
    317319      <DistanceTrigger name="trigger8" position="0,0,0" distance=40 stayActive="true" />
    318       <SpawnPoint position="0,0,0" lookat="0,-2400,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
     320      <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
    319321        <events>
    320322          <activity>
     
    443445
    444446    <!-- ---------------SpaceShips----------------- -->
    445     <SpaceShip position="0,2000,2000" lookat="0,0,0" >
     447    <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 >
    446448      <templates>
    447449        <Template link=spaceshipassff />
    448450      </templates>
    449451      <controller>
    450         <AIController />
     452         <WaypointPatrolController alertnessradius=1500 team=0 >
     453              <waypoints>
     454                  <Model scale=0 position="0,2000,2000" />
     455              </waypoints>
     456         </WaypointPatrolController>
    451457      </controller>
    452458    </SpaceShip>
    453459
     460    <SpaceShip position="0,2000,-2000" lookat="0,0,0" team=1 >
     461      <templates>
     462        <Template link=spaceshipassff />
     463      </templates>
     464      <controller>
     465          <WaypointPatrolController alertnessradius=1500 team=0 >
     466                <waypoints>
     467                    <Model scale=0 position="0,2000,-2000" />
     468                </waypoints>
     469          </WaypointPatrolController>
     470      </controller>
     471    </SpaceShip>
     472
    454473  </Scene>
    455474</Level>
  • 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}
  • code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h

    r8548 r8616  
    3838namespace orxonox
    3939{
     40  /**
     41  @brief
     42  The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
     43  !!! Don't forget to controll the indexes of your check points and to set one last check point!!!
     44  */
    4045    class _ObjectsExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
    4146    {
     
    5762        inline int getCheckpointIndex()
    5863            { return this->bCheckpointIndex_; }
    59         inline void setTimelimit(int timeLimit)
    60             { this->bTimeLimit_ = timeLimit;}
    61         inline int getTimeLimit()
     64        virtual void setTimelimit(float timeLimit);
     65        inline float getTimeLimit()
    6266            { return this->bTimeLimit_;}
    6367        inline const WorldEntity* getWorldEntity() const
     
    6569       
    6670    private:
    67         int bCheckpointIndex_;
    68         bool bIsLast_;
    69         int bTimeLimit_;
     71        int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes.
     72        bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
     73        float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
    7074     
    7175    };
  • code/branches/spacerace/src/modules/gametypes/SpaceRace.cc

    r8573 r8616  
    4242    {
    4343        RegisterObject(SpaceRace);
    44         this->checkpointsReached_ = 0;
     44        this->bCheckpointsReached_ = 0;
    4545        this->bTimeIsUp_ = false;
    4646        this->numberOfBots_ = 0;
     
    5555    {
    5656        Gametype::end();
    57         this->stopTimer();
    5857        if (this->bTimeIsUp_) {
    59             COUT(0) << "Time is up" << std::endl;
    60             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up");
     58            this->clock_->capture();
     59            int s = this->clock_->getSeconds();
     60            int ms = this->clock_->getMilliseconds()-1000*s;
     61            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
     62                                         + "You didn't reach the check point" + multi_cast<std::string>(this->bCheckpointsReached_+1)
     63                                         + " before the time limit. You loose!\n";
     64            COUT(0) << message;
     65            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     66            Host::Broadcast(message);
    6167        }
    6268        else {
     
    6470            int s = this->clock_->getSeconds();
    6571            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.";
     72            const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
     73                                          + "." + multi_cast<std::string>(ms) + " seconds.\n";
    6874            COUT(0) << message << std::endl;
    6975            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     
    8187        Gametype::start();
    8288       
    83         this->startTimer();
    8489        clock_= new Clock();
    8590        std::string message("The match has started! Reach the check points as quickly as possible!");
     
    9095    void SpaceRace::newCheckpointReached()
    9196    {
    92         this->checkpointsReached_++;
     97        this->bCheckpointsReached_++;
    9398        this->clock_->capture();
    9499        int s = this->clock_->getSeconds();
     
    96101        const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
    97102                                      + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    98                                       + " seconds.";
     103                                      + " seconds.\n";
    99104        COUT(0) << message << std::endl;
    100105        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
  • code/branches/spacerace/src/modules/gametypes/SpaceRace.h

    r8552 r8616  
    4040namespace orxonox
    4141{
    42 /*    class PlayerScore {
    43         public:
    44             PlayerScore() {
    45                 this->name = "";
    46                 this->time =0;
    47             }
    48             PlayerScore(std::string name, float time) {
    49                 this->name_ = name;
    50                 this->time_ = time;
    51             }
    52             PlayerScore(float time) {
    53                 this->name_ = "Player";
    54                 this->time_ = time;
    55             }
    56        
    57         private:
    58             std::string name_;
    59             float time_;
    60     };*/
    61        
     42  /**
     43  @brief
     44  The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
     45  */
    6246    class _OrxonoxExport SpaceRace : public Gametype
    6347    {
     
    7458           
    7559            inline void setCheckpointsReached(int n)
    76                 { this->checkpointsReached_ = n;}
     60                { this->bCheckpointsReached_ = n;}
    7761            inline int getCheckpointsReached()
    78                 { return this->checkpointsReached_; }
     62                { return this->bCheckpointsReached_; }
    7963            inline void timeIsUp()
    8064                { this->bTimeIsUp_ = true;}
    81            
     65            Clock *clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
    8266        protected:
    8367           
    8468        private:
    85             int checkpointsReached_;
    86             std::set<float> scores_;
    87             Clock *clock_;
    88             bool bTimeIsUp_;
     69            int bCheckpointsReached_; //The current number of check points reached by the player.
     70            std::set<float> scores_; //The times of the players are saved in a set.
     71            bool bTimeIsUp_; //True if one of the check points is reached too late.
    8972    };
    9073}
Note: See TracChangeset for help on using the changeset viewer.