Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6245


Ignore:
Timestamp:
Dec 4, 2009, 3:52:28 PM (15 years ago)
Author:
youngk
Message:

Implemented Firing sounds in Weapons HsW01, LightningGun and RocketFire. Engine and Explosion sounds for the Rocket are not yet implemented.
From now on, when creating a new sound for a weapon, just insert "this→setDefaultSound(PATH_TO_FILE)" into the constructor of the weapon.

Sound Files for HsW01 and LightningGun will be available in a couple of minutes

Location:
code/branches/presentation2/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc

    r6227 r6245  
    5252        RegisterObject(HsW01);
    5353
    54         this->reloadTime_ = 0.5;
     54        this->reloadTime_ = 0.25;
    5555        this->damage_ = 15;
    5656        this->speed_ = 2500;
     
    6161        this->delayTimer_.stopTimer();
    6262
    63         this->defSndWpnFire_ = new WorldSound(this);
    64         this->defSndWpnFire_->setLooping(false);
    65         this->setDefaultSound("sounds/Weapon_Laser_shrt.ogg");
     63        this->setDefaultSound("sounds/Weapon_HsW01.ogg");
    6664    }
    6765
    6866    HsW01::~HsW01()
    6967    {
    70         if(this->isInitialized())
    71         {
    72             delete this->defSndWpnFire_;
    73         }
    7468    }
    7569
     
    106100    void HsW01::fire()
    107101    {
    108         this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
    109         this->defSndWpnFire_->play();
    110 
    111102        this->delayTimer_.startTimer();
    112 
    113         //this->defSndWpnFire_->stop();
    114103    }
    115104
     
    142131        HsW01::muendungsfeuer();
    143132    }
    144 
    145     void HsW01::setDefaultSound(const std::string& soundPath)
    146     {
    147         this->defSndWpnFire_->setSource(soundPath);
    148     }
    149 
    150     const std::string& HsW01::getDefaultSound()
    151     {
    152         return this->defSndWpnFire_->getSource();
    153     }
    154133}
  • code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h

    r6227 r6245  
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4747
    48             void setDefaultSound(const std::string& soundPath);
    49             const std::string& getDefaultSound();
    50 
    5148        private:
    5249            void setMaterial(const std::string& material);
     
    6158            float delay_;
    6259            Timer delayTimer_;
    63 
    64             WorldSound* defSndWpnFire_;
    6560    };
    6661}
  • code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc

    r6154 r6245  
    3636#include "worldentities/pawns/Pawn.h"
    3737
     38#include "sound/WorldSound.h"
     39
    3840namespace orxonox
    3941{
     
    4951
    5052        this->setMunitionName("LaserMunition");
     53        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
    5154    }
    5255
     
    5659
    5760    void LightningGun::fire()
    58     {
     61    {       
    5962        LightningGunProjectile* projectile = new LightningGunProjectile(this);
    6063        projectile->setMaterial("Flares/LightningBall_");
  • code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.h

    r5781 r6245  
    4242
    4343            virtual void fire();
     44
    4445       private:
    4546            float speed_;
  • code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc

    r6153 r6245  
    3838#include "worldentities/pawns/Pawn.h"
    3939
     40#include "sound/WorldSound.h"
     41
    4042namespace orxonox
    4143{
     
    5254
    5355        this->setMunitionName("RocketMunition");
     56        this->setDefaultSound("sounds/Rocket_Launch.ogg");
     57    }
     58
     59    RocketFire::~RocketFire()
     60    {
    5461    }
    5562
  • code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h

    r6107 r6245  
    3939        public:
    4040            RocketFire(BaseObject* creator);
    41             virtual ~RocketFire() {}
     41            virtual ~RocketFire();
    4242
    4343            virtual void fire();
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc

    r6165 r6245  
    4040#include "WeaponSystem.h"
    4141
     42#include "sound/WorldSound.h"
     43
    4244namespace orxonox
    4345{
     
    6769        this->muzzlePosition_ = Vector3::ZERO;
    6870        this->muzzleOrientation_ = Quaternion::IDENTITY;
     71
     72        this->defSndWpnFire_ = new WorldSound(this);
     73        this->defSndWpnFire_->setLooping(false);
    6974    }
    7075
    7176    WeaponMode::~WeaponMode()
    7277    {
     78        if(this->isInitialized())
     79        {
     80            delete this->defSndWpnFire_;
     81        }
    7382    }
    7483
     
    113122            this->reloadTimer_.startTimer();
    114123
     124            assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
     125            this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
     126            if(!(this->defSndWpnFire_->isPlaying()))
     127            {
     128                this->defSndWpnFire_->play();
     129            }
     130           
    115131            this->fire();
    116132
     
    200216    void WeaponMode::reloaded()
    201217    {
     218        if(this->defSndWpnFire_->isPlaying())
     219        {
     220            this->defSndWpnFire_->stop();
     221        }
    202222        this->bReloading_ = false;
    203223    }
     
    228248            return WorldEntity::FRONT;
    229249    }
     250
     251    void WeaponMode::setDefaultSound(const std::string& soundPath)
     252    {
     253        this->defSndWpnFire_->setSource(soundPath);
     254    }
     255
     256    const std::string& WeaponMode::getDefaultSound()
     257    {
     258        return this->defSndWpnFire_->getSource();
     259    }
    230260}
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h

    r6150 r6245  
    5151            bool fire(float* reloadTime);
    5252            bool reload();
     53
     54            // Interacting with the default Firing sound
     55            void setDefaultSound(const std::string& soundPath);
     56            const std::string& getDefaultSound();
    5357
    5458
     
    160164            Vector3 muzzlePosition_;
    161165            Quaternion muzzleOrientation_;
     166
     167            WorldSound* defSndWpnFire_;
    162168    };
    163169}
Note: See TracChangeset for help on using the changeset viewer.