Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8959


Ignore:
Timestamp:
Dec 7, 2011, 2:38:31 PM (13 years ago)
Author:
eceline
Message:

RaceCheckPoint::fire doesn't work

Location:
code/branches/spaceraceTwo
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spaceraceTwo/data/levels/Spacerace2.oxw

    r8949 r8959  
    3939        <SpaceRaceManager>
    4040<checkpoints>   
    41         <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="true">
     41        <RaceCheckPoint name="checkpoint1" position="0,-200,100" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints=(1,2,0)>
     42        <attached>
     43            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     44        </attached>
     45        <collisionShapes>
     46            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
     47            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
     48            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
     49            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
     50        </collisionShapes>
     51    </RaceCheckPoint>
     52
     53<RaceCheckPoint name="checkpoint2" position="0,-200,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints=(3,0,0)>
     54        <attached>
     55            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     56        </attached>
     57        <collisionShapes>
     58            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
     59            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
     60            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
     61            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
     62        </collisionShapes>
     63    </RaceCheckPoint>
     64
     65<RaceCheckPoint name="checkpoint3" position="0,-400,200" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints=(3,0,0)>
     66        <attached>
     67            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     68        </attached>
     69        <collisionShapes>
     70            <BoxCollisionShape position="0,0,55"      halfExtents="55, 10, 10" />
     71            <BoxCollisionShape position="0,0,-55"     halfExtents="55, 10, 10" />
     72            <BoxCollisionShape position="55,0,0"      halfExtents="10, 10, 55" />
     73            <BoxCollisionShape position="-55,0,0"     halfExtents="10, 10, 55" />
     74        </collisionShapes>
     75    </RaceCheckPoint>
     76
     77<RaceCheckPoint name="checkpoint4" position="0,-400,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="true">
    4278        <attached>
    4379            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     
    5389</SpaceRaceManager>
    5490
    55  <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 >
    56       <templates>
    57         <Template link=spaceshipassff />
    58       </templates>
    59       <controller>
    60          <WaypointPatrolController alertnessradius=1500 team=0 >
    61             <waypoints>
    62                 <Model scale=0 position="0,2000,2000" />
    63             </waypoints>
    64          </WaypointPatrolController>
    65       </controller>
    66     </SpaceShip>
     91 
    6792
    6893
  • code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc

    r8954 r8959  
    3333#include "core/XMLPort.h"
    3434#include "chat/ChatManager.h"
     35
     36#include <infos/PlayerInfo.h>
    3537
    3638#include "SpaceRace.h"
     
    5153       
    5254           
    53         this->bCheckpointIndex_ = 0;
    54         //this->bIsLast_ = false;
     55       
     56       
    5557        this->bTimeLimit_ = 0;
    5658        this->isVisible_=true;
     
    6062        this->setRadarVisibility(true);
    6163   
     64        this->reached_=NULL;
    6265    //this->addTarget("WorldEntity");
    6366   
     
    7174         if (this->isInitialized())
    7275        {
    73             //for (size_t i = 0; i < 3; ++i)
    74             //   this->nextcheckpoints_[i]->destroy();
     76           for (size_t i = 0; i < this->next_.size(); ++i)
     77                this->next_[i]->destroy();
    7578        }
    7679       //nextcheckpoints_.destroy;
     
    121124        DistanceMultiTrigger::fire((bool)bIsTriggered,player);
    122125       
    123    //SUPER(RaceCheckPoint,fire,bIsTriggered,player);
    124                
    125 
    126         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     126       SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    127127        assert(gametype);
    128128       
    129                  PlayerInfo* player2 = (PlayerInfo*)player;
    130         assert(player2);
    131                 //DistanceMultiTrigger::fire(bIsTriggered,player);
     129       
     130       
     131       // BaseObject b=*player;
     132       //  PlayerInfo* p = orxonox_cast<PlayerInfo*,Player>(player);
     133        //assert(player);
     134       //PlayerInfo* player3=((PlayerInfo*) player);
     135       Player* player3=((Player*) player);
     136     
     137      PlayerInfo* player2=( PlayerInfo*) player;
     138       
     139       for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
     140        {
     141          unsigned int clientid1=0, clientid2=0,clientid3=0;
     142          if(it->first !=NULL)clientid1 = it->first->getClientID();
     143         
     144          if(player3 != NULL && player3->info_ != NULL)clientid2 =         player3->info_->getClientID();
     145          if(player2 != NULL )clientid3 =         player2->getClientID();
     146          orxout()<<clientid1<<endl;orxout()<<clientid2<<endl;orxout()<<clientid3<<endl;
     147        orxout()<<"for"<<endl;if(clientid1==clientid2) {orxout()<<"player"<<endl; player2=it->first;}if((it->first)==player2) {orxout()<<"player2"<<endl; }}
     148       
     149        // PlayerInfo* player2 = orxonox_cast<PlayerInfo*>(player);
     150       // assert(player);
     151        //gametype->newCheckpointReached(this,player);
     152        //if(bIsTriggered)this->reached_=player2;
     153       
     154        /* for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
     155        {if(gametype->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;if(player2==it->first)orxout()<<"e"<<endl;}
     156        if(gametype->getCheckpointReached(player2)==-1) orxout()<<"my index -1"<<endl;
     157   orxout()<<gametype->getCheckpointReached(player2)<<endl;
     158         
    132159               
     160                RaceCheckPoint* check=gametype->getCheckpointReached(player2);
    133161               
     162        bool b =false; 
     163        for(int i=0;i<3;i++){
     164       
     165        if (check->getNext[i]==this){
     166                b=true;}
     167        }       
     168       
    134169               
    135        
    136                
    137         if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player2) && bIsTriggered)
     170        if (gametype && b && bIsTriggered)
    138171        {
    139172            gametype->clock_.capture();
     
    147180                gametype->end();
    148181            else
     182                gametype->newCheckpointReached(this,player2)
    149183            {
    150                 gametype->newCheckpointReached(this,player2);
     184               
    151185                this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
    152186            }
    153         }
     187        }*/
     188 
     189               
     190
     191     
    154192    }
    155193
  • code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h

    r8954 r8959  
    3232#include "gametypes/GametypesPrereqs.h"
    3333
     34
     35
    3436#include "objects/triggers/DistanceMultiTrigger.h"
    3537#include "interfaces/RadarViewable.h"
     
    6264                {return this->nextcheckpoints_;}
    6365
     66        inline void setNext(int index,RaceCheckPoint* p)
     67                {this->next_[index]=p;}
     68 inline void setLast(bool isLast)
     69                { this->bIsLast_ = isLast; }
     70            inline bool getLast()
     71                { return this->bIsLast_; }
     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.
     74        PlayerInfo* reached_;
     75               
    6476        inline void setV(bool b)
    6577                {this->isVisible_ = b;}
    6678        protected:
    6779            virtual void fire(bool bIsTriggered,BaseObject* player);
    68             inline void setLast(bool isLast)
    69                 { this->bIsLast_ = isLast; }
    70             inline bool getLast()
    71                 { return this->bIsLast_; }
    72            
     80           
    7381       
    74                
    7582
    7683            virtual void setTimelimit(float timeLimit);
     
    8289        private:
    8390            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.
    84             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.
    85             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.
    86 
     91           
    8792       
    8893        Vector3 nextcheckpoints_; //the indexes of the next check points
    8994
    9095        bool isVisible_;
    91      
     96
     97       
     98      std::vector<RaceCheckPoint*> next_;
    9299    };
    93100}
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc

    r8954 r8959  
    2929#include "SpaceRace.h"
    3030
     31//#include "SpaceRaceManager.h"
     32
    3133#include "items/Engine.h"
    3234
     
    5456       
    5557       for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    56         {this->checkpointReached_[it->first]=0;}
     58        {this->checkpointReached_[it->first]=-1;}
    5759       
    5860       
     
    140142     
    141143    }
    142      
    143    
    144     }
    145 
    146         void SpaceRace::setV(SpaceRaceManager* m){
    147                 /*Vector3 v =Vector3(0,0,0);
     144    // for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     145      //  {if(this->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;}
     146   
     147    }
     148
     149        void SpaceRace::setV(SpaceRaceManager* m){/*
     150                Vector3 v =Vector3(0,0,0);
    148151        int j=0;
    149152        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    161164
    162165    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
    163     {
     166    {/*
    164167        this->checkpointReached_[pl]=index;
    165168        this->clock_.capture();
     
    171174        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    172175        ChatManager::message(message);
    173        
     176       */
    174177       
    175178    }
     
    194197void SpaceRace::playerEntered(PlayerInfo* player){
    195198        Gametype::playerEntered(player);
    196         //this->checkpointReached_[player]=0;
     199       
     200        this->checkpointReached_[player]=-1;
    197201        //this->playersAlive_++;
    198202    }
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h

    r8940 r8959  
    7373                { this->bTimeIsUp_ = true;}
    7474        void tick(float dt);
     75Clock 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.
    7576
    7677
     
    8586            std::set<float> scores_; //The times of the players are saved in a set.
    8687            bool bTimeIsUp_; //True if one of the check points is reached too late.
    87             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.
    88 
     88           
    8989               
    9090                int playersAlive_;
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc

    r8949 r8959  
    4646        RegisterObject(SpaceRaceManager);
    4747         
     48         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     49                this->setNext(this->checkpoints_[i]);
    4850         
    4951    }
     
    7173    }
    7274   
     75    int SpaceRaceManager::getIndex(RaceCheckPoint* r)
     76    {
     77       
     78                 for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     79                if (this->checkpoints_[i]==r){return i;}
     80           
     81         
     82       
     83            return -1;
     84    }
     85   
    7386     void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7487    {
     
    8598     gametype->setV(this);
    8699         
     100         
     101         for (size_t i = 0; i < this->checkpoints_.size(); ++i){
     102                if(this->checkpoints_[i]->reached_!=NULL)
     103                this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_);
     104         
     105     }
     106    }
     107   
     108   
     109    void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player){
     110         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     111        assert(gametype);
     112       
     113        //if(gametype->getCheckpointReached(player)==-1) {orxout()<<"index -1"<<endl;}
     114   
     115                 bool b =false;
     116                //DistanceMultiTrigger::fire(bIsTriggered,player);
     117                int index=gametype->getCheckpointReached(player);
     118                if (index>-1){
     119                RaceCheckPoint* tmp= this->getCheckpoint(index);
     120                Vector3 v= tmp->getNextcheckpoint();
     121       
     122       // orxout()<<"index not -1"<<endl;
     123        if (this->getCheckpoint(v.x)==check){
     124                b=true;
     125        }       
     126       
     127       if (this->getCheckpoint(v.y)==check){
     128                b=true;
     129        }       
     130       if (this->getCheckpoint(v.z)==check){
     131                b=true;
     132        }       }
     133        else{b=(this->getIndex(check)==0);}
     134               
     135        if (gametype && b)
     136        {
     137            gametype->clock_.capture();
     138            float time = gametype->clock_.getSecondsPrecise();
     139            if (check->bTimeLimit_!=0 && time > check->bTimeLimit_)
     140            {
     141                gametype->timeIsUp();
     142                gametype->end();
     143            }
     144            else if (check->getLast())
     145                gametype->end();
     146            else
     147            {
     148                gametype->newCheckpointReached(check,player);
     149                check->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
     150            }
     151        }
     152        check->reached_=NULL;
     153    }
     154   
     155   
     156   
     157    void SpaceRaceManager::setNext(RaceCheckPoint* check){
    87158       
    88      
     159        Vector3 v=check->getNextcheckpoint();
     160                check->setNext(0,this->getCheckpoint(v.x));
     161        check->setNext(1,this->getCheckpoint(v.y));
     162        check->setNext(2,this->getCheckpoint(v.z));
     163        }
     164   
     165   
    89166    }
    90 }
    91167
    92168
     169
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h

    r8940 r8959  
    5858
    5959           void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    60 
     60                int getIndex(RaceCheckPoint* r);
    6161            void addCheckpoint(RaceCheckPoint* checkpoint);
    6262            RaceCheckPoint* getCheckpoint(unsigned int index) const;
    6363               
     64        void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
    6465               
     66        void setNext(RaceCheckPoint* check);
    6567
    6668        void tick(float dt);
Note: See TracChangeset for help on using the changeset viewer.