58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using UnityEngine;
|
||
using UnityEngine.Audio;
|
||
|
||
namespace BaseGames.Audio
|
||
{
|
||
/// <summary>
|
||
/// 音频全局配置 SO:区域 BGM 映射、Boss BGM 映射、特殊曲目。
|
||
/// 资产路径:Assets/ScriptableObjects/Audio/AUD_Config.asset
|
||
/// </summary>
|
||
[CreateAssetMenu(menuName = "Audio/AudioConfig")]
|
||
public class AudioConfigSO : ScriptableObject
|
||
{
|
||
[System.Serializable]
|
||
public struct ZoneBGMEntry
|
||
{
|
||
public string ZoneId;
|
||
public AudioClip BGMClip;
|
||
public float FadeDuration;
|
||
}
|
||
|
||
[System.Serializable]
|
||
public struct BossBGMEntry
|
||
{
|
||
public string BossId;
|
||
public AudioClip BGMClip;
|
||
}
|
||
|
||
[Header("区域 BGM 映射")]
|
||
public ZoneBGMEntry[] ZoneBGMs;
|
||
|
||
[Header("Boss BGM 映射")]
|
||
public BossBGMEntry[] BossBGMs;
|
||
|
||
[Header("特殊曲目")]
|
||
public AudioClip MainMenuBGM;
|
||
public AudioClip GameOverSting;
|
||
public AudioClip VictoryStingBGM;
|
||
[Min(0.1f)]
|
||
public float VictoryStingDuration = 4f;
|
||
|
||
public AudioClip GetZoneBGM(string zoneId)
|
||
{
|
||
if (ZoneBGMs == null) return null;
|
||
foreach (var e in ZoneBGMs)
|
||
if (e.ZoneId == zoneId) return e.BGMClip;
|
||
return null;
|
||
}
|
||
|
||
public AudioClip GetBossBGM(string bossId)
|
||
{
|
||
if (BossBGMs == null) return null;
|
||
foreach (var e in BossBGMs)
|
||
if (e.BossId == bossId) return e.BGMClip;
|
||
return null;
|
||
}
|
||
}
|
||
}
|