Changeset 7208 for code/trunk/src/modules
- Timestamp:
- Aug 24, 2010, 9:49:54 AM (14 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/Pickup.cc
r7163 r7208 236 236 } 237 237 238 /**239 @brief240 Starts the pickup duration timer.241 After the specified durationTime has expired the function pickupTimerCallback is called.242 pickupTimerCallback can be overloaded and thus the desired functionality can be implemented.243 @param durationTime244 The duration after which the expires and the callback function is called.245 @return246 Returns true if the pickup duration timer was started successfully, false if not.247 */248 bool Pickup::startPickupTimer(float durationTime)249 {250 if (durationTime<=0)251 {252 COUT(1) << "Invalid durationTime in pickup." << std::endl;253 return false;254 }255 if (this->durationTimer_.isActive()) //!< Check if Timer is already running256 {257 COUT(1) << "Pickup durationTimer already in use." << std::endl;258 return false;259 }260 this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::pickupTimerCallback, this)));261 return true;262 }263 238 } -
code/trunk/src/modules/pickup/Pickup.h
r7163 r7208 133 133 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 134 134 135 bool startPickupTimer(float durationTime); //!< Starts the pickup duration timer.136 /**137 @brief Get your Timer.138 @return Returns a pointer to the Timer.139 */140 inline Timer* getTimer(void)141 { return &this->durationTimer_; }142 143 /**144 @brief The callback method for the Timer.145 Can be overloaded to implement desired functionality.146 */147 virtual void pickupTimerCallback(void) {}148 149 135 /** 150 136 @brief Set the activation type of the pickup. … … 166 152 void initialize(void); //!< Initializes the member variables. 167 153 168 //TODO: Problems, when there are more Timers needed? Solutions?169 Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.170 171 154 pickupActivationType::Value activationType_; //!< The activation type of the Pickup. 172 155 pickupDurationType::Value durationType_; //!< The duration type of the pickup. -
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
r7163 r7208 115 115 if (this->isUsed()) 116 116 { 117 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)118 { 119 this-> getTimer()->unpauseTimer();117 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 118 { 119 this->durationTimer_.unpauseTimer(); 120 120 } 121 121 else 122 122 { 123 this-> startPickupTimer(this->getDuration());123 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this))); 124 124 } 125 125 … … 131 131 this->setInvisible(false); 132 132 133 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())133 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()) 134 134 { 135 135 this->Pickupable::destroy(); … … 137 137 else 138 138 { 139 this-> getTimer()->pauseTimer();139 this->durationTimer_.pauseTimer(); 140 140 } 141 141 } -
code/trunk/src/modules/pickup/items/InvisiblePickup.h
r7163 r7208 77 77 void setDuration(float duration); 78 78 void initializeIdentifier(void); 79 v irtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends.79 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. 83 83 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 84 85 Timer durationTimer_; //!< Timer. 86 84 87 bool invisible_; //!< Helper to remember wether the Pawn is invisible. 85 88 float duration_; //! Duration of invisibility. -
code/trunk/src/modules/pickup/items/ShieldPickup.cc
r7163 r7208 160 160 if(this->isUsed()) 161 161 { 162 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)162 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 163 163 { 164 this-> getTimer()->unpauseTimer();164 this->durationTimer_.unpauseTimer(); 165 165 } 166 166 else 167 167 { 168 this-> startPickupTimer(this->getDuration());168 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&ShieldPickup::pickupTimerCallback, this))); 169 169 } 170 170 pawn->setShieldAbsorption(this->getShieldAbsorption()); … … 179 179 if(this->isOnce()) 180 180 { 181 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())181 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()) 182 182 { 183 183 this->Pickupable::destroy(); … … 185 185 else 186 186 { 187 this-> getTimer()->pauseTimer();187 this->durationTimer_.pauseTimer(); 188 188 } 189 189 } -
code/trunk/src/modules/pickup/items/ShieldPickup.h
r7163 r7208 80 80 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 81 81 82 v irtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.82 void pickupTimerCallback(void); //!< Function that gets called when timer ends. 83 83 84 84 void setDuration(float duration); … … 90 90 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 91 91 92 Timer durationTimer_; //!< Timer. 93 92 94 float duration_; //!< The health that is transferred to the Pawn. 93 95 float shieldHealth_; -
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r7163 r7208 141 141 if(this->isUsed()) 142 142 { 143 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)143 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 144 144 { 145 this-> getTimer()->unpauseTimer();145 this->durationTimer_.unpauseTimer(); 146 146 } 147 147 else 148 148 { 149 this-> startPickupTimer(this->getDuration());149 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this))); 150 150 } 151 151 engine->setSpeedAdd(this->getSpeedAdd()); … … 159 159 if(this->isOnce()) 160 160 { 161 if(!this-> getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())161 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()) 162 162 { 163 163 this->Pickupable::destroy(); … … 165 165 else 166 166 { 167 this-> getTimer()->pauseTimer();167 this->durationTimer_.pauseTimer(); 168 168 } 169 169 } -
code/trunk/src/modules/pickup/items/SpeedPickup.h
r7163 r7208 79 79 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 80 80 81 v irtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.81 void pickupTimerCallback(void); //!< Function that gets called when timer ends. 82 82 83 83 void setDuration(float duration); … … 89 89 Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 90 90 91 Timer durationTimer_; //!< Timer. 92 91 93 float duration_; //!< The health that is transferred to the Pawn. 92 94 float speedAdd_;
Note: See TracChangeset
for help on using the changeset viewer.