using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; namespace Asteroid_Belt_Assault { public static class SoundManager { private static List explosions = new List(); private static int explosionCount = 4; private static SoundEffect playerShot; private static SoundEffect enemyShot; private static Random rand = new Random(); public static void Initialize(ContentManager content) { try { playerShot = content.Load(@"Sounds\Shot1"); enemyShot = content.Load(@"Sounds\Shot2"); for (int x = 1; x <= explosionCount; x++) { explosions.Add( content.Load(@"Sounds\Explosion" + x.ToString())); } } catch { Debug.Write("SoundManager Initialization Failed"); } } public static void PlayExplosion() { try { explosions[rand.Next(0, explosionCount)].Play(); } catch { Debug.Write("PlayExplosion Failed"); } } public static void PlayPlayerShot() { try { playerShot.Play(); } catch { Debug.Write("PlayPlayerShot Failed"); } } public static void PlayEnemyShot() { try { enemyShot.Play(); } catch { Debug.Write("PlayEnemyShot Failed"); } } } }