Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8968


Ignore:
Timestamp:
Dec 8, 2011, 6:07:32 PM (13 years ago)
Author:
eceline
Message:

added waypoint patrol controller to level, RaceCheckPoint::fire works now

Location:
code/branches/spaceraceTwo
Files:
9 edited

Legend:

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

    r8959 r8968  
    3939        <SpaceRaceManager>
    4040<checkpoints>   
    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)>
     41        <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints="1,2,0">
    4242        <attached>
    4343            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     
    5151    </RaceCheckPoint>
    5252
    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)>
     53<RaceCheckPoint name="checkpoint2" position="0,2100,2300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints="3,-1,-1">
    5454        <attached>
    5555            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     
    6363    </RaceCheckPoint>
    6464
    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)>
     65<RaceCheckPoint name="checkpoint3" position="0,700,2700" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints="3,-1,-1">
    6666        <attached>
    6767            <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
     
    9090
    9191 
    92 
     92<SpaceShip position="0,0,200" lookat="0,0,0">
     93      <templates>
     94        <Template link=spaceshipassff />
     95      </templates>
     96      <controller>
     97        <WaypointPatrolController alertnessradius=1000 team=10>
     98          <waypoints>
     99            <Model mesh="cube.mesh" scale=8 position="0,-2000,1000" />
     100            <Model mesh="cube.mesh" scale=8 position="0,2100,2300" />
     101            <Model mesh="cube.mesh" scale=8 position="0,-400,300" />
     102          </waypoints>
     103        </WaypointPatrolController>
     104      </controller>
     105    </SpaceShip>
    93106
    94107    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 />
  • code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc

    r8960 r8968  
    3535
    3636#include <infos/PlayerInfo.h>
     37#include <worldentities/ControllableEntity.h>
    3738
    3839#include "SpaceRace.h"
     
    5657       
    5758        this->bTimeLimit_ = 0;
    58         this->isVisible_=true;
     59       
    5960
    6061        this->setRadarObjectColour(ColourValue::Blue);
    6162        this->setRadarObjectShape(RadarViewable::Triangle);
    62         this->setRadarVisibility(true);
    63    
     63       
     64        this->setRadarVisibility(false);
     65        this->settingsChanged();
    6466        this->reached_=NULL;
    6567    //this->addTarget("WorldEntity");
     
    7274    {
    7375   
    74          if (this->isInitialized())
    75         {
    76            for (size_t i = 0; i < this->next_.size(); ++i)
    77                 this->next_[i]->destroy();
    78         }
    79        //nextcheckpoints_.destroy;
     76       
     77       
     78     
    8079    }
    8180
     
    8685        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    8786        assert(gametype);
    88         if(this->isVisible_){this->setRadarVisibility(true);}
    89         else{this->setRadarVisibility(false);}
    9087       
    91      
    92      
    93        
    94         /*this->setRadarVisibility(false);
    95         Vector3 v =Vector3(0,0,0);
    96         int j=0;
    97         for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
    98         {
    99                 j=gametype->getCheckpointReached(it->first);
    100                 RaceCheckPoint* r=SpaceRaceManager::getCheckpoint(j);
    101                 v=r->getNextcheckpoint();
    102                 for(int i=1;i<4;i++){
    103                 if (this->getCheckpointIndex() == v[i])
    104                  this->setRadarVisibility(true);
    105                  }*/
    106         //}     
    10788    }
    10889
     
    119100        void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
    120101    {
    121        
    122         //bool b= bIsTriggered;
    123         //PlayerInfo* pl= player;
    124102        DistanceMultiTrigger::fire((bool)bIsTriggered,player);
    125103       
    126104       SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    127105        assert(gametype);
    128        
    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->second.info_ !=NULL)clientid1 = it->second.info_->getClientID();else orxout()<<"second NULL"<<endl;
    143            if(it->first !=NULL)clientid1 = it->first->getClientID();else orxout()<<"first NULL"<<endl;
    144            clientid1 = it->first->getClientID();
    145           if(player3 != NULL && player3->info_ != NULL)clientid2 =         player3->info_->getClientID();
    146           if(player2 != NULL )clientid3 =         player2->getClientID();
    147           orxout()<<clientid1<<endl;orxout()<<clientid2<<endl;orxout()<<clientid3<<endl;
    148         orxout()<<"for"<<endl;if(clientid1==clientid2) {orxout()<<"player"<<endl; player2=it->first;}if((it->first)==player2) {orxout()<<"player2"<<endl; }}
    149        
    150         // PlayerInfo* player2 = orxonox_cast<PlayerInfo*>(player);
    151        // assert(player);
    152         //gametype->newCheckpointReached(this,player);
    153         //if(bIsTriggered)this->reached_=player2;
    154        
    155         /* for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
    156         {if(gametype->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;if(player2==it->first)orxout()<<"e"<<endl;}
    157         if(gametype->getCheckpointReached(player2)==-1) orxout()<<"my index -1"<<endl;
    158    orxout()<<gametype->getCheckpointReached(player2)<<endl;
    159          
    160                
    161                 RaceCheckPoint* check=gametype->getCheckpointReached(player2);
    162                
    163         bool b =false; 
    164         for(int i=0;i<3;i++){
    165        
    166         if (check->getNext[i]==this){
    167                 b=true;}
    168         }       
    169        
    170                
    171         if (gametype && b && bIsTriggered)
    172         {
    173             gametype->clock_.capture();
    174             float time = gametype->clock_.getSecondsPrecise();
    175             if (this->bTimeLimit_!=0 && time > this->bTimeLimit_)
    176             {
    177                 gametype->timeIsUp();
    178                 gametype->end();
    179             }
    180             else if (this->getLast())
    181                 gametype->end();
    182             else
    183                 gametype->newCheckpointReached(this,player2)
    184             {
    185                
    186                 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
    187             }
    188         }*/
    189  
    190                
    191 
    192      
     106     ControllableEntity* entity=(ControllableEntity*) player;
     107     
     108      PlayerInfo* player2=entity->getPlayer();
     109     
     110        if(bIsTriggered)this->reached_=player2;
    193111    }
    194112
  • code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h

    r8959 r8968  
    6464                {return this->nextcheckpoints_;}
    6565
    66         inline void setNext(int index,RaceCheckPoint* p)
    67                 {this->next_[index]=p;}
     66       
    6867 inline void setLast(bool isLast)
    6968                { this->bIsLast_ = isLast; }
     
    7473        PlayerInfo* reached_;
    7574               
    76         inline void setV(bool b)
    77                 {this->isVisible_ = b;}
     75        inline float getTimeLimit()
     76                { return this->bTimeLimit_;}
    7877        protected:
    7978            virtual void fire(bool bIsTriggered,BaseObject* player);
     
    8281
    8382            virtual void setTimelimit(float timeLimit);
    84             inline float getTimeLimit()
    85                 { return this->bTimeLimit_;}
     83           
    8684            inline const WorldEntity* getWorldEntity() const
    8785                { return this; }
     
    9391        Vector3 nextcheckpoints_; //the indexes of the next check points
    9492
    95         bool isVisible_;
    96 
     93       
    9794       
    9895      std::vector<RaceCheckPoint*> next_;
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc

    r8959 r8968  
    2929#include "SpaceRace.h"
    3030
    31 //#include "SpaceRaceManager.h"
    3231
    3332#include "items/Engine.h"
     
    10099    void SpaceRace::start()
    101100    {
    102                 //Gametype::start();
    103                            this->spawnPlayersIfRequested(); Gametype::checkStart();
     101               
     102                           this->spawnPlayersIfRequested();
     103                           
     104                            Gametype::checkStart();
    104105                           this->cantMove_=true;
    105106         
     
    142143     
    143144    }
    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;}
     145   
    146146   
    147147    }
    148148
    149         void SpaceRace::setV(SpaceRaceManager* m){/*
    150                 Vector3 v =Vector3(0,0,0);
    151         int j=0;
    152         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    153         {
    154                 j=this->getCheckpointReached(it->first);
    155                 RaceCheckPoint* r=m->getCheckpoint(j);
    156                 v=r->getNextcheckpoint();
    157                 for(int i=1;i<4;i++){
    158                 if(v[i]==0){
    159                  RaceCheckPoint* n=m->getCheckpoint(v[i]);
    160                  n->setV(true);
    161                  }}
    162         }*/
    163         }
    164 
     149       
     150   
    165151    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
    166     {/*
    167         this->checkpointReached_[pl]=index;
     152            {
     153                this->checkpointReached_[pl]=index;
    168154        this->clock_.capture();
    169         int s = this->clock_.getSeconds();
     155                int s = this->clock_.getSeconds();
    170156        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    171         const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
     157                const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
    172158                        + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    173                         + " seconds.";
     159                                + " seconds.";
    174160        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    175161        ChatManager::message(message);
    176        */
    177        
    178     }
    179    
     162                       
     163            }
     164   
    180165     void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
    181     {   int index = p->getCheckpointIndex();
    182         this->checkpointReached_[pl]=index;
    183         this->clock_.capture();
    184         int s = this->clock_.getSeconds();
    185         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
     166            {   int index = p->getCheckpointIndex();
     167                this->checkpointReached_[pl]=index;
     168                this->clock_.capture();
     169                int s = this->clock_.getSeconds();
     170                int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    186171        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
    187                         + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
     172                                + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    188173                        + " seconds.";
    189         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    190         ChatManager::message(message);
    191        
    192        
    193     }
     174                const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     175                ChatManager::message(message);
     176               
     177               
     178            }
     179           
    194180   
    195181   
     
    212198       // return valid_player;
    213199        }
     200       
     201         bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
     202    {
     203        return false;
     204    }
     205
     206    bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator)
     207    {
     208        return false;
     209    }
     210
     211    bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)
     212    {
     213        return false;
     214    }
    214215}
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h

    r8959 r8968  
    7676
    7777
    78          void setV(SpaceRaceManager* m);
     78          bool allowPawnHit(Pawn* victim, Pawn* originator);
     79
     80    bool allowPawnDamage(Pawn* victim, Pawn* originator);
     81
     82    bool allowPawnDeath(Pawn* victim, Pawn* originator);
    7983        protected:
    8084                virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc

    r8959 r8968  
    2121 *
    2222 *   Author:
    23  *     Mauro Salomon
     23 *     Celine Eggenberger
    2424 *   Co-authors:
    2525 *      ...
     
    3838#include "util/Math.h"
    3939
     40
     41
    4042namespace orxonox
    4143{
     
    4648        RegisterObject(SpaceRaceManager);
    4749         
    48          for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    49                 this->setNext(this->checkpoints_[i]);
    50          
     50        this->firstcheckpointvisible_=false;
     51         
    5152    }
    5253
     
    9596    {
    9697    SUPER(SpaceRaceManager,tick,dt);
    97      SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    98      gametype->setV(this);
    99          
     98     
     99     if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
     100         {this->checkpoints_[0]->setRadarVisibility(true);this->firstcheckpointvisible_=false;}
    100101         
    101102         for (size_t i = 0; i < this->checkpoints_.size(); ++i){
     
    111112        assert(gametype);
    112113       
    113         //if(gametype->getCheckpointReached(player)==-1) {orxout()<<"index -1"<<endl;}
     114       
    114115   
    115116                 bool b =false;
    116                 //DistanceMultiTrigger::fire(bIsTriggered,player);
     117               
    117118                int index=gametype->getCheckpointReached(player);
     119                Vector3 v=Vector3 (-1,-1,-1);
    118120                if (index>-1){
    119121                RaceCheckPoint* tmp= this->getCheckpoint(index);
    120                 Vector3 v= tmp->getNextcheckpoint();
     122                v= tmp->getNextcheckpoint();
    121123       
    122        // orxout()<<"index not -1"<<endl;
     124       
    123125        if (this->getCheckpoint(v.x)==check){
    124126                b=true;
     
    137139            gametype->clock_.capture();
    138140            float time = gametype->clock_.getSecondsPrecise();
    139             if (check->bTimeLimit_!=0 && time > check->bTimeLimit_)
     141            if (check->getTimeLimit()!=0 && time > check->getTimeLimit())
    140142            {
    141143                gametype->timeIsUp();
     
    146148            else
    147149            {
     150                if (index > -1)this->setRadVis(player,false);
    148151                gametype->newCheckpointReached(check,player);
    149152                check->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
     153               
     154               
     155               
     156                this->setRadVis(player, true);
     157               
    150158            }
    151159        }
     
    153161    }
    154162   
     163    void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b){
     164        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     165        assert(gametype);
     166        int index=gametype->getCheckpointReached(player);
     167        Vector3 v=Vector3(-1,-1,-1);
     168        RaceCheckPoint* tmp= this->getCheckpoint(index);
     169                v= tmp->getNextcheckpoint();
    155170   
    156171   
    157     void SpaceRaceManager::setNext(RaceCheckPoint* check){
    158        
    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         }
     172         if(v.x > -1){this->getCheckpoint(v.x)->setRadarVisibility(b);
     173                this->getCheckpoint(v.x)->settingsChanged();}
     174                if(v.y > -1){this->getCheckpoint(v.y)->setRadarVisibility(b);
     175                this->getCheckpoint(v.y)->settingsChanged();}
     176                if(v.z > -1){this->getCheckpoint(v.z)->setRadarVisibility(b);
     177                this->getCheckpoint(v.z)->settingsChanged();}
     178   
     179    }
     180   
     181   
    164182   
    165183   
  • code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h

    r8959 r8968  
    4242#include "RaceCheckPoint.h"
    4343
     44
     45
    4446namespace orxonox
    4547{
     
    6466        void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
    6567               
    66         void setNext(RaceCheckPoint* check);
     68       
    6769
    6870        void tick(float dt);
    6971        protected:
    70                
     72                 void setRadVis(PlayerInfo* player, bool b);
    7173        private:
    7274                std::vector<RaceCheckPoint*> checkpoints_;
    73                
     75                bool firstcheckpointvisible_;
    7476               
    7577               
  • code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc

    r7184 r8968  
    7878
    7979    void WaypointPatrolController::searchEnemy()
    80     {
     80    {/*
    8181        this->patrolTimer_.setInterval(rnd());
    8282
     
    101101
    102102        if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
    103             this->target_ = 0;
     103            this->target_ = 0;*/
    104104    }
    105105}
  • code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc

    r8706 r8968  
    5757
    5858        this->registerVariables();
     59       
    5960    }
    6061
Note: See TracChangeset for help on using the changeset viewer.