C# - Sound Handling - #xna

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
    }
}

User login

Powered by Drupal, an open source content management system

Random image

Worm Hole 3