Changeset 9241 for code/branches/presentation2012/src/modules/pickup
- Timestamp:
- May 24, 2012, 8:49:19 PM (13 years ago)
- Location:
- code/branches/presentation2012
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012 ¶
- Property svn:mergeinfo changed
/code/branches/newlevel2012 merged: 9236
- Property svn:mergeinfo changed
-
code/branches/presentation2012/src ¶
- Property svn:mergeinfo set to (toggle deleted branches)
-
code/branches/presentation2012/src/modules ¶
- Property svn:mergeinfo set to (toggle deleted branches)
-
code/branches/presentation2012/src/modules/pickup ¶
- Property svn:mergeinfo set to (toggle deleted branches)
-
TabularUnified code/branches/presentation2012/src/modules/pickup/PickupPrereqs.h ¶
r9195 r9241 68 68 namespace orxonox 69 69 { 70 71 70 class CollectiblePickup; 72 71 class DroppedPickup; -
TabularUnified code/branches/presentation2012/src/modules/pickup/items/FlagPickup.cc ¶
r9240 r9241 28 28 29 29 /** 30 31 32 */30 @file FlagPickup.cc 31 @brief Implementation of the FlagPickup class. 32 */ 33 33 34 34 #include "FlagPickup.h" … … 37 37 #include "core/CoreIncludes.h" 38 38 #include "core/XMLPort.h" 39 40 39 #include "pickup/PickupIdentifier.h" 41 40 42 41 namespace orxonox 43 42 { 44 43 45 44 CreateFactory(FlagPickup); 46 45 47 46 /** 48 @brief49 50 */47 @brief 48 Constructor. Registers the object and initializes the member variables. 49 */ 51 50 FlagPickup::FlagPickup(BaseObject* creator) : Pickup(creator) 52 51 { 53 52 RegisterObject(FlagPickup); 54 53 55 54 this->initialize(); 56 55 } 57 56 58 57 /** 59 @brief60 61 */58 @brief 59 Destructor. 60 */ 62 61 FlagPickup::~FlagPickup() 63 62 { 64 63 65 64 } 66 65 67 66 /** 68 @brief69 70 */67 @brief 68 Initializes the member variables. 69 */ 71 70 void FlagPickup::initialize(void) 72 71 { 73 72 this->flagType_ = 0; 74 73 75 74 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 76 75 } 77 76 78 77 /** 79 @brief80 81 */78 @brief 79 Initializes the PickupIdentifier of this pickup. 80 */ 82 81 void FlagPickup::initializeIdentifier(void) 83 82 { … … 90 89 this->pickupIdentifier_->addParameter(type1, val); 91 90 } 92 91 93 92 /** 94 @brief95 96 */93 @brief 94 Method for creating a FlagPickup object through XML. 95 */ 97 96 void FlagPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) 98 97 { 99 98 SUPER(FlagPickup, XMLPort, xmlelement, mode); 100 99 101 100 XMLPortParam(FlagPickup, "flagType", setFlagType, getFlagType, xmlelement, mode); 102 101 //XMLPortParam(FlagPickup, "teamNumber", setTeamNumber, getTeamNumber, xmlelement, mode); 103 102 104 103 this->initializeIdentifier(); 105 104 } 106 107 105 106 108 107 /** 109 @brief110 111 @return112 113 */108 @brief 109 Get the flag type of this pickup. 110 @return 111 Returns the falg type as a string. 112 */ 114 113 const int FlagPickup::getFlagType(void) const 115 114 { 116 115 return this->flagType_; 117 116 } 118 117 119 118 /** 120 @brief121 Set the type of the HealthPickup.122 @param type123 124 */119 @brief 120 Set the type of the FlagPickup. 121 @param type 122 The type as a string. 123 */ 125 124 void FlagPickup::setFlagType(int type) 126 125 { … … 133 132 } 134 133 } 134 135 /** 136 @brief 137 Is called when the pickup has transited from used to unused or the other way around. 138 */ 139 void FlagPickup::changedUsed(void) 140 { 141 SUPER(FlagPickup, changedUsed); 142 143 Pawn* pawn = this->carrierToPawnHelper(); 144 145 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 146 this->Pickupable::destroy(); 147 148 // If the pickup has transited to used. 149 if(this->isUsed()) 150 { 151 this->bPickedUp_ = true; 152 this->pickedUpBy_ = pawn; 153 orxout(internal_error, context::pickups) << "flag picked up." << endl; 135 154 155 } 156 } 157 136 158 /** 137 @brief 138 Is called when the pickup has transited from used to unused or the other way around. 139 */ 140 void FlagPickup::changedUsed(void) 141 { 142 SUPER(FlagPickup, changedUsed); 143 144 Pawn* pawn = this->carrierToPawnHelper(); 145 146 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 147 this->Pickupable::destroy(); 148 149 // If the pickup has transited to used. 150 if(this->isUsed()) 151 { 152 this->bPickedUp_ = true; 153 this->pickedUpBy_ = pawn; 154 } 155 } 156 157 /** 158 @brief 159 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 160 @return 161 A pointer to the Pawn, or NULL if the conversion failed. 162 */ 163 Pawn* FlagPickup::carrierToPawnHelper(void) 164 { 165 PickupCarrier* carrier = this->getCarrier(); 166 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 167 168 if(pawn == NULL) 169 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl; 170 171 return pawn; 172 } 173 174 175 159 @brief 160 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 161 @return 162 A pointer to the Pawn, or NULL if the conversion failed. 163 */ 164 Pawn* FlagPickup::carrierToPawnHelper(void) 165 { 166 PickupCarrier* carrier = this->getCarrier(); 167 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 168 169 if(pawn == NULL) 170 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in Flag Pickup." << endl; 171 172 return pawn; 173 } 174 175 176 176 177 void FlagPickup::tick(float dt) 177 178 179 180 181 182 183 184 185 186 178 { 179 SUPER(FlagPickup, tick, dt); 180 181 //Pawn* pawn = this->carrierToPawnHelper(); 182 183 // if(pawn->isAlive() && pawn->hasFlag()){ 184 // this->Pickupable::destroy(); 185 // } 186 187 } 187 188 } -
TabularUnified code/branches/presentation2012/src/modules/pickup/items/FlagPickup.h ¶
r9240 r9241 28 28 29 29 /** 30 31 32 33 */30 @file FlagPickup.h 31 @brief Declaration of the FlagPickup class. 32 @ingroup PickupItems 33 */ 34 34 35 35 #ifndef _FlagPickup_H__ … … 47 47 48 48 namespace orxonox { 49 /*50 @ingroup PickupItems51 52 53 @author54 55 56 @ingroup PickupItems57 */49 /* 50 @ingroup PickupItems 51 52 53 @author 54 Nino Weingart 55 56 @ingroup PickupItems 57 */ 58 58 class _PickupExport FlagPickup : public Pickup, public Tickable 59 59 { 60 61 62 63 virtual~FlagPickup(); //!< Destructor.64 65 66 67 68 60 public: 61 62 FlagPickup(BaseObject* creator); //!< Constructor. 63 ~FlagPickup(); //!< Destructor. 64 65 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a FlagPickup object through XML. 66 67 virtual void tick(float dt); 68 69 69 const int getFlagType(void) const; //!< Get the flag type of this pickup. 70 70 71 71 inline bool isPickedUp() const 72 72 { return this->bPickedUp_; } 73 73 inline Pawn* pickedUpBy() const 74 75 74 { return this->pickedUpBy_; } 75 76 76 inline void setPickedUp(bool pickedUp) 77 77 { this->bPickedUp_ = pickedUp; } … … 79 79 inline void ignorePickedUp() 80 80 { this->Pickupable::destroy(); } 81 81 82 82 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 83 84 protected: 85 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 86 87 /** 88 @brief Set the flag type of this pickup. 89 @param type The type of this pickup as an enum. 90 */ 91 inline void setFlagTypeDirect(int type) 92 { this->flagType_ = type; } 93 void setFlagType(int type); //!< Set the type of the FlagPickup. 94 95 private: 96 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 97 void initialize(void); //!< Initializes the member variables. 98 Pawn* pickedUpBy_; 99 int flagType_; 100 101 bool bPickedUp_; 102 83 84 protected: 85 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 86 87 /** 88 @brief Set the flag type of this pickup. 89 @param type The type of this pickup as an enum. 90 */ 91 inline void setFlagTypeDirect(int type) 92 { this->flagType_ = type; } 93 94 void setFlagType(int type); //!< Set the type of the FlagPickup. 95 96 private: 97 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 98 void initialize(void); //!< Initializes the member variables. 99 Pawn* pickedUpBy_; 100 int flagType_; 101 102 bool bPickedUp_; 103 103 104 }; 104 105 }
Note: See TracChangeset
for help on using the changeset viewer.