Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7084 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Feb 7, 2006, 4:51:27 PM (18 years ago)
Author:
bensch
Message:

HACK

Location:
trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/projectiles/bomb.cc

    r6825 r7084  
    7979  this->detonationMaterial = new Material();
    8080  this->detonationMaterial->setDiffuse(1, 0, 0);
     81
     82  this->loadExplosionSound("sound/explosions/explosion_7_far.wav");
    8183  //   this->detonationMaterial->setTransparency(.1);
    8284  /**
  • trunk/src/world_entities/projectiles/projectile.cc

    r6434 r7084  
    2222#include "world_entities/weapons/weapon.h"
    2323#include "model.h"
     24#include "resource_manager.h"
    2425
    2526using namespace std;
     
    3738  this->target = NULL;
    3839  this->removeNode();
     40
     41  this->explosionBuffer = NULL;
     42  this->engineBuffer = NULL;
    3943}
    4044
     
    4549Projectile::~Projectile ()
    4650{
     51  if (this->explosionBuffer != NULL)
     52    ResourceManager::getInstance()->unload(this->explosionBuffer);
     53  if (this->engineBuffer != NULL)
     54    ResourceManager::getInstance()->unload(this->engineBuffer);
    4755  /*
    4856     do not delete the test projectModel, since it is pnode
     
    5058  */
    5159  //delete this->projectileModel;
     60}
     61
     62
     63void Projectile::loadExplosionSound(const char* explosionSound)
     64{
     65  if (this->explosionBuffer != NULL)
     66    ResourceManager::getInstance()->unload(this->explosionBuffer);
     67
     68  else if (explosionSound != NULL)
     69  {
     70    this->explosionBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(explosionSound, WAV);
     71    if (this->explosionBuffer != NULL)
     72    {
     73      PRINTF(4)("Loaded sound %s to Pickup: %s.\n", explosionSound, this->getName());
     74    }
     75    else
     76    {
     77      PRINTF(2)("Failed to load sound %s to explosion %s.\n.", explosionSound, this->getName());
     78    }
     79  }
     80  else
     81    this->explosionBuffer = NULL;
     82}
     83
     84
     85void Projectile::loadEngineSound(const char* engineSound)
     86{
     87  if (this->engineBuffer != NULL)
     88    ResourceManager::getInstance()->unload(this->engineBuffer);
     89
     90  else if (engineSound != NULL)
     91  {
     92    this->engineBuffer = (SoundBuffer*)ResourceManager::getInstance()->load(engineSound, WAV);
     93    if (this->engineBuffer != NULL)
     94    {
     95      PRINTF(4)("Loaded sound %s to Pickup: %s.\n", engineSound, this->getName());
     96    }
     97    else
     98    {
     99      PRINTF(2)("Failed to load sound %s to engine %s.\n.", engineSound, this->getName());
     100    }
     101  }
     102  else
     103    this->engineBuffer = NULL;
    52104}
    53105
     
    114166*/
    115167void Projectile::destroy ()
    116 {}
     168{
     169  if (this->explosionBuffer != NULL)
     170    this->soundSource.play(this->explosionBuffer);
     171}
    117172
  • trunk/src/world_entities/projectiles/projectile.h

    r6434 r7084  
    1212#include "world_entity.h"
    1313
     14#include "sound_source.h"
     15#include "sound_buffer.h"
     16
    1417class Projectile : public WorldEntity
    1518{
     
    2225    void setLifeSpan(float lifeSpan);
    2326
    24 
     27    void loadExplosionSound(const char* explosionSound);
     28    void loadEngineSound(const char* engineSound);
    2529    void setMinEnergy(float energyMin);
    2630    /** @returns the minimal charched energy */
     
    5862
    5963    PNode*                target;                    //!< A target for guided Weapons.
     64
     65    SoundSource          soundSource;
     66  private:
     67    SoundBuffer*          explosionBuffer;
     68    SoundBuffer*          engineBuffer;
    6069};
    6170
  • trunk/src/world_entities/weapons/test_gun.cc

    r6778 r7084  
    9797{
    9898  this->init();
    99   this->loadParams(root);
     99  if (root != NULL)
     100    this->loadParams(root);
    100101}
    101102
Note: See TracChangeset for help on using the changeset viewer.