Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 11, 2006, 4:18:14 PM (18 years ago)
Author:
manuel
Message:

moved pickup from spaceship to playable. playable can now pickup health and max-health powerups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/powerups/src/world_entities/playable.cc

    r6444 r6487  
    2121#include "player.h"
    2222#include "state.h"
     23
     24#include "power_ups/weapon_power_up.h"
     25#include "power_ups/param_power_up.h"
    2326
    2427
     
    141144}
    142145
     146bool 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
    143171/**
    144172 * add an event to the event list of events this Playable can capture
Note: See TracChangeset for help on using the changeset viewer.