diff --git a/GFramework.Core.Godot/system/AbstractAudioManagerSystem.cs b/GFramework.Core.Godot/system/AbstractAudioManagerSystem.cs index 0df032f..077686f 100644 --- a/GFramework.Core.Godot/system/AbstractAudioManagerSystem.cs +++ b/GFramework.Core.Godot/system/AbstractAudioManagerSystem.cs @@ -203,6 +203,63 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager player.Play(); } + /// + /// 播放特效音效 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + public virtual void PlaySfx(string audioPath, float volume = 1.0f, float pitch = 1.0f) + { + if (AvailableSoundPlayers.Count == 0) return; + + var audioStream = ResourceLoadSystem?.LoadResource(audioPath); + if (audioStream == null) return; + + var player = AvailableSoundPlayers.Dequeue(); + player.Stream = audioStream; + player.VolumeDb = LinearToDb(volume * SfxVolume * MasterVolume); + player.Play(); + } + + /// + /// 播放语音 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + public virtual void PlayVoice(string audioPath, float volume = 1.0f, float pitch = 1.0f) + { + if (AvailableSoundPlayers.Count == 0) return; + + var audioStream = ResourceLoadSystem?.LoadResource(audioPath); + if (audioStream == null) return; + + var player = AvailableSoundPlayers.Dequeue(); + player.Stream = audioStream; + player.VolumeDb = LinearToDb(volume * VoiceVolume * MasterVolume); + player.Play(); + } + + /// + /// 播放环境音效 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + public virtual void PlayAmbient(string audioPath, float volume = 1.0f, float pitch = 1.0f) + { + if (AvailableSoundPlayers.Count == 0) return; + + var audioStream = ResourceLoadSystem?.LoadResource(audioPath); + if (audioStream == null) return; + + var player = AvailableSoundPlayers.Dequeue(); + player.Stream = audioStream; + player.VolumeDb = LinearToDb(volume * AmbientVolume * MasterVolume); + player.Play(); + } + /// /// 通过资源ID播放音效 /// @@ -272,6 +329,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager MusicPlayer.VolumeDb = LinearToDb(MusicVolume * MasterVolume); } } + + /// + /// 获取背景音乐音量 + /// + /// 音量大小,范围0-1 + public virtual float GetMusicVolume() + { + return MusicVolume; + } /// /// 设置音效音量 @@ -281,6 +347,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager { SoundVolume = volume; } + + /// + /// 获取音效音量 + /// + /// 音量大小,范围0-1 + public virtual float GetSoundVolume() + { + return SoundVolume; + } /// /// 设置主音量 @@ -296,6 +371,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager MusicPlayer.VolumeDb = LinearToDb(MusicVolume * MasterVolume); } } + + /// + /// 获取主音量 + /// + /// 音量大小,范围0-1 + public virtual float GetMasterVolume() + { + return MasterVolume; + } /// /// 设置SFX音量 @@ -305,6 +389,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager { SfxVolume = volume; } + + /// + /// 获取SFX音量 + /// + /// 音量大小,范围0-1 + public virtual float GetSfxVolume() + { + return SfxVolume; + } /// /// 设置语音音量 @@ -314,6 +407,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager { VoiceVolume = volume; } + + /// + /// 获取语音音量 + /// + /// 音量大小,范围0-1 + public virtual float GetVoiceVolume() + { + return VoiceVolume; + } /// /// 设置环境音量 @@ -323,6 +425,15 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager { AmbientVolume = volume; } + + /// + /// 获取环境音量 + /// + /// 音量大小,范围0-1 + public virtual float GetAmbientVolume() + { + return AmbientVolume; + } /// /// 检查背景音乐是否正在播放 diff --git a/GFramework.Core.Godot/system/IAudioManagerSystem.cs b/GFramework.Core.Godot/system/IAudioManagerSystem.cs index 47cf1f1..483479b 100644 --- a/GFramework.Core.Godot/system/IAudioManagerSystem.cs +++ b/GFramework.Core.Godot/system/IAudioManagerSystem.cs @@ -24,6 +24,30 @@ public interface IAudioManagerSystem : ISystem /// 音调调整 void PlaySound(string audioPath, float volume = 1.0f, float pitch = 1.0f); + /// + /// 播放特效音效 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + void PlaySfx(string audioPath, float volume = 1.0f, float pitch = 1.0f); + + /// + /// 播放语音 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + void PlayVoice(string audioPath, float volume = 1.0f, float pitch = 1.0f); + + /// + /// 播放环境音效 + /// + /// 音频文件路径 + /// 音量大小,范围0-1 + /// 音调调整 + void PlayAmbient(string audioPath, float volume = 1.0f, float pitch = 1.0f); + /// /// 停止背景音乐 /// @@ -45,18 +69,72 @@ public interface IAudioManagerSystem : ISystem /// 音量大小,范围0-1 void SetMusicVolume(float volume); + /// + /// 获取背景音乐音量 + /// + /// 音量大小,范围0-1 + float GetMusicVolume(); + /// /// 设置音效音量 /// /// 音量大小,范围0-1 void SetSoundVolume(float volume); + /// + /// 获取音效音量 + /// + /// 音量大小,范围0-1 + float GetSoundVolume(); + + /// + /// 设置特效音量 + /// + /// 音量大小,范围0-1 + void SetSfxVolume(float volume); + + /// + /// 获取特效音量 + /// + /// 音量大小,范围0-1 + float GetSfxVolume(); + + /// + /// 设置语音音量 + /// + /// 音量大小,范围0-1 + void SetVoiceVolume(float volume); + + /// + /// 获取语音音量 + /// + /// 音量大小,范围0-1 + float GetVoiceVolume(); + + /// + /// 设置环境音量 + /// + /// 音量大小,范围0-1 + void SetAmbientVolume(float volume); + + /// + /// 获取环境音量 + /// + /// 音量大小,范围0-1 + float GetAmbientVolume(); + /// /// 设置主音量 /// /// 音量大小,范围0-1 void SetMasterVolume(float volume); + /// + /// 获取主音量 + /// + /// 音量大小,范围0-1 + float GetMasterVolume(); + /// /// 检查背景音乐是否正在播放 ///