using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;

namespace GhostArena3
{
    class SoundManager : GameComponent, ISoundManager
    {

        private AudioEngine _audio;
        private WaveBank _wavebank;
        private SoundBank _soundbank;

        public SoundManager(Game game)
            : base (game)
        {

        }

        public override void Initialize()
        {
            _audio = new AudioEngine("Content/Chapter3sounds.xgs");
            _wavebank = new WaveBank(_audio, "Content/Wave Bank.xwb");
            _soundbank = new SoundBank(_audio, "Content/Sound Bank.xsb");

            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            _audio.Update();

            base.Update(gameTime);
        }

        public void StartCue(string name)
        {
            _soundbank.PlayCue(name);
        }

        public Cue GetCue(string name)
        {
            return _soundbank.GetCue(name);
        }

        public void StopCue(string name)
        {
            _soundbank.GetCue(name).Stop(AudioStopOptions.Immediate);
        }

        public SoundManager GetSoundManager()
        {
            return this;
        }
    }
}
