Added final features for this release. Now only polishing (if needed) remains.
Features: Sacrifice-Node, Maintain-Node, Options for screen type, lightcolor and soundvolume, tied in sound effects, game pause when menu is open, visibly open up gate when opening it.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Godot;
|
||||
|
||||
public partial class SoundManager : Node
|
||||
{
|
||||
private static SoundManager instance;
|
||||
|
||||
[Export] private AudioStreamPlayer buttonSound;
|
||||
[Export] private AudioStreamPlayer miningSound;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
if (instance == this)
|
||||
{
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayButton()
|
||||
{
|
||||
if (instance == null || instance.buttonSound == null) return;
|
||||
|
||||
instance.buttonSound.Play();
|
||||
}
|
||||
|
||||
public static void PlayMining()
|
||||
{
|
||||
if (instance == null || instance.miningSound == null) return;
|
||||
|
||||
instance.miningSound.Play();
|
||||
}
|
||||
|
||||
public static void SetMasterVolume(float percent)
|
||||
{
|
||||
percent = Mathf.Clamp(percent, 0f, 1f);
|
||||
int busIndex = AudioServer.GetBusIndex("Master");
|
||||
AudioServer.SetBusVolumeDb(busIndex, Mathf.LinearToDb(percent));
|
||||
AudioServer.SetBusMute(busIndex, percent <= 0f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user