diff options
Diffstat (limited to 'Penguloon/SoundManager.cs')
| -rw-r--r-- | Penguloon/SoundManager.cs | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/Penguloon/SoundManager.cs b/Penguloon/SoundManager.cs index ddc32fa..6722a4e 100644 --- a/Penguloon/SoundManager.cs +++ b/Penguloon/SoundManager.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework.Audio; +using System; +using Microsoft.Xna.Framework.Audio; namespace Penguloon { @@ -12,18 +13,41 @@ namespace Penguloon public static SoundEffectInstance GameOver { get; set; } public static SoundEffectInstance Upgrade { get; set; } public static SoundEffectInstance Unavailable { get; set; } + public static SoundEffectInstance Sell { get; set; } + + private static bool muted = false; + + public static bool Muted + { + get { return muted; } + set { muted = value; if (!value) StartBaseline(); else StopBaseLine(); } + } + + private static void StopBaseLine() + { + Baseline.Volume = 0.0f; + } public static void StartBaseline() { - SoundEffect effect = ContentManager.GetSound("Sounds/baseline"); - Baseline = effect.CreateInstance(); + if (Muted) return; + + if (Baseline == null) + { + SoundEffect effect = ContentManager.GetSound("Sounds/baseline"); + Baseline = effect.CreateInstance(); + Baseline.Volume = 0.1f; + Baseline.IsLooped = true; + Baseline.Play(); + } + Baseline.Volume = 0.1f; - Baseline.IsLooped = true; - Baseline.Play(); } public static void PlayClickSound() { + if (Muted) return; + if(BtnClick == null) { SoundEffect effect = ContentManager.GetSound("Sounds/click"); @@ -37,6 +61,8 @@ namespace Penguloon public static void PlayClickSound2() { + if (Muted) return; + if (BtnClick2 == null) { SoundEffect effect = ContentManager.GetSound("Sounds/click2"); @@ -50,6 +76,8 @@ namespace Penguloon public static void PlayClickSound3() { + if (Muted) return; + if (BtnClick3 == null) { SoundEffect effect = ContentManager.GetSound("Sounds/click3"); @@ -63,6 +91,8 @@ namespace Penguloon public static void PlayPlaceObjectSound() { + if (Muted) return; + if (PlaceObject == null) { SoundEffect effect = ContentManager.GetSound("Sounds/placeobject"); @@ -76,6 +106,8 @@ namespace Penguloon public static void PlayGameOverSound() { + if (Muted) return; + if (GameOver == null) { SoundEffect effect = ContentManager.GetSound("Sounds/gameover"); @@ -89,6 +121,8 @@ namespace Penguloon public static void PlayUpgradeSound() { + if (Muted) return; + if (Upgrade == null) { SoundEffect effect = ContentManager.GetSound("Sounds/upgrade"); @@ -102,6 +136,8 @@ namespace Penguloon public static void PlayUnavailableSound() { + if (Muted) return; + if (Unavailable == null) { SoundEffect effect = ContentManager.GetSound("Sounds/unavailable"); @@ -113,8 +149,25 @@ namespace Penguloon Unavailable.Play(); } + public static void PlaySellSound() + { + if (Muted) return; + + if (Sell == null) + { + SoundEffect effect = ContentManager.GetSound("Sounds/sell"); + Sell = effect.CreateInstance(); + Sell.Volume = 1f; + Sell.IsLooped = false; + } + + Sell.Play(); + } + public static void PlayBalloonPopSound() { + if (Muted) return; + SoundEffect popEffect = ContentManager.GetSound("Sounds/pop"); popEffect.Play(0.5f, 0f, 0f); } |
