using Microsoft.Xna.Framework.Audio;

namespace AlienAttack
{
	public static class AudioManager
	{
		// the different fx that can be played
		public enum Cue
		{
			EnemyShot,
			PlayerShot,
			Explosion
		};

		// instances of the effects
		private static readonly SoundEffect _theme;
		private static readonly SoundEffect _enemyShot;
		private	static readonly SoundEffect _playerShot;
		private static readonly SoundEffect _explosion;

		private static readonly SoundEffectInstance _themeInstance;

		static AudioManager()
		{
			// load 'em up
			_theme = AlienAttackGame.Instance.Content.Load<SoundEffect>("sfx\\theme");
			_themeInstance = _theme.CreateInstance();
			_enemyShot = AlienAttackGame.Instance.Content.Load<SoundEffect>("sfx\\enemyShot");
			_playerShot = AlienAttackGame.Instance.Content.Load<SoundEffect>("sfx\\playerShot");
			_explosion = AlienAttackGame.Instance.Content.Load<SoundEffect>("sfx\\explosion");
		}

		public static void PlayCue(Cue cue)
		{
			// play the effect requested
			switch(cue)
			{
				case Cue.EnemyShot:
					_enemyShot.Play();
					break;
				case Cue.PlayerShot:
					_playerShot.Play();
					break;
				case Cue.Explosion:
					_explosion.Play();
					break;
			}
		}

		public static void StartTheme()
		{
			_themeInstance.Play();
		}

		public static void StopTheme()
		{
			_themeInstance.Stop();
		}
	}
}
