Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 2, 2006, 10:20:16 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: added powerups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r6815 r6973  
    5353  this->setClassID(CL_WEAPON_POWER_UP, "WeaponPowerUp");
    5454  this->weaponXML = NULL;
    55   this->weaponID = CL_NULL;
    5655  this->weapon = NULL;
    5756}
     
    6564  {
    6665    this->weaponXML = elem;
    67     respawn();
     66    newWeapon();
    6867  }
    6968  else
     
    7877}
    7978
    80 void WeaponPowerUp::respawn()
     79bool WeaponPowerUp::process(WeaponManager* manager)
     80{
     81  if(manager->addWeapon(this->weapon)) {
     82    newWeapon();
     83  }
     84  else {
     85    manager->increaseAmmunition(this->weapon->getProjectileType(), this->weapon->getEnergy());
     86  }
     87  return true;
     88}
     89
     90void WeaponPowerUp::newWeapon()
    8191{
    8292  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
    83       ? Factory::fabricate(static_cast<ClassID>(weaponID))
     93      ? Factory::fabricate(static_cast<ClassID>(this->weapon->getLeafClassID()))
    8494      : Factory::fabricate((TiXmlElement*)this->getXmlElem()->FirstChildElement("weapon")));
    8595  this->model = this->weapon->getModel(0);
     
    8999{
    90100  this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name));
    91   this->weaponID = (ClassID)this->weapon->getLeafClassID();
    92101  this->model = this->weapon->getModel(0);
    93102}
Note: See TracChangeset for help on using the changeset viewer.