Changeset 7066 in orxonox.OLD for trunk/src/world_entities/power_ups
- Timestamp:
- Feb 7, 2006, 1:29:17 PM (19 years ago)
- Location:
- trunk/src/world_entities/power_ups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/power_ups/power_up.cc
r7065 r7066 45 45 46 46 this->soundSource.setSourceNode(this); 47 this->soundBuffer = NULL; 47 this->pickupBuffer = NULL; 48 this->respawnBuffer = NULL; 48 49 } 49 50 … … 51 52 { 52 53 delete this->sphereMaterial; 53 if (this->soundBuffer != NULL) 54 ResourceManager::getInstance()->unload(this->soundBuffer); 54 if (this->pickupBuffer != NULL) 55 ResourceManager::getInstance()->unload(this->pickupBuffer); 56 if (this->respawnBuffer != NULL) 57 ResourceManager::getInstance()->unload(this->respawnBuffer); 55 58 } 56 59 … … 65 68 66 69 LoadParam(root, "pickup-sound", this, PowerUp, loadPickupSound); 70 71 LoadParam(root, "respawn-sound", this, PowerUp, loadRespawnSound); 67 72 } 68 73 … … 70 75 void PowerUp::loadPickupSound(const char* pickupSound) 71 76 { 72 if (this-> soundBuffer != NULL)73 ResourceManager::getInstance()->unload(this-> soundBuffer);77 if (this->pickupBuffer != NULL) 78 ResourceManager::getInstance()->unload(this->pickupBuffer); 74 79 75 80 else if (pickupSound != NULL) 76 81 { 77 this-> soundBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);78 if (this-> soundBuffer != NULL)82 this->pickupBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV); 83 if (this->pickupBuffer != NULL) 79 84 { 80 85 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound, this->getName()); … … 86 91 } 87 92 else 88 this->soundBuffer = NULL; 89 } 93 this->pickupBuffer = NULL; 94 } 95 96 void PowerUp::loadRespawnSound(const char* respawnSound) 97 { 98 if (this->respawnBuffer != NULL) 99 ResourceManager::getInstance()->unload(this->respawnBuffer); 100 101 else if (respawnSound != NULL) 102 { 103 this->respawnBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV); 104 if (this->respawnBuffer != NULL) 105 { 106 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound, this->getName()); 107 } 108 else 109 { 110 PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound, this->getName()); 111 } 112 } 113 else 114 this->respawnBuffer = NULL; 115 } 116 90 117 91 118 void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) … … 95 122 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 96 123 { 97 if( soundBuffer != NULL)98 this->soundSource.play(this-> soundBuffer);124 if(pickupBuffer != NULL) 125 this->soundSource.play(this->pickupBuffer); 99 126 100 127 switch(respawnType) { … … 114 141 if(this->getOMListNumber() != OM_COMMON) { 115 142 this->respawnTime -= dt; 116 if(this->respawnTime <= 0) { 143 if(this->respawnTime <= 0) 144 { 117 145 this->toList(OM_COMMON); 146 this->soundSource.play(this->respawnBuffer); 147 118 148 } 119 149 } -
trunk/src/world_entities/power_ups/power_up.h
r7065 r7066 27 27 28 28 void loadPickupSound(const char* pickupSound); 29 void loadRespawnSound(const char* pickupSound); 29 30 30 31 virtual void draw () const; … … 43 44 private: 44 45 SoundSource soundSource; 45 SoundBuffer* soundBuffer; 46 SoundBuffer* pickupBuffer; 47 SoundBuffer* respawnBuffer; 46 48 Material* sphereMaterial; 47 49 PowerUpRespawn respawnType;
Note: See TracChangeset
for help on using the changeset viewer.