Changeset 9869 in orxonox.OLD for trunk/src/world_entities/power_ups/power_up.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.