Example #1
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }
            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing.
                performing = (Hit != null && DSound.isPlaying(Hit)) || (expl != null && DSound.isPlaying(expl));
                return;
            }

            performing = true;
            base.onTick();
            playSound3d(moveSound, false, false);
            if (inFiringRange())
            {
                moveSound.Stop();
                Hit = target.loadSound(target.soundPath + "bsg" + Common.getRandom(3, 4) + ".wav");
                target.playSound(Hit, true, false);
                fireHitEvent(target, Common.getRandom(100, 200));
                finished = true;
                return;
            }

            if (!DSound.isPlaying(moveSound))
            {
                finished = true;
                explode();
                performing = (Hit != null && DSound.isPlaying(Hit)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Example #2
0
        public void flush()
        {
            if (audioBuffer != null)
            {
                audioBuffer.Stop();
                audioBuffer.CurrentPosition = 0;
                //audioBuffer.Write(silence, 0, LockFlags.None);
            }

            offsetBytes = 0;
            prevPlayPos = 0;

            ptsPos     = 0;
            prevPtsPos = 0;
            playLoops  = 0;
            ptsLoops   = 0;
        }
Example #3
0
 public void Pause()
 {
     lock (_syncObj)
         if (_isPlaying && _secondaryBuffer != null)
         {
             _secondaryBuffer.Stop();
             _isPlaying = false;
         }
 }
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }

            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing or sound will get cut.
                performing = (missileHitSound != null && DSound.isPlaying(missileHitSound)) || (expl != null && DSound.isPlaying(expl));
                return;
            }

            performing = true;
            playSound3d(missileSound, false, true);
            base.onTick();
            if (inFiringRange())
            {
                missileSound.Stop();
                missileHitSound = target.loadSound(target.soundPath + "m3-" + Common.getRandom(1, 3) + ".wav");
                target.playSound(missileHitSound, true, false);
                target.hit(Common.getRandom(101, 200), Interaction.Cause.destroyedByWeapon);
                fireHitEvent(target, target.damage);
                finished = true;
                return;
            }
            if (totalDistance > 15.0)
            {
                missileSound.Stop();
                explode();
                finished   = true;
                performing = (missileHitSound != null && DSound.isPlaying(missileHitSound)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Example #5
0
 public override void move()
 {
     if (firstLoad)
     {
         playSound(moveSound, true, true);
         firstLoad = false;
     }
     performDeaths();
     if (readyToTerminate())
     {
         moveSound.Stop();
         isProjectorStopped = true;
         return;
     }
     if (!isRequestedTerminated)
     {
         base.move();
         playSound(moveSound, false, true);
         base.updateTotalDistance();
         registerLock();
         fireWeapon();
         processRoute();
     }
 }
 public void StopSound()
 {
     if (IsPlaying)
     {
         try
         {
             _deviceBuffer.Stop();
         }
         catch (DirectSoundException)
         {
         }
     }
     _deviceBuffer.Dispose();
     _deviceBuffer     = null;
     BufferSizeSamples = 0;
 }
Example #7
0
        public void Stop()
        {
            lock (this)
            {
                if (Secondary != null)
                {
                    Secondary.Stop();
                    Secondary.Dispose();
                    Secondary = null;
                }

                BytesWritten         = 0;
                CurrentWritePosition = 0;
                PlayingStarted       = false;
                Started = false;
            }
        }