Changeset 7541 for code/trunk/src/modules/pickup/items
- Timestamp:
- Oct 14, 2010, 12:55:59 PM (14 years ago)
- Location:
- code/trunk/src/modules/pickup/items
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/items/DronePickup.cc
r7163 r7541 33 33 34 34 #include "DronePickup.h" 35 #include "worldentities/Drone.h" 36 #include "controllers/DroneController.h"35 36 #include <sstream> 37 37 38 38 #include "core/CoreIncludes.h" … … 40 40 #include "util/StringUtils.h" 41 41 42 #include "controllers/DroneController.h" 43 #include "pickup/PickupIdentifier.h" 42 44 #include "worldentities/pawns/Pawn.h" 43 #include "pickup/PickupIdentifier.h" 44 45 #include <sstream> 45 #include "worldentities/Drone.h" 46 #include "worldentities/StaticEntity.h" 46 47 47 48 namespace orxonox … … 104 105 } 105 106 107 /** 108 @brief 109 Set the droneTemplate. 110 @param templatename 111 The name of the Template to e set. 112 */ 106 113 void DronePickup::setDroneTemplate(std::string templatename){ 107 114 droneTemplate_ = templatename; 108 115 } 109 116 117 /** 118 @brief 119 Get the name of the droneTemplate. 120 @return 121 Returns the name of the droneTemplate. 122 */ 110 123 const std::string& DronePickup::getDroneTemplate() const 111 124 { … … 121 134 SUPER(DronePickup, changedUsed); 122 135 123 // !If the pickup is not picked up nothing must be done.136 // If the pickup is not picked up nothing must be done. 124 137 if(!this->isPickedUp()) 125 138 return; 126 139 127 // !If the pickup has transited to used.140 // If the pickup has transited to used. 128 141 if(this->isUsed()) 129 142 { 130 143 131 144 Pawn* pawn = this->carrierToPawnHelper(); 132 if(pawn == NULL) // !<If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.145 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 133 146 this->Pickupable::destroy(); 134 147 … … 147 160 drone->setPosition(spawnPosition); 148 161 149 // !The pickup has been used up.162 // The pickup has been used up. 150 163 this->setUsed(false); 151 164 } 152 165 else 153 166 { 154 // !If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.167 // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused. 155 168 if(this->isOnce() || (this->isContinuous() )) 156 169 { -
code/trunk/src/modules/pickup/items/DronePickup.h
r7456 r7541 39 39 40 40 #include <string> 41 #include <worldentities/pawns/Pawn.h>42 #include <worldentities/Drone.h>43 44 #include "worldentities/StaticEntity.h"45 41 46 42 #include "pickup/Pickup.h" … … 49 45 namespace orxonox { 50 46 47 /** 48 @brief 49 The DronePickup adds a Drone to the Pawn upon being picked up. 50 It can be used in XML as follows: 51 @code 52 <DronePickup droneTemplate="myDroneTemplate" /> 53 @endcode 54 Where <em>droneTemplate</em> specifies a @ref orxonox::Template "Template" based on which the Drone is created. 51 55 56 @author 57 Lukas Gassner 58 59 @ingroup PickupItems 60 */ 52 61 class _PickupExport DronePickup : public Pickup, public Tickable 53 62 { … … 62 71 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 63 72 64 void setDroneTemplate(std::string templatename); 65 const std::string& getDroneTemplate() const; 73 void setDroneTemplate(std::string templatename); //!< Set the droneTemplate. 74 const std::string& getDroneTemplate() const; //!< Get the name of the droneTemplate. 66 75 67 76 protected: … … 70 79 private: 71 80 void initialize(void); //!< Initializes the member variables. 72 std::string droneTemplate_; 81 std::string droneTemplate_; //!< The name of the template, based upon which the Drone is created. 73 82 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 74 83 -
code/trunk/src/modules/pickup/items/HealthPickup.cc
r7163 r7541 142 142 { 143 143 Pawn* pawn = this->carrierToPawnHelper(); 144 if(pawn == NULL) // !<If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.144 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 145 145 this->Pickupable::destroy(); 146 146 147 // !Calculate the health that is added this tick.147 // Calculate the health that is added this tick. 148 148 float health = dt*this->getHealthRate(); 149 149 if(health > this->getHealth()) 150 150 health = this->getHealth(); 151 // !Calculate the health the Pawn will have once the health is added.151 // Calculate the health the Pawn will have once the health is added. 152 152 float fullHealth = pawn->getHealth() + health; 153 153 this->setHealth(this->getHealth()-health); … … 174 174 } 175 175 176 // ! If all health has been transfered.176 // If all health has been transferred. 177 177 if(this->getHealth() == 0) 178 178 { … … 190 190 SUPER(HealthPickup, changedUsed); 191 191 192 // !If the pickup is not picked up nothing must be done.192 // If the pickup is not picked up nothing must be done. 193 193 if(!this->isPickedUp()) //TODO: Needed? 194 194 return; 195 195 196 // !If the pickup has transited to used.196 // If the pickup has transited to used. 197 197 if(this->isUsed()) 198 198 { … … 200 200 { 201 201 Pawn* pawn = this->carrierToPawnHelper(); 202 if(pawn == NULL) // !<If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.202 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 203 203 this->Pickupable::destroy(); 204 204 … … 227 227 } 228 228 229 // !The pickup has been used up.229 // The pickup has been used up. 230 230 this->setUsed(false); 231 231 } … … 253 253 } 254 254 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.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)) 257 257 { -
code/trunk/src/modules/pickup/items/HealthPickup.h
r7493 r7541 47 47 namespace orxonox { 48 48 49 //! Enum for the type of the HealthPickup 49 /** 50 @brief 51 Enum for the type of the @ref orxonox::HealthPickup "HealthPickup". 52 53 @ingroup PickupItems 54 */ 50 55 namespace pickupHealthType 51 56 { 52 57 enum Value 53 58 { 54 limited, 55 temporary, 56 permanent 59 limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health. 60 temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use. 61 permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health. 57 62 }; 58 63 } … … 60 65 /** 61 66 @brief 62 A pickupthat can do (dependent upon the parameters) lots of different things to the health of a Pawn.67 The Health Pickup is a Pickupable that can do (dependent upon the parameters) lots of different things to the health of a Pawn. 63 68 There are 4 parameters that can be chosen: 64 - The @b health The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn. 65 - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it. 66 - The @b duration @b type It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter. 67 - The @b health @b type The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way. 69 - The <b>health</b> The amount of health that (in a way dependent on the other parameters) is transferred to the Pawn. 70 - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the health is transferred, either immediately after being picked up or only after the player uses it. 71 - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the specified health is transferred once to the Pawn, for <em>continuous</em> the set health is transferred over a span of time at a rate defined by the health rate parameter. 72 - The <b>health type</b> The health type can be chosen to be <em>limited</em>, <em>temporary</em> or <em>permanent</em>. <em>limited</em> means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. <em>permanent</em> means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way. 73 74 An examle of a XML implementation of a HealthPickup would be: 75 @code 76 <HealthPickup 77 health = 33 78 healthType = "limited" 79 activationType = "immediate" 80 durationType = "once" 81 /> 82 @endcode 83 68 84 @author 69 85 Damian 'Mozork' Frick 86 87 @ingroup PickupItems 70 88 */ 71 89 class _PickupExport HealthPickup : public Pickup, public Tickable … … 83 101 84 102 /** 85 @brief Get the health that is transfer ed to the Pawn upon usage of this pickup.103 @brief Get the health that is transferred to the Pawn upon usage of this pickup. 86 104 @return Returns the health. 87 105 */ -
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
r7208 r7541 57 57 { 58 58 RegisterObject(InvisiblePickup); 59 //! Defines who is allowed to pick up the pickup.60 59 this->initialize(); 61 60 } … … 86 85 { 87 86 this->duration_ = 0.0f; 87 // Defines who is allowed to pick up the pickup. 88 88 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 89 89 } … … 99 99 100 100 this->initializeIdentifier(); 101 this->setDurationType(Pickup::durationTypeOnce_s); // The duration type is always once. 101 102 } 102 103 … … 109 110 SUPER(InvisiblePickup, changedUsed); 110 111 111 // !If the pickup is not picked up nothing must be done.112 // If the pickup is not picked up nothing must be done. 112 113 if(!this->isPickedUp()) 113 114 return; … … 115 116 if (this->isUsed()) 116 117 { 117 if( !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)118 if(this->isContinuous() 118 119 { 119 this->durationTimer_.unpauseTimer(); 120 } 121 else 122 { 123 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this))); 120 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 121 { 122 this->durationTimer_.unpauseTimer(); 123 } 124 else 125 { 126 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this))); 127 } 124 128 } 125 129 -
code/trunk/src/modules/pickup/items/InvisiblePickup.h
r7493 r7541 50 50 A pickup that makes the Pawn invisible. 51 51 There are 2 parameters that can be chosen: 52 - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it. 53 - The @b duration @b type It can be chosen how long the Pawn will be invisibel. 52 - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it. 53 - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the InvisiblePickup just makes the Pawn invisible for as long as it is used, for <em>continuous</em> the Pawn is invisible for the specified duration. 54 - The <b>duration</b> Specifies how long (in seconds) the invisibility lasts. 55 54 56 @author 55 57 Benedict Simlinger 58 59 @ingroup PickupItems 56 60 */ 57 61 class _PickupExport InvisiblePickup : public Pickup
Note: See TracChangeset
for help on using the changeset viewer.