A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
748 B

  1. using Microsoft.Xna.Framework.Audio;
  2. using System;
  3. namespace SemiColinGames {
  4. public class MusicPlayer : IDisposable {
  5. public static bool Enabled = true;
  6. private SoundEffectInstance music;
  7. ~MusicPlayer() {
  8. Dispose();
  9. }
  10. public void Dispose() {
  11. Stop();
  12. music?.Dispose();
  13. GC.SuppressFinalize(this);
  14. }
  15. public void Load(SoundEffect sound) {
  16. if (sound == null) {
  17. return;
  18. }
  19. music = sound.CreateInstance();
  20. music.IsLooped = true;
  21. music.Volume = 0.1f;
  22. }
  23. public void Stop() {
  24. music?.Stop();
  25. }
  26. public void Pause() {
  27. music?.Pause();
  28. }
  29. public void Play() {
  30. if (Enabled) {
  31. music?.Play();
  32. }
  33. }
  34. }
  35. }