Merge branch 'develop' into 7.3春优化
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
Bar,
|
||||
Dream,
|
||||
MainMenu,
|
||||
Empty
|
||||
Empty,
|
||||
PauseMenu
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.SaveSystem;
|
||||
using AibisDream.UI;
|
||||
using FMOD;
|
||||
using FMOD.Studio;
|
||||
using FMODUnity;
|
||||
@@ -16,6 +18,7 @@ namespace AibisDream.Kit
|
||||
public class AudioManager : Singleton<AudioManager>
|
||||
{
|
||||
private const string AmbStateName = "scene";
|
||||
private const string MainMenuStageParamName = "mainMenuStage";
|
||||
|
||||
public EventReference ambEvent;
|
||||
|
||||
@@ -28,6 +31,10 @@ namespace AibisDream.Kit
|
||||
|
||||
[Tooltip("Maximum volume in dB when slider is at 1")]
|
||||
[SerializeField] private float maxDecibels = 0f;
|
||||
|
||||
[Header("Terminal UI")]
|
||||
[SerializeField] private string terminalHoverSfx = "event:/ActionFB/menu_hover";
|
||||
[SerializeField] private string terminalClickSfx = "event:/ActionFB/menu_click";
|
||||
|
||||
#region Event实例
|
||||
|
||||
@@ -42,6 +49,9 @@ namespace AibisDream.Kit
|
||||
|
||||
private List<IUnRegister> _removeTrigger = new();
|
||||
private AmbState _currentAmbState = AmbState.Main;
|
||||
private AmbState? _ambStateBeforePauseMenu;
|
||||
|
||||
public AmbState CurrentAmbState => _currentAmbState;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -65,7 +75,16 @@ namespace AibisDream.Kit
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register<EventEnum, FixSceneMode>(EventEnum.FixSceneModeChanged, OnFixSceneModeChange));
|
||||
// 主菜单 / 退出局内
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register(GameLoopEnum.AppStart, OnAppStart));
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register(GameLoopEnum.GameStart, OnGameStart));
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, OnGameQuit));
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register<TerminalUIEvent, TerminalMainMenuPhase>(
|
||||
TerminalUIEvent.MainMenuPhase, OnMainMenuPhase));
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register(TerminalUIEvent.PauseMenuAmbEnter, OnPauseMenuAmbEnter));
|
||||
_removeTrigger.Add(EnumEventSystem.Global.Register<TerminalUIEvent, bool>(
|
||||
TerminalUIEvent.PauseMenuAmbExit, OnPauseMenuAmbExit));
|
||||
|
||||
SingleCastEventSystem.Global.Register<TerminalUIAudioEnum>(TerminalUIAudioEnum.Hover, OnTerminalUIHover);
|
||||
SingleCastEventSystem.Global.Register<TerminalUIAudioEnum>(TerminalUIAudioEnum.Click, OnTerminalUIClick);
|
||||
}
|
||||
|
||||
public override void OnSingletonDestroy()
|
||||
@@ -80,13 +99,30 @@ namespace AibisDream.Kit
|
||||
trigger.UnRegister();
|
||||
}
|
||||
_removeTrigger.Clear();
|
||||
|
||||
SingleCastEventSystem.Global.Unregister(TerminalUIAudioEnum.Hover);
|
||||
SingleCastEventSystem.Global.Unregister(TerminalUIAudioEnum.Click);
|
||||
}
|
||||
|
||||
private void OnTerminalUIHover()
|
||||
{
|
||||
PlaySfx(terminalHoverSfx);
|
||||
}
|
||||
|
||||
private void OnTerminalUIClick()
|
||||
{
|
||||
PlaySfx(terminalClickSfx);
|
||||
}
|
||||
|
||||
public AudioSnapshotDto CaptureSnapshot()
|
||||
{
|
||||
var ambState = _currentAmbState == AmbState.PauseMenu && _ambStateBeforePauseMenu.HasValue
|
||||
? _ambStateBeforePauseMenu.Value
|
||||
: _currentAmbState;
|
||||
|
||||
var dto = new AudioSnapshotDto
|
||||
{
|
||||
ambState = _currentAmbState.ToString()
|
||||
ambState = ambState.ToString()
|
||||
};
|
||||
|
||||
foreach (var pair in _musicDict)
|
||||
@@ -181,16 +217,57 @@ namespace AibisDream.Kit
|
||||
RuntimeManager.StudioSystem.setParameterByName(AmbStateName, (float)state);
|
||||
}
|
||||
|
||||
private void OnPauseMenuAmbEnter()
|
||||
{
|
||||
if (_currentAmbState == AmbState.PauseMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ambStateBeforePauseMenu = _currentAmbState;
|
||||
ChangeAmb(AmbState.PauseMenu);
|
||||
}
|
||||
|
||||
private void OnPauseMenuAmbExit(bool restorePrevious)
|
||||
{
|
||||
if (!_ambStateBeforePauseMenu.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (restorePrevious)
|
||||
{
|
||||
ChangeAmb(_ambStateBeforePauseMenu.Value);
|
||||
}
|
||||
|
||||
_ambStateBeforePauseMenu = null;
|
||||
}
|
||||
|
||||
public void SetGlobalParam(string paramName, float value)
|
||||
{
|
||||
RuntimeManager.StudioSystem.setParameterByName(paramName, value);
|
||||
}
|
||||
|
||||
public void SetMainMenuStage(int stage)
|
||||
{
|
||||
SetGlobalParam(MainMenuStageParamName, stage);
|
||||
}
|
||||
|
||||
private void OnAppStart()
|
||||
{
|
||||
ChangeAmb(menuAmbState);
|
||||
}
|
||||
|
||||
private void OnMainMenuPhase(TerminalMainMenuPhase phase)
|
||||
{
|
||||
SetMainMenuStage((int)phase);
|
||||
}
|
||||
|
||||
private void OnGameStart()
|
||||
{
|
||||
SetMainMenuStage(3);
|
||||
}
|
||||
|
||||
private void OnSceneLoad(string loadingScene)
|
||||
{
|
||||
// 场景加载时切换AMB
|
||||
|
||||
Reference in New Issue
Block a user