Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5973 in orxonox.OLD


Ignore:
Timestamp:
Dec 7, 2005, 5:02:50 PM (18 years ago)
Author:
manuel
Message:

needs fix in weapon_powert_up.cc (fabricate from string)

Location:
branches/powerups/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/powerups/src/world_entities/power_ups/power_up.cc

    r5874 r5973  
    4040    if(dynamic_cast<Extendable*>(entity)->pickup(this))
    4141    {
    42       this->setVisibiliy(false);
     42      this->hide();
    4343    }
    4444  }
    4545}
     46
     47void PowerUp::hide()
     48{
     49  this->setVisibiliy(false);
     50}
  • branches/powerups/src/world_entities/power_ups/power_up.h

    r5873 r5973  
    1818  PowerUp();
    1919  virtual ~PowerUp ();
     20  virtual void hide();
    2021};
    2122
  • branches/powerups/src/world_entities/power_ups/weapon_power_up.cc

    r5965 r5973  
    2222
    2323#include "primitive_model.h"
     24
     25#include "factory.h"
     26#include "load_param.h"
    2427
    2528using namespace std;
     
    5255{
    5356  static_cast<PowerUp*>(this)->loadParams(root);
    54 
     57  const TiXmlElement* elem = root->FirstChildElement("weapon");
     58  if(elem != NULL && (elem = weapon->getFirstChildElement()) != NULL)
     59  {
     60    this->weaponXML = elem;
     61    createWeapon();
     62  }
     63  else
     64  {
     65    LoadParam(root, "weaponID", this, const char*, setWeaponClass);
     66  }
    5567}
    5668
    5769Weapon* WeaponPowerUp::getWeapon()
    5870{
    59   return dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(this->getWeaponID()));
     71  return this->weapon;
    6072}
    6173
    62 ClassID WeaponPowerUp::getWeaponID()
     74void WeaponPowerUp::createWeapon()
    6375{
    64   return this->weaponID;
     76  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
     77      ? Factory::getFirst()->fabricate(static_cast<ClassID>(this->weapon->getClassID()))
     78      : Factory::getFirst()->fabricate(weaponXML));
    6579}
    6680
    67 long WeaponPowerUp::getCapsNeeded()
     81void WeaponPowerUp::setWeaponClass(const char* name)
    6882{
    69   return this->capsNeeded;
     83  this->weapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(name, name));
    7084}
  • branches/powerups/src/world_entities/power_ups/weapon_power_up.h

    r5965 r5973  
    2020
    2121  Weapon* getWeapon();
    22   ClassID getWeaponID();
    23   long getCapsNeeded();
     22  void setWeaponClass(const char* name);
    2423
    2524private:
    2625  void init();
    2726  void loadParams(const TiXmlElement* root);
     27private:
     28  Weapon* weapon;
     29  const TiXmlElement* weaponXML;
    2830
    29 private:
    30   ClassID weaponID;
    31   long capsNeeded;
     31  void createWeapon();
    3232};
    3333
  • branches/powerups/src/world_entities/space_ships/space_ship.cc

    r5965 r5973  
    377377{
    378378  if(powerUp->isA(CL_WEAPON_POWER_UP)) {
    379     WeaponPowerUp* wpu = dynamic_cast<WeaponPowerUp*>(powerUp);
     379    Weapon weapon = dynamic_cast<WeaponPowerUp*>(powerUp)->getWeapon();
    380380    WeaponManager* manager = this->getWeaponManager();
    381     int slot = manager->getNextFreeSlot(0, wpu->getCapsNeeded());
     381    int slot = manager->getNextFreeSlot(0, weapon->getCapability());
    382382    if(slot >= 0) {
    383       manager->addWeapon(wpu->getWeapon(), 0, slot);
     383      manager->addWeapon(weapon, 0, slot);
    384384      return true;
    385385    }
Note: See TracChangeset for help on using the changeset viewer.