[Orxonox-commit 1509] r6227 - code/branches/presentation2/src/modules/weapons/weaponmodes

youngk at orxonox.net youngk at orxonox.net
Thu Dec 3 17:14:49 CET 2009


Author: youngk
Date: 2009-12-03 17:14:49 +0100 (Thu, 03 Dec 2009)
New Revision: 6227

Modified:
   code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
   code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h
Log:
Inserted a firing sound into HsW01. BUG: Sound plays only once on first fire.

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc	2009-12-03 15:31:06 UTC (rev 6226)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc	2009-12-03 16:14:49 UTC (rev 6227)
@@ -41,6 +41,8 @@
 #include "worldentities/WorldEntity.h"
 #include "worldentities/pawns/Pawn.h"
 
+#include "sound/WorldSound.h"
+
 namespace orxonox
 {
     CreateFactory(HsW01);
@@ -49,7 +51,7 @@
     {
         RegisterObject(HsW01);
 
-        this->reloadTime_ = 0.25;
+        this->reloadTime_ = 0.5;
         this->damage_ = 15;
         this->speed_ = 2500;
         this->delay_ = 0;
@@ -57,8 +59,20 @@
 
         this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
         this->delayTimer_.stopTimer();
+
+        this->defSndWpnFire_ = new WorldSound(this);
+        this->defSndWpnFire_->setLooping(false);
+        this->setDefaultSound("sounds/Weapon_Laser_shrt.ogg");
     }
 
+    HsW01::~HsW01()
+    {
+        if(this->isInitialized())
+        {
+            delete this->defSndWpnFire_;
+        }
+    }
+
     void HsW01::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(HsW01, XMLPort, xmlelement, mode);
@@ -91,7 +105,12 @@
 
     void HsW01::fire()
     {
+        this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
+        this->defSndWpnFire_->play();
+
         this->delayTimer_.startTimer();
+
+        //this->defSndWpnFire_->stop();
     }
 
     void HsW01::muendungsfeuer()
@@ -122,4 +141,14 @@
 
         HsW01::muendungsfeuer();
     }
+
+    void HsW01::setDefaultSound(const std::string& soundPath)
+    {
+        this->defSndWpnFire_->setSource(soundPath);
+    }
+
+    const std::string& HsW01::getDefaultSound()
+    {
+        return this->defSndWpnFire_->getSource();
+    }
 }

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h	2009-12-03 15:31:06 UTC (rev 6226)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h	2009-12-03 16:14:49 UTC (rev 6227)
@@ -40,11 +40,14 @@
     {
         public:
             HsW01(BaseObject* creator);
-            virtual ~HsW01() {}
+            virtual ~HsW01();
 
             virtual void fire();
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
+            void setDefaultSound(const std::string& soundPath);
+            const std::string& getDefaultSound();
+
         private:
             void setMaterial(const std::string& material);
             std::string& getMaterial();
@@ -57,6 +60,8 @@
             float speed_;
             float delay_;
             Timer delayTimer_;
+
+            WorldSound* defSndWpnFire_;
     };
 }
 




More information about the Orxonox-commit mailing list