Changeset 4883 in orxonox.OLD for orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc
- Timestamp:
- Jul 17, 2005, 4:02:36 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc
r4882 r4883 53 53 for (int i = 0; i < WA_ACTION_COUNT; i++) 54 54 if (this->soundBuffers[i]) 55 delete this->soundBuffers[i];55 ResourceManager::getInstance()->unload(this->soundBuffers[i]); 56 56 } 57 57 … … 73 73 74 74 this->requestedAction = WA_NONE; 75 this-> weaponSource = NULL;75 this->soundSource = new SoundSource(this); 76 76 77 77 this->active = true; … … 86 86 } 87 87 88 /** 89 * sets a new projectile to the weapon 90 * @param new projectile for this weapon 88 89 void Weapon::setActionSound(WeaponAction action, const char* soundFile) 90 { 91 if (action >= WA_ACTION_COUNT) 92 return; 93 else 94 { 95 this->soundBuffers[action] = (SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV); 96 if (this->soundBuffers[action] != NULL) 97 { 98 PRINTF(4)("Loaded sound %s to action %s\n", soundFile, actionToChar(action)); 99 } 100 else 101 { 102 PRINTF(4)("failed to load sound %s to %s\n", soundFile, actionToChar(action)); 103 } 104 105 } 106 } 107 108 /** 109 * request an action that should be executed, 110 * @param action the next action to take 91 111 * 92 * weapon an projectile are independent, so you can combine them as you want 93 */ 94 void Weapon::setProjectile(Projectile* projectile) 95 { 96 this->projectile = projectile; 97 } 98 99 100 /** 101 * sets a new projectile to the weapon 102 * @returns the current projectile of this weapon 103 * 104 * weapon an projectile are independent, so you can combine them as you want 105 */ 106 Projectile* Weapon::getProjectile() 107 { 108 return this->projectile; 109 } 110 111 112 * This function must be called instead of the actions (like fire/reload...) 113 * to make all the checks needed to have a usefull WeaponSystem. 114 */ 112 115 void Weapon::requestAction(WeaponAction action) 113 116 { … … 187 190 { 188 191 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 192 193 if (this->soundBuffers[WA_ACTIVATE] != NULL) 194 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 189 195 } 190 196 … … 196 202 { 197 203 PRINTF(4)("Deactivating the Weapon %s\n", this->getName()); 204 205 if (this->soundBuffers[WA_DEACTIVATE] != NULL) 206 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 198 207 } 199 208 … … 201 210 { 202 211 this->energyLoaded -= this->minCharge; 212 213 if (this->soundBuffers[WA_SHOOT] != NULL) 214 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 203 215 } 204 216 … … 226 238 this->energy -= chargeSize; 227 239 } 240 if (this->soundBuffers[WA_RELOAD] != NULL) 241 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 242 228 243 } 229 244 230 245 void Weapon::charge() 231 246 { 247 if (this->soundBuffers[WA_CHARGE] != NULL) 248 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 249 232 250 } 233 251
Note: See TracChangeset
for help on using the changeset viewer.