Changeset 6487 in orxonox.OLD for branches/powerups/src/world_entities/playable.cc
- Timestamp:
- Jan 11, 2006, 4:18:14 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/powerups/src/world_entities/playable.cc
r6444 r6487 21 21 #include "player.h" 22 22 #include "state.h" 23 24 #include "power_ups/weapon_power_up.h" 25 #include "power_ups/param_power_up.h" 23 26 24 27 … … 141 144 } 142 145 146 bool Playable::pickup(PowerUp* powerUp) 147 { 148 if(powerUp->isA(CL_WEAPON_POWER_UP)) { 149 Weapon* weapon = dynamic_cast<WeaponPowerUp*>(powerUp)->getWeapon(); 150 WeaponManager* manager = this->getWeaponManager(); 151 int slot = manager->getNextFreeSlot(0, weapon->getCapability()); 152 if(slot >= 0) { 153 manager->addWeapon(weapon, 0, slot); 154 return true; 155 } 156 } 157 else if(powerUp->isA(CL_PARAM_POWER_UP)) { 158 ParamPowerUp* ppu = dynamic_cast<ParamPowerUp*>(powerUp); 159 switch(ppu->getType()) { 160 case POWERUP_PARAM_HEALTH: 161 this->addEnergy(ppu->getValue()); 162 return true; 163 case POWERUP_PARAM_MAX_HEALTH: 164 this->setMaxEnergy(this->getMaxEnergy() + ppu->getValue()); 165 return true; 166 } 167 } 168 return false; 169 } 170 143 171 /** 144 172 * add an event to the event list of events this Playable can capture
Note: See TracChangeset
for help on using the changeset viewer.