public DemoSound GetSound(PhysicsSound soundData, DemoListener listener, DemoEmitter emitter) { int index; DemoSound sound; if (currentSounds.Count > 0) { index = currentSounds.Count - 1; sound = currentSounds[index]; currentSounds.RemoveAt(index); } else { sound = new DemoSound(demo.SoundQueue, this); totalSounds.Add(sound); } sound.SoundData = soundData; sound.Listener = listener; sound.Emitter = emitter; return(sound); }
public void Clear() { DemoSoundUnit hitSoundUnit; SoundData = null; if (enableHit) { for (int i = 0; i < hitSoundUnits.Length; i++) { hitSoundUnit = hitSoundUnits[i]; if (hitSoundUnit.State == ALSourceState.Playing) { hitSoundUnit.Volume = 0.0f; hitSoundUnit.Stop(); } if (hitSoundUnit.SourceHandle != 0) { soundQueue.EnqueueSource(hitSoundUnit.SourceHandle); hitSoundUnit.SourceHandle = 0; } } } if (enableRoll) { if (rollSoundUnit.State == ALSourceState.Playing) { rollSoundUnit.Volume = 0.0f; rollSoundUnit.Stop(); } if (rollSoundUnit.SourceHandle != 0) { soundQueue.EnqueueSource(rollSoundUnit.SourceHandle); rollSoundUnit.SourceHandle = 0; } } if (enableSlide) { if (slideSoundUnit.State == ALSourceState.Playing) { slideSoundUnit.Volume = 0.0f; slideSoundUnit.Stop(); } if (slideSoundUnit.SourceHandle != 0) { soundQueue.EnqueueSource(slideSoundUnit.SourceHandle); slideSoundUnit.SourceHandle = 0; } } if (enableBackground) { if (backgroundSoundUnit.State == ALSourceState.Playing) { backgroundSoundUnit.Volume = 0.0f; backgroundSoundUnit.Stop(); } if (backgroundSoundUnit.SourceHandle != 0) { soundQueue.EnqueueSource(backgroundSoundUnit.SourceHandle); backgroundSoundUnit.SourceHandle = 0; } } }