Changeset 2900 for code/branches/pickups/src/orxonox/objects/pickup
- Timestamp:
- Apr 6, 2009, 3:53:50 PM (16 years ago)
- Location:
- code/branches/pickups
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickups
-
Property
svn:ignore
set to
build
dependencies
-
Property
svn:ignore
set to
-
code/branches/pickups/src/orxonox/objects/pickup/BaseItem.cc
r2864 r2900 63 63 this->setOwner(pawn); 64 64 65 COUT(3) << "Adding '" << this->getPickupIdentifier() << "' item." << std::endl; 66 67 return pawn->getPickups().add(this); 65 if (pawn->getPickups().add(this)) 66 { 67 COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl; 68 return true; 69 } 70 return false; 68 71 } 69 72 /** -
code/branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt
r2864 r2900 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 BaseItem.cc 3 DroppedItem.cc 3 4 EquipmentItem.cc 5 Jump.cc 4 6 ModifierPickup.cc 5 7 PassiveItem.cc -
code/branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc
r2864 r2900 74 74 XMLPortParamTemplate(ModifierPickup, "damageAdd", setAdditiveDamage, getAdditiveDamage, element, mode, float); 75 75 XMLPortParamTemplate(ModifierPickup, "damageMulti", setMultiplicativeDamage, getMultiplicativeDamage, element, mode, float); 76 77 XMLPortParamTemplate(ModifierPickup, "accelerationAdd", setAdditiveAcceleration, getAdditiveAcceleration, element, mode, float); 78 XMLPortParamTemplate(ModifierPickup, "accelerationMulti", setMultiplicativeAcceleration, getMultiplicativeAcceleration, element, mode, float); 76 79 } 77 80 /** … … 141 144 this->timer_.stopTimer(); 142 145 146 delete this; 147 143 148 return true; 144 149 } -
code/branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h
r2864 r2900 58 58 virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method 59 59 60 virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups 61 60 62 /** 61 63 @brief Get the duration of this pickup. … … 97 99 { this->setMultiplicativeModifier(ModifierType::Damage, value); } 98 100 101 /** 102 @brief Get the amount of acceleration this pickup adds. 103 @return Returns how much acceleration this pickup adds. 104 */ 105 inline float getAdditiveAcceleration() const 106 { return this->getAdditiveModifier(ModifierType::Acceleration); } 107 /** 108 @brief Get the factor by which this pickup multiplies the acceleration. 109 @return Returns the factor by which to multiply acceleration. 110 */ 111 inline float getMultiplicativeAcceleration() const 112 { return this->getMultiplicativeModifier(ModifierType::Acceleration); } 113 114 /** 115 @brief Set the amount of acceleration this pickup adds. 116 @param value How much acceleration this pickup adds. 117 */ 118 inline void setAdditiveAcceleration(float value) 119 { this->setAdditiveModifier(ModifierType::Acceleration, value); } 120 /** 121 @brief Set the factor by which this pickup multiplies the acceleration. 122 @param value Factor by which to multiply acceleration. 123 */ 124 inline void setMultiplicativeAcceleration(float value) 125 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } 126 99 127 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 100 128 private: -
code/branches/pickups/src/orxonox/objects/pickup/ModifierType.h
r2864 r2900 45 45 { 46 46 Unknown = 0, 47 Damage 47 Damage, 48 Acceleration 48 49 }; 49 50 } -
code/branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc
r2864 r2900 94 94 for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++) 95 95 { 96 (*it).second->dropped((*it).second->getOwner()); 97 98 delete (*it).second; 96 if((*it).second && (*it).second->getOwner()) 97 (*it).second->dropped((*it).second->getOwner()); 99 98 } 100 99 this->items_.clear(); … … 125 124 return false; 126 125 } 126 } 127 //! Uses the first usable item in the collection on the owner. 128 void PickupCollection::useItem() 129 { 130 Identifier* ident = Class(UsableItem); 131 for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++) 132 { 133 if ((*it).second->isA(ident)) 134 { 135 UsableItem* asUsable = dynamic_cast<UsableItem*>((*it).second); 136 asUsable->used(this->owner_); 137 return; 138 } 139 } 140 } 141 /** 142 @brief Uses a usable item on the owner of the collection. 143 @param item Item to use. 144 */ 145 void PickupCollection::useItem(UsableItem* item) 146 { 147 if (item && this->owner_) 148 item->used(this->owner_); 127 149 } 128 150 /** -
code/branches/pickups/src/orxonox/objects/pickup/PickupCollection.h
r2864 r2900 48 48 { 49 49 class BaseItem; 50 class UsableItem; 50 51 class Pawn; 51 52 … … 67 68 68 69 void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection. 70 71 void useItem(); //!< Use the first usable item. 72 void useItem(UsableItem* item); //!< Use a usable item. 69 73 70 74 void addAdditiveModifier(ModifierType::Enum type, float value); //!< Add an additive modifier. -
code/branches/pickups/src/orxonox/objects/pickup/UsableItem.h
r2864 r2900 52 52 53 53 /** 54 @brief Method invoked if the item wasused.55 @param pawn Pawn which usedthe item.54 @brief Method invoked when the item is being used. 55 @param pawn Pawn which is using the item. 56 56 */ 57 57 virtual void used(Pawn* pawn) { }
Note: See TracChangeset
for help on using the changeset viewer.