Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 16, 2011, 4:20:26 PM (13 years ago)
Author:
eceline
Message:

level Spacerace2

Location:
code/branches/spaceraceTwo/src/modules/gametypes
Files:
6 edited

Legend:

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

    r8934 r8940  
    4545
    4646        this->bCheckpointIndex_ = 0;
    47         this->bIsLast_ = false;
     47        //this->bIsLast_ = false;
    4848        this->bTimeLimit_ = 0;
    4949        this->isVisible_=false;
     
    9090    {
    9191        SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
    92 
     92        Vector3 v= Vector3(0,0,0);
    9393        XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
    9494        XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
    9595        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
    96     XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&);
     96    XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
    9797    }
    9898
     
    102102
    103103        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     104        assert(gametype);
    104105        if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player) && bIsTriggered)
    105106        {
     
    115116            else
    116117            {
    117                 gametype->newCheckpointReached(this);
     118                gametype->newCheckpointReached(this,player);
    118119                this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
    119120            }
     
    127128        {
    128129            SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     130            assert(gametype);
    129131            if (gametype)
    130132            {
  • code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h

    r8934 r8940  
    6262                {return this->nextcheckpoints_;}
    6363
    64         inline void setVisibility(bool b)
     64        inline void setV(bool b)
    6565                {this->isVisible_ = b;}
    6666        protected:
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc

    r8934 r8940  
    4545    {
    4646        RegisterObject(SpaceRace);
    47         this->checkpointReached_ = 0;
     47       
    4848        this->bTimeIsUp_ = false;
    4949        this->numberOfBots_ = 0;
    5050        this->cantMove_=false;
    5151       
    52        
     52       for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     53        {this->checkpointReached_[it->first]=0;}
    5354    }
    5455   
     
    136137    }
    137138
    138        
    139        
    140 
    141     void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index)
    142     {
    143         this->checkpointReached_=index;
     139        void SpaceRace::setV(SpaceRaceManager* m){
     140                Vector3 v =Vector3(0,0,0);
     141        int j=0;
     142        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     143        {
     144                j=this->getCheckpointReached(it->first);
     145                RaceCheckPoint* r=m->getCheckpoint(j);
     146                v=r->getNextcheckpoint();
     147                for(int i=1;i<4;i++){
     148                 RaceCheckPoint* n=m->getCheckpoint(i);
     149                 n->setV(true);
     150                 }
     151        }
     152        }
     153
     154    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
     155    {
     156        this->checkpointReached_[pl]=index;
    144157        this->clock_.capture();
    145158        int s = this->clock_.getSeconds();
     
    154167    }
    155168   
    156      void SpaceRace::newCheckpointReached(RaceCheckPoint* p)
     169     void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
    157170    {   int index = p->getCheckpointIndex();
    158         this->checkpointReached_=index;
     171        this->checkpointReached_[pl]=index;
    159172        this->clock_.capture();
    160173        int s = this->clock_.getSeconds();
     
    169182    }
    170183   
    171      int SpaceRace::getCheckpointReached(PlayerInfo* player){
    172         return this->currentCheckpoint_[player];
    173 }
     184   
    174185
    175186void SpaceRace::playerEntered(PlayerInfo* player){
    176         this->currentCheckpoint_[player]=1;
     187        this->checkpointReached_[player]=0;
    177188        this->playersAlive_++;
    178189    }
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h

    r8934 r8940  
    5353    {
    5454        friend class RaceCheckPoint;
    55         friend class SpaceRaceManager;
     55        //friend class SpaceRaceManager;
    5656
    5757        public:
     
    6262            virtual void end();
    6363               
    64             virtual void newCheckpointReached(SpaceRaceManager* p, int index);
    65                 virtual void newCheckpointReached(RaceCheckPoint* p);
     64            virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
     65                virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
    6666
    67             inline void setCheckpointReached(int n)
    68                 { this->checkpointReached_ = n;}
    69             inline int getCheckpointReached()
    70                 { return this->checkpointReached_; }
     67            inline void setCheckpointReached(int n, PlayerInfo* p)
     68                { this->checkpointReached_[p] = n;}
     69            inline int getCheckpointReached(PlayerInfo* p)
     70                { return this->checkpointReached_[p]; }
    7171               
    7272            inline void timeIsUp()
     
    7474        void tick(float dt);
    7575
    76         int getCheckpointReached(PlayerInfo* player);
    7776
    78          
     77         void setV(SpaceRaceManager* m);
    7978        protected:
    8079                virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
     
    8382        float maxSpeedBack_; float maxSpeedFront_; float maxSpeedLeftRight_; float maxSpeedUpDown_;
    8483        bool cantMove_;
    85             int checkpointReached_; //The number of the last check point reached by each player.
     84            std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
    8685            std::set<float> scores_; //The times of the players are saved in a set.
    8786            bool bTimeIsUp_; //True if one of the check points is reached too late.
    8887            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.
    8988
    90                 std::map<PlayerInfo*, int> currentCheckpoint_;
     89               
    9190                int playersAlive_;
    9291
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc

    r8934 r8940  
    2929#include "SpaceRaceManager.h"
    3030#include "SpaceRace.h"
     31#include "infos/PlayerInfo.h"
    3132
    3233#include "core/XMLPort.h"
     
    3940namespace orxonox
    4041{
    41     CreateUnloadableFactory(SpaceRaceManager);
     42    CreateFactory(SpaceRaceManager);
    4243
    4344    SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
     
    7475
    7576        //XMLPortParam(WaypointController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f);
    76         //XMLPortObject(WaypointController, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
     77        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
    7778    }
    7879   
     
    8182    SUPER(SpaceRaceManager,tick,dt);
    8283     SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    83            Vector3 v =Vector3(0,0,0);
    84         int j=0;
    85         for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
    86         {
    87                 j=gametype->getCheckpointReached(it->first);
    88                 RaceCheckPoint* r=this->getCheckpoint(j);
    89                 v=r->getNextcheckpoint();
    90                 for(int i=1;i<4;i++){
    91                  RaceCheckPoint* n=this->getCheckpoint(i);
    92                  n->setVisibility(true);
    93                  }
    94         }
     84     gametype->setV(this);
     85         
     86       
    9587     
    9688    }
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h

    r8928 r8940  
    3434#include <set>
    3535#include <string>
    36 # include <vector>
     36#include <vector>
    3737
    3838#include <util/Clock.h>
Note: See TracChangeset for help on using the changeset viewer.