#region File Description
//-----------------------------------------------------------------------------
// Sound.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.IO;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
#endregion
namespace Marblets
{
///
/// An enum for all of the Marblets sounds
///
public enum SoundEntry
{
///
/// Title Screen music
///
MusicTitle,
///
/// In game music
///
MusicGame,
///
/// GameOver
///
MusicGameOver,
///
/// Board cleared
///
MusicBoardCleared,
///
/// Start 3d game
///
Menu3DStart,
///
/// Start 2d game
///
Menu2DStart,
///
/// Move cursor
///
Navigate,
///
/// Clear Marbles
///
ClearMarbles,
///
/// Illegal clear less than 2 marbles
///
ClearIllegal,
///
/// Bonus sound for large clear
///
ClearBonus,
///
/// Marbles landing after breaking
///
LandMarbles,
}
///
/// Abstracts away the sounds for a simple interface using the Sounds enum
///
public static class Sound
{
private static string[] cueNames = new string[]
{
"IntroMus", //Title Screen
"MusLoop_Temp1", //In-Game Music
"MusLoop_Temp1", //Game Over
"MusLoop_Temp1", //Clear Board
"start_3", //Menu: 3D select (button press)
"start_3", //Menu: 2D select (button press)
"navigate_1", //In-Game Cursor Move
"clear_4", //Clear marbles (Press A)
"clear_illegal", //Illegal clear (press A w/<2 marbles selected)
"clear_bonus", //Large break bonus
"drop2", //Marbles impact sound (after fall)
};
const int SoundCount = 11;
private static SoundEffect[] soundEffects = new SoundEffect[SoundCount];
public static void Play(SoundEntry sound)
{
soundEffects[(int)sound].Play();
}
public static SoundEffectInstance PlayMusic(SoundEntry sound)
{
SoundEffectInstance instance = soundEffects[(int)sound].CreateInstance();
instance.IsLooped = (sound == SoundEntry.MusicGame);
instance.Play();
return instance;
}
public static void StopMusic(SoundEffectInstance instance)
{
if(instance != null)
{
instance.Stop();
instance.Dispose();
}
}
public static void LoadContent(ContentManager content)
{
for(int i = 0; i < SoundCount; i++)
{
soundEffects[i] = content.Load("Audio/Wav/" + cueNames[i]);
}
}
}
}