Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7066 in orxonox.OLD for trunk/src/world_entities/power_ups


Ignore:
Timestamp:
Feb 7, 2006, 1:29:17 PM (19 years ago)
Author:
bensch
Message:

powerup respawn sound

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  
    4545
    4646  this->soundSource.setSourceNode(this);
    47   this->soundBuffer = NULL;
     47  this->pickupBuffer = NULL;
     48  this->respawnBuffer = NULL;
    4849}
    4950
     
    5152{
    5253  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);
    5558}
    5659
     
    6568
    6669  LoadParam(root, "pickup-sound", this, PowerUp, loadPickupSound);
     70
     71  LoadParam(root, "respawn-sound", this, PowerUp, loadRespawnSound);
    6772}
    6873
     
    7075void PowerUp::loadPickupSound(const char* pickupSound)
    7176{
    72   if (this->soundBuffer != NULL)
    73     ResourceManager::getInstance()->unload(this->soundBuffer);
     77  if (this->pickupBuffer != NULL)
     78    ResourceManager::getInstance()->unload(this->pickupBuffer);
    7479
    7580  else if (pickupSound != NULL)
    7681{
    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)
    7984  {
    8085    PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound, this->getName());
     
    8691}
    8792  else
    88     this->soundBuffer = NULL;
    89 }
     93    this->pickupBuffer = NULL;
     94}
     95
     96void 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
    90117
    91118void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
     
    95122    if(dynamic_cast<Extendable*>(entity)->pickup(this))
    96123    {
    97       if(soundBuffer != NULL)
    98         this->soundSource.play(this->soundBuffer);
     124      if(pickupBuffer != NULL)
     125        this->soundSource.play(this->pickupBuffer);
    99126
    100127      switch(respawnType) {
     
    114141  if(this->getOMListNumber() != OM_COMMON) {
    115142    this->respawnTime -= dt;
    116     if(this->respawnTime <= 0) {
     143    if(this->respawnTime <= 0)
     144    {
    117145      this->toList(OM_COMMON);
     146      this->soundSource.play(this->respawnBuffer);
     147
    118148    }
    119149  }
  • trunk/src/world_entities/power_ups/power_up.h

    r7065 r7066  
    2727
    2828  void loadPickupSound(const char* pickupSound);
     29  void loadRespawnSound(const char* pickupSound);
    2930
    3031  virtual void draw () const;
     
    4344private:
    4445  SoundSource    soundSource;
    45   SoundBuffer*   soundBuffer;
     46  SoundBuffer*   pickupBuffer;
     47  SoundBuffer*   respawnBuffer;
    4648  Material* sphereMaterial;
    4749  PowerUpRespawn respawnType;
Note: See TracChangeset for help on using the changeset viewer.