Changeset 9869 in orxonox.OLD for trunk/src/world_entities/power_ups
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- Location:
- trunk/src/world_entities/power_ups
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/power_ups/laser_power_up.cc
r9406 r9869 24 24 25 25 26 27 CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(LaserPowerUp, CL_LASER_POWER_UP); 28 CREATE_FACTORY(LaserPowerUp); 28 29 29 30 LaserPowerUp::LaserPowerUp () : PowerUp(0.0, 1.0, 0.0) … … 49 50 void LaserPowerUp::init() 50 51 { 51 this-> setClassID(CL_LASER_POWER_UP, "LaserPowerUp");52 this->registerObject(this, LaserPowerUp::_objectList); 52 53 this->loadModel("models/guns/test_gun.obj", 2.0); 53 54 -
trunk/src/world_entities/power_ups/laser_power_up.h
r7954 r9869 13 13 14 14 class LaserPowerUp : public PowerUp { 15 ObjectListDeclaration(LaserPowerUp); 15 16 16 17 public: … … 22 23 23 24 24 virtual void LaserPowerUp::collidesWith(WorldEntity* entity, const Vector& location);25 virtual void collidesWith(WorldEntity* entity, const Vector& location); 25 26 virtual void tick(float dt); 26 27 virtual void draw() const; -
trunk/src/world_entities/power_ups/param_power_up.cc
r9656 r9869 27 27 28 28 29 30 CREATE_FACTORY(ParamPowerUp, CL_PARAM_POWER_UP); 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(ParamPowerUp, CL_PARAM_POWER_UP); 31 CREATE_FACTORY(ParamPowerUp); 31 32 32 33 const char* ParamPowerUp::paramTypes[] = { … … 58 59 void ParamPowerUp::init() 59 60 { 60 this-> setClassID(CL_PARAM_POWER_UP, "ParamPowerUp");61 this->registerObject(this, ParamPowerUp::_objectList); 61 62 this->value = 0; 62 63 this->max_value = 0; -
trunk/src/world_entities/power_ups/param_power_up.h
r7954 r9869 20 20 21 21 class ParamPowerUp : public PowerUp { 22 ObjectListDeclaration(ParamPowerUp); 22 23 23 24 public: -
trunk/src/world_entities/power_ups/power_up.cc
r9406 r9869 21 21 #include "primitive_model.h" 22 22 23 #include " util/loading/resource_manager.h"23 #include "sound/resource_sound_buffer.h" 24 24 #include "util/loading/load_param.h" 25 25 26 #include "debug.h" 26 27 28 ObjectListDefinition(PowerUp); 27 29 28 30 PowerUp::PowerUp(float r, float g, float b) 29 31 { 30 this-> setClassID(CL_POWER_UP, "PowerUp");32 this->registerObject(this, PowerUp::_objectList); 31 33 32 34 this->respawnType = RESPAWN_TIME; … … 45 47 46 48 this->soundSource.setSourceNode(this); 47 this->pickupBuffer = NULL;48 this->respawnBuffer = NULL;49 49 50 50 this->collider = NULL; … … 54 54 { 55 55 delete this->sphereMaterial; 56 if (this->pickupBuffer != NULL)57 ResourceManager::getInstance()->unload(this->pickupBuffer);58 if (this->respawnBuffer != NULL)59 ResourceManager::getInstance()->unload(this->respawnBuffer);60 56 } 61 57 … … 77 73 void PowerUp::loadPickupSound(const std::string& pickupSound) 78 74 { 79 if (this->pickupBuffer != NULL) 80 ResourceManager::getInstance()->unload(this->pickupBuffer); 81 82 else if (!pickupSound.empty()) 83 { 84 this->pickupBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV); 85 if (this->pickupBuffer != NULL) 86 { 87 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound.c_str(), this->getCName()); 88 } 89 else 90 { 91 PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound.c_str(), this->getCName()); 92 } 93 } 75 if (!pickupSound.empty()) 76 this->pickupBuffer = OrxSound::ResourceSoundBuffer(pickupSound); 94 77 else 95 this->pickupBuffer = NULL;78 this->pickupBuffer = OrxSound::SoundBuffer(); 96 79 } 97 80 98 81 void PowerUp::loadRespawnSound(const std::string& respawnSound) 99 82 { 100 if (this->respawnBuffer != NULL) 101 ResourceManager::getInstance()->unload(this->respawnBuffer); 102 103 else if (!respawnSound.empty()) 104 { 105 this->respawnBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV); 106 if (this->respawnBuffer != NULL) 107 { 108 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound.c_str(), this->getCName()); 109 } 110 else 111 { 112 PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound.c_str(), this->getCName()); 113 } 114 } 83 if (!respawnSound.empty()) 84 this->respawnBuffer = OrxSound::ResourceSoundBuffer(respawnSound); 115 85 else 116 this->respawnBuffer = NULL;86 this->respawnBuffer = OrxSound::SoundBuffer(); 117 87 } 118 88 … … 120 90 void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) 121 91 { 122 if(this->collider != entity && entity->isA( CL_EXTENDABLE))92 if(this->collider != entity && entity->isA(Extendable::staticClassID())) 123 93 { 124 94 this->collider = entity; 125 95 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 126 96 { 127 if(pickupBuffer != NULL)97 if(pickupBuffer.loaded()) 128 98 this->soundSource.play(this->pickupBuffer); 129 99 … … 154 124 this->toList(OM_COMMON); 155 125 this->collider = NULL; 156 if (likely(this->respawnBuffer != NULL))126 if (likely(this->respawnBuffer.loaded())) 157 127 this->soundSource.play(this->respawnBuffer); 158 128 -
trunk/src/world_entities/power_ups/power_up.h
r7954 r9869 21 21 22 22 class PowerUp : public WorldEntity { 23 ObjectListDeclaration(PowerUp); 23 24 24 25 public: … … 43 44 private: 44 45 OrxSound::SoundSource soundSource; 45 OrxSound::SoundBuffer *pickupBuffer;46 OrxSound::SoundBuffer *respawnBuffer;46 OrxSound::SoundBuffer pickupBuffer; 47 OrxSound::SoundBuffer respawnBuffer; 47 48 Material* sphereMaterial; 48 49 PowerUpRespawn respawnType; -
trunk/src/world_entities/power_ups/turret_power_up.cc
r9406 r9869 24 24 25 25 26 27 CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(TurretPowerUp, CL_TURRET_POWER_UP); 28 CREATE_FACTORY(TurretPowerUp); 28 29 29 30 TurretPowerUp::TurretPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0) … … 45 46 void TurretPowerUp::init() 46 47 { 47 this-> setClassID(CL_TURRET_POWER_UP, "TurretPowerUp");48 this->registerObject(this, TurretPowerUp::_objectList); 48 49 this->loadModel("models/guns/turret1.obj", 2.0); 49 50 -
trunk/src/world_entities/power_ups/turret_power_up.h
r7954 r9869 13 13 14 14 class TurretPowerUp : public PowerUp { 15 ObjectListDeclaration(TurretPowerUp); 15 16 16 17 public: … … 20 21 virtual void loadParams(const TiXmlElement* root); 21 22 22 virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location);23 virtual void collidesWith(WorldEntity* entity, const Vector& location); 23 24 virtual void tick(float dt); 24 25 virtual void draw() const; -
trunk/src/world_entities/power_ups/weapon_power_up.cc
r9406 r9869 25 25 #include "util/loading/factory.h" 26 26 #include "util/loading/load_param.h" 27 #include "debug.h" 27 28 28 29 30 CREATE_FACTORY(WeaponPowerUp , CL_WEAPON_POWER_UP);29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(WeaponPowerUp, CL_WEAPON_POWER_UP); 31 CREATE_FACTORY(WeaponPowerUp); 31 32 32 33 WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0) … … 45 46 void WeaponPowerUp::init() 46 47 { 47 this-> setClassID(CL_WEAPON_POWER_UP, "WeaponPowerUp");48 this->registerObject(this, WeaponPowerUp::_objectList); 48 49 this->loadPickupSound("sound/powerups/whats this2.wav"); 49 50 … … 87 88 { 88 89 this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL) 89 ? Factory::fabricate( static_cast<ClassID>(this->weapon->getLeafClassID()))90 ? Factory::fabricate((this->weapon->getClassID())) 90 91 : Factory::fabricate((const TiXmlElement*)this->getXmlElem()->FirstChildElement("weapon"))); 91 92 this->model = this->weapon->getModel(0); -
trunk/src/world_entities/power_ups/weapon_power_up.h
r7954 r9869 14 14 15 15 class WeaponPowerUp : public PowerUp { 16 16 ObjectListDeclaration(WeaponPowerUp); 17 17 public: 18 18 WeaponPowerUp(const TiXmlElement* root = NULL);
Note: See TracChangeset
for help on using the changeset viewer.