private SoundEffect LoadSound(string name) { if (SoundsEnabled) { SoundEffect sound; try { sound = Game.Content.Load <SoundEffect>(name); } catch (Microsoft.Xna.Framework.Audio.NoAudioHardwareException e) { // If no audio hardware is installed, print a warning and don't try to load sounds again MessageOverlay.Show("Audio error", e.Message); SoundsEnabled = false; return(null); } loadedSounds.Add(name, sound); return(sound); } else { return(null); } }