29 lines
825 B
C#
29 lines
825 B
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Zennysoft.Game.Implementation;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
public partial class BGMPlayer : DimmableAudioStreamPlayer
|
|
{
|
|
private static string _bgmPath = $"res://src/audio/bgm/";
|
|
private IDictionary<BackgroundMusic, AudioStream> _bgmDictionary;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_bgmDictionary = new Dictionary<BackgroundMusic, AudioStream>();
|
|
var backgroundMusic = Enum.GetValues(typeof(BackgroundMusic));
|
|
foreach (var bgm in backgroundMusic)
|
|
_bgmDictionary.Add((BackgroundMusic)bgm, GD.Load<AudioStream>(_bgmPath + bgm + ".ogg"));
|
|
}
|
|
|
|
public void Play(BackgroundMusic backgroundMusic)
|
|
{
|
|
_bgmDictionary.TryGetValue(backgroundMusic, out var stream);
|
|
Stream = stream;
|
|
FadeIn();
|
|
}
|
|
}
|