Changeset 5973 in orxonox.OLD for branches/powerups/src/world_entities
- Timestamp:
- Dec 7, 2005, 5:02:50 PM (19 years ago)
- 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 40 40 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 41 41 { 42 this-> setVisibiliy(false);42 this->hide(); 43 43 } 44 44 } 45 45 } 46 47 void PowerUp::hide() 48 { 49 this->setVisibiliy(false); 50 } -
branches/powerups/src/world_entities/power_ups/power_up.h
r5873 r5973 18 18 PowerUp(); 19 19 virtual ~PowerUp (); 20 virtual void hide(); 20 21 }; 21 22 -
branches/powerups/src/world_entities/power_ups/weapon_power_up.cc
r5965 r5973 22 22 23 23 #include "primitive_model.h" 24 25 #include "factory.h" 26 #include "load_param.h" 24 27 25 28 using namespace std; … … 52 55 { 53 56 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 } 55 67 } 56 68 57 69 Weapon* WeaponPowerUp::getWeapon() 58 70 { 59 return dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(this->getWeaponID()));71 return this->weapon; 60 72 } 61 73 62 ClassID WeaponPowerUp::getWeaponID()74 void WeaponPowerUp::createWeapon() 63 75 { 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)); 65 79 } 66 80 67 long WeaponPowerUp::getCapsNeeded()81 void WeaponPowerUp::setWeaponClass(const char* name) 68 82 { 69 return this->capsNeeded;83 this->weapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(name, name)); 70 84 } -
branches/powerups/src/world_entities/power_ups/weapon_power_up.h
r5965 r5973 20 20 21 21 Weapon* getWeapon(); 22 ClassID getWeaponID(); 23 long getCapsNeeded(); 22 void setWeaponClass(const char* name); 24 23 25 24 private: 26 25 void init(); 27 26 void loadParams(const TiXmlElement* root); 27 private: 28 Weapon* weapon; 29 const TiXmlElement* weaponXML; 28 30 29 private: 30 ClassID weaponID; 31 long capsNeeded; 31 void createWeapon(); 32 32 }; 33 33 -
branches/powerups/src/world_entities/space_ships/space_ship.cc
r5965 r5973 377 377 { 378 378 if(powerUp->isA(CL_WEAPON_POWER_UP)) { 379 Weapon PowerUp* wpu = dynamic_cast<WeaponPowerUp*>(powerUp);379 Weapon weapon = dynamic_cast<WeaponPowerUp*>(powerUp)->getWeapon(); 380 380 WeaponManager* manager = this->getWeaponManager(); 381 int slot = manager->getNextFreeSlot(0, w pu->getCapsNeeded());381 int slot = manager->getNextFreeSlot(0, weapon->getCapability()); 382 382 if(slot >= 0) { 383 manager->addWeapon(w pu->getWeapon(), 0, slot);383 manager->addWeapon(weapon, 0, slot); 384 384 return true; 385 385 }
Note: See TracChangeset
for help on using the changeset viewer.