C# - Sound Handling - #xna
Submitted by edg3 on Fri, 06/04/2010 - 08:47
namespace GIADBase { class SoundHandler { public float GlobalVolume = 0.5f; protected Dictionary<string, SoundEffect> SoundEffects = new Dictionary<string, SoundEffect>(); public bool AddSoundEffect(string path, SoundEffect soundEffect) { if (!SoundEffects.Keys.Contains<string>(path)) { SoundEffects.Add(path, soundEffect); } else { return false; } return true; } public int PlaySoundEffect(string path, float Volume, float Pitch, float Pan) { SoundEffects[path].Play(Volume * GlobalVolume, Pitch, Pan); return 0; } //TODO: add music playing here } }