Initial music impl

This commit is contained in:
2021-04-23 20:28:06 +02:00
parent 44f0f9e399
commit 1aa7a57d91
19 changed files with 171 additions and 7 deletions
+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SynthySound;
namespace EvilSatellites
{
public class MusicManager
{
public ISoundEffect Song;
public float _Volume;
public float Volume {
get => _Volume;
set
{
if (IsPlaying)
{
Song.Volume = Volume;
}
_Volume = Volume;
}
}
public bool IsPlaying;
public Synthy Engine;
public MusicManager(Synthy engine)
{
Engine = engine;
_Volume = 0.2f;
IsPlaying = false;
}
public void Play(string path)
{
if (IsPlaying)
{
Song.Stop();
Song.Destroy();
}
Song = Engine.Load(@"sfx/music/" + path + ".mp3", false, true);
Song.Play();
Song.Volume = _Volume;
Song.Loop = true;
IsPlaying = true;
}
public void Stop()
{
if (IsPlaying)
{
Song.Stop();
Song.Destroy();
IsPlaying = false;
}
}
}
}