Changeset 9016 for code/trunk/src/modules/gametypes/RaceCheckPoint.cc
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
r8858 r9016 34 34 #include "chat/ChatManager.h" 35 35 36 #include <infos/PlayerInfo.h> 37 #include <worldentities/ControllableEntity.h> 38 36 39 #include "SpaceRace.h" 37 40 … … 39 42 { 40 43 CreateFactory(RaceCheckPoint); 44 45 41 46 42 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): Distance Trigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))47 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) 43 48 { 44 49 RegisterObject(RaceCheckPoint); 45 46 this->bCheckpointIndex_ = 0; 47 this->bIsLast_ = false; 50 this->setDistance(100); 51 this->setBeaconMode("off"); 52 this->setBroadcast(false); 53 this->setSimultaneousTriggerers(100); 48 54 this->bTimeLimit_ = 0; 49 55 … … 51 57 this->setRadarObjectShape(RadarViewable::Triangle); 52 58 this->setRadarVisibility(false); 59 this->settingsChanged(); 60 this->reached_=NULL; 61 53 62 } 63 54 64 55 RaceCheckPoint::~RaceCheckPoint() 56 { 57 } 65 RaceCheckPoint::~RaceCheckPoint() 66 { 67 68 } 58 69 59 70 void RaceCheckPoint::tick(float dt) … … 63 74 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 64 75 assert(gametype); 65 if (this->getCheckpointIndex() == gametype->getCheckpointsReached())66 this->setRadarVisibility(true);67 else68 this->setRadarVisibility(false);69 76 } 70 77 … … 72 79 { 73 80 SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); 74 81 Vector3 v= Vector3(0,0,0); 75 82 XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); 76 83 XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false); 77 84 XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); 85 XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v); 78 86 } 79 87 80 void RaceCheckPoint:: triggered(bool bIsTriggered)88 void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player) 81 89 { 82 Distance Trigger::triggered(bIsTriggered);83 90 DistanceMultiTrigger::fire((bool)bIsTriggered,player); 91 84 92 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 85 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered) 86 { 87 gametype->clock_.capture(); 88 float time = gametype->clock_.getSecondsPrecise(); 89 if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) 90 { 91 gametype->timeIsUp(); 92 gametype->end(); 93 } 94 else if (this->getLast()) 95 gametype->end(); 96 else 97 { 98 gametype->newCheckpointReached(); 99 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 100 } 101 } 93 assert(gametype); 94 ControllableEntity* entity = (ControllableEntity*) player; 95 96 PlayerInfo* player2 = entity->getPlayer(); 97 98 if(bIsTriggered) 99 this->reached_=player2; 102 100 } 103 101 … … 108 106 { 109 107 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 108 assert(gametype); 110 109 if (gametype) 111 110 {
Note: See TracChangeset
for help on using the changeset viewer.