Changeset 3064 for code/trunk/src/orxonox/objects/worldentities/triggers
- Timestamp:
- May 25, 2009, 5:54:42 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects/worldentities/triggers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
r3033 r3064 38 38 namespace orxonox 39 39 { 40 CreateFactory(CheckPoint);40 CreateFactory(CheckPoint); 41 41 42 CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)43 {44 RegisterObject(CheckPoint);42 CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator) 43 { 44 RegisterObject(CheckPoint); 45 45 46 this->setStayActive(true); 47 this->setDistance(50); 48 this->bIsFirst_ = false; 49 this->bIsDestination_ = false; 50 //this->setVisible(true); 46 this->setStayActive(true); 47 this->setDistance(50); 48 this->bIsFirst_ = false; 49 this->bIsDestination_ = false; 51 50 52 this->notifyMaskUpdate(); 53 } 51 this->setRadarObjectColour(ColourValue::Green); 52 this->setRadarObjectShape(RadarViewable::Dot); 53 this->setRadarVisibility(false); 54 54 55 CheckPoint::~CheckPoint() 56 { 57 } 55 this->notifyMaskUpdate(); 56 } 58 57 59 void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)60 {61 SUPER(CheckPoint, XMLPort, xmlelement, mode);58 CheckPoint::~CheckPoint() 59 { 60 } 62 61 63 XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false); 64 XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false); 65 XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30); 66 } 62 void CheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 63 { 64 SUPER(CheckPoint, XMLPort, xmlelement, mode); 67 65 68 void CheckPoint::triggered(bool bIsTriggered) 69 { 70 DistanceTrigger::triggered(bIsTriggered); 66 XMLPortParam(CheckPoint, "isfirst", setFirst, getFirst, xmlelement, mode).defaultValues(false); 67 XMLPortParam(CheckPoint, "isdestination", setDestination, getDestination, xmlelement, mode).defaultValues(false); 68 XMLPortParam(CheckPoint, "addtime", setAddTime, getAddTime, xmlelement, mode).defaultValues(30); 69 } 71 70 72 Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); 73 if (gametype) 71 void CheckPoint::changedActivity() 74 72 { 75 gametype->addTime(addTime_); 73 SUPER(CheckPoint, changedActivity); 74 75 if (this->BaseObject::isActive()) 76 { 77 COUT(0) << "active " << this << std::endl; 78 this->setRadarVisibility(true); 79 } 80 else 81 { 82 COUT(0) << "inactive " << this << std::endl; 83 this->setRadarVisibility(false); 84 } 85 } 76 86 77 if (bIsTriggered && bIsFirst_) 87 void CheckPoint::triggered(bool bIsTriggered) 88 { 89 DistanceTrigger::triggered(bIsTriggered); 90 91 Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype()); 92 if (gametype) 78 93 { 79 gametype->setTimeLimit(addTime_); 80 gametype->firstCheckpointReached(true); 94 gametype->addTime(addTime_); 95 this->setRadarVisibility(false); 96 97 if (bIsTriggered && bIsFirst_) 98 { 99 gametype->setTimeLimit(addTime_); 100 gametype->firstCheckpointReached(true); 101 } 102 103 if (bIsTriggered && bIsDestination_) 104 { 105 gametype->end(); 106 } 81 107 } 108 } 82 109 83 if (bIsTriggered && bIsDestination_) 84 { 85 gametype->end(); 86 } 87 } 88 } 89 90 void CheckPoint::notifyMaskUpdate() 91 { 92 this->targetMask_.exclude(Class(BaseObject)); 93 this->targetMask_.include(Class(Pawn)); 94 } 110 void CheckPoint::notifyMaskUpdate() 111 { 112 this->targetMask_.exclude(Class(BaseObject)); 113 this->targetMask_.include(Class(Pawn)); 114 } 95 115 } -
code/trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.h
r3033 r3064 36 36 37 37 #include "DistanceTrigger.h" 38 #include "objects/RadarViewable.h" 38 39 39 40 namespace orxonox 40 41 { 41 class _OrxonoxExport CheckPoint : public DistanceTrigger42 {42 class _OrxonoxExport CheckPoint : public DistanceTrigger, public RadarViewable 43 { 43 44 public: 44 CheckPoint(BaseObject* creator);45 virtual ~CheckPoint();45 CheckPoint(BaseObject* creator); 46 virtual ~CheckPoint(); 46 47 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML. 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML. 49 virtual void changedActivity(); 48 50 49 51 private: 50 virtual void triggered(bool bIsTriggered);51 virtual void notifyMaskUpdate();52 virtual void triggered(bool bIsTriggered); 53 virtual void notifyMaskUpdate(); 52 54 53 inline void setDestination(bool isDestination)54 { bIsDestination_ = isDestination; }55 inline void setDestination(bool isDestination) 56 { bIsDestination_ = isDestination; } 55 57 56 inline bool getDestination()57 { return bIsDestination_; }58 inline const WorldEntity* getWorldEntity() const 59 { return this; } 58 60 59 inline void setFirst(bool isFirst)60 { this->bIsFirst_ = isFirst; }61 inline bool getDestination() 62 { return bIsDestination_; } 61 63 62 inline bool getFirst()63 { return this->bIsFirst_; }64 inline void setFirst(bool isFirst) 65 { this->bIsFirst_ = isFirst; } 64 66 65 inline void setAddTime(float time)66 { this->addTime_ = time; }67 inline bool getFirst() 68 { return this->bIsFirst_; } 67 69 68 inline bool getAddTime()69 { return this->addTime_; }70 inline void setAddTime(float time) 71 { this->addTime_ = time; } 70 72 71 bool bIsFirst_; 72 bool bIsDestination_; 73 float addTime_; 74 }; 73 inline bool getAddTime() 74 { return this->addTime_; } 75 76 bool bIsFirst_; 77 bool bIsDestination_; 78 float addTime_; 79 }; 75 80 } 76 81
Note: See TracChangeset
for help on using the changeset viewer.