Initial music impl
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user