Changeset 7127 for code/branches/presentation3/src/modules/pickup/items
- Timestamp:
- Jun 9, 2010, 9:32:58 PM (15 years ago)
- Location:
- code/branches/presentation3/src/modules/pickup/items
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/pickup/items/DronePickup.cc
r7034 r7127 49 49 50 50 CreateFactory(DronePickup); 51 51 52 52 /** 53 53 @brief … … 57 57 { 58 58 RegisterObject(DronePickup); 59 59 60 60 this->initialize(); 61 61 } 62 62 63 63 /** 64 64 @brief … … 67 67 DronePickup::~DronePickup() 68 68 { 69 69 70 70 } 71 71 72 72 /** 73 @brief 73 @brief 74 74 Initializes the member variables. 75 75 */ … … 80 80 this->droneTemplate_ = ""; 81 81 } 82 82 83 83 /** 84 84 @brief … … 91 91 this->pickupIdentifier_->addParameter(type, val); 92 92 } 93 93 94 94 /** 95 95 @brief … … 100 100 SUPER(DronePickup, XMLPort, xmlelement, mode); 101 101 XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode); 102 102 103 103 this->initializeIdentifier(); 104 104 } 105 105 106 106 void DronePickup::setDroneTemplate(std::string templatename){ 107 107 droneTemplate_ = templatename; 108 } 109 108 } 109 110 110 const std::string& DronePickup::getDroneTemplate() const 111 111 { … … 120 120 { 121 121 SUPER(DronePickup, changedUsed); 122 122 123 123 //! If the pickup is not picked up nothing must be done. 124 124 if(!this->isPickedUp()) 125 125 return; 126 126 127 127 //! If the pickup has transited to used. 128 128 if(this->isUsed()) … … 132 132 if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 133 133 this->destroy(); 134 134 135 135 //Attach to pawn 136 136 Drone* drone = new Drone(pawn->getCreator()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something) … … 143 143 droneController->setOwner(pawn); 144 144 } 145 145 146 146 Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30); 147 147 drone->setPosition(spawnPosition); 148 148 149 149 //! The pickup has been used up. 150 150 this->setUsed(false); … … 159 159 } 160 160 } 161 161 162 162 /** 163 163 @brief … … 170 170 PickupCarrier* carrier = this->getCarrier(); 171 171 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 172 172 173 173 if(pawn == NULL) 174 174 { 175 175 COUT(1) << "Invalid PickupCarrier in DronePickup." << std::endl; 176 176 } 177 177 178 178 return pawn; 179 179 } 180 180 181 181 /** 182 182 @brief … … 189 189 if(item == NULL) 190 190 item = new DronePickup(this); 191 191 192 192 SUPER(DronePickup, clone, item); 193 193 194 194 DronePickup* pickup = dynamic_cast<DronePickup*>(item); 195 195 pickup->setDroneTemplate(this->getDroneTemplate()); 196 196 197 197 pickup->initializeIdentifier(); 198 198 } -
code/branches/presentation3/src/modules/pickup/items/DronePickup.h
r7034 r7127 47 47 48 48 namespace orxonox { 49 49 50 50 51 51 class _PickupExport DronePickup : public Pickup, public Tickable 52 52 { 53 53 public: 54 54 55 55 DronePickup(BaseObject* creator); //!< Constructor. 56 56 virtual ~DronePickup(); //!< Destructor. 57 57 58 58 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a DronePickup object through XML. 59 59 60 60 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 61 61 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 62 62 63 63 void setDroneTemplate(std::string templatename); 64 const std::string& getDroneTemplate() const; 65 64 const std::string& getDroneTemplate() const; 65 66 66 protected: 67 67 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 68 68 69 69 private: 70 70 void initialize(void); //!< Initializes the member variables. 71 71 std::string droneTemplate_; 72 72 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 73 74 73 75 74 75 76 76 }; 77 77 } -
code/branches/presentation3/src/modules/pickup/items/HealthPickup.cc
r7008 r7127 45 45 namespace orxonox 46 46 { 47 47 48 48 /*static*/ const std::string HealthPickup::healthTypeLimited_s = "limited"; 49 49 /*static*/ const std::string HealthPickup::healthTypeTemporary_s = "temporary"; 50 50 /*static*/ const std::string HealthPickup::healthTypePermanent_s = "permanent"; 51 51 52 52 CreateFactory(HealthPickup); 53 53 54 54 /** 55 55 @brief … … 59 59 { 60 60 RegisterObject(HealthPickup); 61 61 62 62 this->initialize(); 63 63 } 64 64 65 65 /** 66 66 @brief … … 69 69 HealthPickup::~HealthPickup() 70 70 { 71 72 } 73 74 /** 75 @brief 71 72 } 73 74 /** 75 @brief 76 76 Initializes the member variables. 77 77 */ 78 78 void HealthPickup::initialize(void) 79 { 79 { 80 80 this->health_ = 0; 81 81 this->healthRate_ = 0; … … 83 83 this->maxHealthSave_ = 0; 84 84 this->maxHealthOverwrite_ = 0; 85 85 86 86 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 87 87 } 88 88 89 89 /** 90 90 @brief … … 98 98 std::string val1 = stream.str(); 99 99 this->pickupIdentifier_->addParameter(type1, val1); 100 100 101 101 std::string val2 = this->getHealthType(); 102 102 std::string type2 = "healthType"; 103 103 this->pickupIdentifier_->addParameter(type2, val2); 104 104 105 105 stream.clear(); 106 106 stream << this->getHealthRate(); … … 109 109 this->pickupIdentifier_->addParameter(type3, val3); 110 110 } 111 111 112 112 /** 113 113 @brief … … 117 117 { 118 118 SUPER(HealthPickup, XMLPort, xmlelement, mode); 119 119 120 120 XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode); 121 121 XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode); 122 122 XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode); 123 123 124 124 if(!this->isContinuous()) 125 125 this->healthRate_ = 0.0; 126 126 127 127 this->initializeIdentifier(); 128 128 } 129 129 130 130 /** 131 131 @brief … … 138 138 { 139 139 SUPER(HealthPickup, tick, dt); 140 140 141 141 if(this->isContinuous() && this->isUsed()) 142 142 { … … 144 144 if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 145 145 this->destroy(); 146 146 147 147 //! Calculate the health that is added this tick. 148 148 float health = dt*this->getHealthRate(); … … 152 152 float fullHealth = pawn->getHealth() + health; 153 153 this->setHealth(this->getHealth()-health); 154 154 155 155 switch(this->getHealthTypeDirect()) 156 156 { … … 173 173 COUT(1) << "Invalid healthType in HealthPickup." << std::endl; 174 174 } 175 175 176 176 //! If all health has been transfered. 177 177 if(this->getHealth() == 0) … … 181 181 } 182 182 } 183 183 184 184 /** 185 185 @brief … … 193 193 if(!this->isPickedUp()) 194 194 return; 195 195 196 196 //! If the pickup has transited to used. 197 197 if(this->isUsed()) … … 202 202 if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 203 203 this->destroy(); 204 204 205 205 float health = 0; 206 206 switch(this->getHealthTypeDirect()) … … 226 226 COUT(1) << "Invalid healthType in HealthPickup." << std::endl; 227 227 } 228 228 229 229 //! The pickup has been used up. 230 230 this->setUsed(false); … … 237 237 PickupCarrier* carrier = this->getCarrier(); 238 238 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 239 239 240 240 if(pawn == NULL) 241 241 { … … 244 244 return; 245 245 } 246 246 247 247 if(pawn->getMaxHealth() == this->maxHealthOverwrite_) 248 248 { … … 252 252 } 253 253 } 254 254 255 255 //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused. 256 256 if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0)) … … 260 260 } 261 261 } 262 262 263 263 /** 264 264 @brief … … 271 271 PickupCarrier* carrier = this->getCarrier(); 272 272 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 273 273 274 274 if(pawn == NULL) 275 275 { 276 276 COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl; 277 277 } 278 278 279 279 return pawn; 280 280 } 281 281 282 282 /** 283 283 @brief … … 297 297 pickup->setHealthRate(this->getHealthRate()); 298 298 pickup->setHealthTypeDirect(this->getHealthTypeDirect()); 299 299 300 300 pickup->initializeIdentifier(); 301 301 } 302 302 303 303 /** 304 304 @brief … … 322 322 } 323 323 } 324 324 325 325 /** 326 326 @brief … … 341 341 } 342 342 } 343 343 344 344 /** 345 345 @brief … … 356 356 else 357 357 { 358 COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl; 359 } 360 } 361 358 COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl; 359 } 360 } 361 362 362 /** 363 363 @brief -
code/branches/presentation3/src/modules/pickup/items/HealthPickup.h
r6709 r7127 45 45 46 46 namespace orxonox { 47 47 48 48 //! Enum for the type of the HealthPickup 49 49 namespace pickupHealthType … … 56 56 }; 57 57 } 58 58 59 59 /** 60 60 @brief … … 71 71 { 72 72 public: 73 73 74 74 HealthPickup(BaseObject* creator); //!< Constructor. 75 75 virtual ~HealthPickup(); //!< Destructor. 76 76 77 77 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML. 78 78 virtual void tick(float dt); //!< Is called every tick. 79 79 80 80 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 81 81 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 82 82 83 83 /** 84 84 @brief Get the health that is transfered to the Pawn upon usage of this pickup. … … 93 93 inline float getHealthRate(void) 94 94 { return this->healthRate_; } 95 95 96 96 /** 97 97 @brief Get the type of HealthPickup, this pickup is. 98 @return Returns the health type as an enum. 98 @return Returns the health type as an enum. 99 99 */ 100 100 inline pickupHealthType::Value getHealthTypeDirect(void) 101 101 { return this->healthType_; } 102 102 const std::string& getHealthType(void); //!< Get the health type of this pickup. 103 103 104 104 protected: 105 105 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. … … 107 107 void setHealth(float health); //!< Sets the health. 108 108 void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous. 109 109 110 110 /** 111 111 @brief Set the health type of this pickup. … … 115 115 { this->healthType_ = type; } 116 116 void setHealthType(std::string type); //!< Set the type of the HealthPickup. 117 117 118 118 private: 119 119 void initialize(void); //!< Initializes the member variables. 120 120 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 121 121 122 122 float health_; //!< The health that is transferred to the Pawn. 123 123 float healthRate_; //!< The rate at which the health is transferred. … … 125 125 float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well. 126 126 pickupHealthType::Value healthType_; //!< The type of the HealthPickup. 127 127 128 128 //! Strings for the health types. 129 129 static const std::string healthTypeLimited_s; 130 130 static const std::string healthTypeTemporary_s; 131 131 static const std::string healthTypePermanent_s; 132 132 133 133 }; 134 134 } -
code/branches/presentation3/src/modules/pickup/items/InvisiblePickup.h
r7112 r7127 44 44 45 45 namespace orxonox { 46 46 47 47 /** 48 48 @brief … … 57 57 { 58 58 public: 59 59 60 60 InvisiblePickup(BaseObject* creator); //!< Constructor. 61 61 virtual ~InvisiblePickup(); //!< Destructor. … … 63 63 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 64 64 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 65 65 66 66 /** 67 67 @brief Checks whether the Pawn is invisible. … … 72 72 inline float getDuration() 73 73 { return this->duration_; } 74 74 75 75 protected: 76 76 bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again. … … 78 78 void initializeIdentifier(void); 79 79 virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends. 80 80 81 81 private: 82 82 void initialize(void); //!< Initializes the member variables. -
code/branches/presentation3/src/modules/pickup/items/MetaPickup.cc
r6709 r7127 40 40 41 41 namespace orxonox { 42 42 43 43 CreateFactory(MetaPickup); 44 44 45 45 //! Setting the static variables to their values. 46 46 /*static*/ const std::string MetaPickup::metaTypeNone_s = "none"; 47 47 /*static*/ const std::string MetaPickup::metaTypeUse_s = "use"; 48 48 /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop"; 49 49 50 50 /** 51 51 @brief … … 55 55 { 56 56 RegisterObject(MetaPickup); 57 57 58 58 this->initialize(); 59 59 } 60 60 61 61 /** 62 62 @brief … … 65 65 MetaPickup::~MetaPickup() 66 66 { 67 68 } 69 67 68 } 69 70 70 /** 71 71 @brief … … 75 75 { 76 76 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 77 77 78 78 this->setActivationTypeDirect(pickupActivationType::immediate); 79 79 this->setDurationTypeDirect(pickupDurationType::once); 80 80 this->metaType_ = pickupMetaType::none; 81 81 } 82 82 83 83 /** 84 84 @brief … … 91 91 this->pickupIdentifier_->addParameter(type, val); 92 92 } 93 93 94 94 /** 95 95 @brief … … 99 99 { 100 100 SUPER(MetaPickup, XMLPort, xmlelement, mode); 101 101 102 102 XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode); 103 103 104 104 this->initializeIdentifier(); 105 105 } 106 106 107 107 /** 108 108 @brief … … 113 113 { 114 114 SUPER(MetaPickup, changedUsed); 115 115 116 116 //! If the MetaPickup transited to used. 117 117 if(this->isUsed()) … … 144 144 } 145 145 } 146 146 147 147 /** 148 148 @brief … … 155 155 if(item == NULL) 156 156 item = new MetaPickup(this); 157 157 158 158 SUPER(MetaPickup, clone, item); 159 159 160 160 MetaPickup* pickup = dynamic_cast<MetaPickup*>(item); 161 161 pickup->setMetaTypeDirect(this->getMetaTypeDirect()); 162 162 163 163 pickup->initializeIdentifier(); 164 164 } 165 165 166 166 /** 167 167 @brief … … 184 184 } 185 185 } 186 186 187 187 /** 188 188 @brief … … 206 206 } 207 207 } 208 208 209 209 } -
code/branches/presentation3/src/modules/pickup/items/MetaPickup.h
r6709 r7127 51 51 }; 52 52 } 53 53 54 54 /** 55 55 @brief … … 60 60 class _PickupExport MetaPickup : public Pickup 61 61 { 62 62 63 63 public: 64 64 MetaPickup(BaseObject* creator); //!< Constructor. Registers and initializes the object. 65 65 virtual ~MetaPickup(); //!< Destructor. 66 66 67 67 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MetaPickup object through XML. 68 68 69 69 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 70 70 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 71 71 72 72 /** 73 73 @brief Returns the meta type of the MetaPickup. … … 77 77 { return this->metaType_; } 78 78 const std::string& getMetaType(void); //!< Get the meta type of this MetaPickup. 79 79 80 80 protected: 81 81 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 82 82 83 83 /** 84 84 @brief Set the meta type of the MetaPickup. … … 88 88 { this->metaType_ = type; } 89 89 void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup. 90 90 91 91 private: 92 92 void initialize(void); //!< Initializes the member variables. 93 93 94 94 pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken. 95 95 96 96 //! Static strings for the meta types. 97 97 static const std::string metaTypeNone_s; 98 98 static const std::string metaTypeUse_s; 99 99 static const std::string metaTypeDrop_s; 100 101 100 101 102 102 }; 103 103 -
code/branches/presentation3/src/modules/pickup/items/ShieldPickup.cc
r6998 r7127 79 79 PickupCarrier* carrier = this->getCarrier(); 80 80 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 81 81 82 82 if(pawn == NULL) 83 83 { … … 86 86 return pawn; 87 87 } 88 88 89 89 /** 90 90 @brief … … 117 117 std::string val2 = stream.str(); 118 118 this->pickupIdentifier_->addParameter(type2, val2); 119 119 120 120 stream.clear(); 121 121 stream << this->getShieldAbsorption(); … … 269 269 270 270 void ShieldPickup::pickupTimerCallback(void) 271 { 271 { 272 272 this->setUsed(false); 273 273 } -
code/branches/presentation3/src/modules/pickup/items/SpeedPickup.cc
r6755 r7127 137 137 if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed. 138 138 this->destroy(); 139 139 140 140 //! If the pickup has transited to used. 141 141 if(this->isUsed()) … … 156 156 engine->setSpeedAdd(0.0f); 157 157 engine->setSpeedMultiply(1.0f); 158 158 159 159 if(this->isOnce()) 160 160 { … … 186 186 COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl; 187 187 } 188 188 189 189 return engine; 190 190 } … … 269 269 270 270 void SpeedPickup::pickupTimerCallback(void) 271 { 271 { 272 272 this->setUsed(false); 273 273 } -
code/branches/presentation3/src/modules/pickup/items/SpeedPickup.h
r6709 r7127 78 78 protected: 79 79 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 80 80 81 81 virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends. 82 82
Note: See TracChangeset
for help on using the changeset viewer.