Files
Infratest/Assets/Code/Infrastructure/App/States/BootstrapState.cs
T

60 lines
1.9 KiB
C#

using Code.Infrastructure.Audio;
using Code.Infrastructure.Generators;
using Code.Infrastructure.UI;
using Code.Infrastructure.UI.Panels;
namespace Code.Infrastructure.App.States
{
[State(typeof(AppStates),typeof(AppStateMachineContext))]
[StateRaisingEvent]
public partial class BootstrapState : IReadyToPlayHandle, IMenuChoosePanelCreatedHandle
{
private EventBus.EventBus _eventBus;
public BootstrapState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
{
_eventBus = eventBus;
}
public override AppStates myState => AppStates.Bootstrap;
protected override void OnEnterState()
{
_eventBus.Subscribe(this);
Context.UIService.TryRemovePanel(UIPanelType.Logo);
Context.UIService.TryLoadCreatePanel(UIPanelType.DebugSceneChooser);
Context.AudioFactory.LoadAudioClips(AudioNames.UISounds);
Context.AudioService.ChangeGroupVolume(
AudioGroupType.Music,
1f,
0.5f);
}
protected override void OnExitState()
{
// Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
Context.AudioService.ChangeGroupVolume(
AudioGroupType.Music,
0,
0.5f,
() => Context.AudioService.CancelMusic(AudioNames.UISounds,0));
_eventBus.Unsubscribe(this);
}
public void OnReadyToPlay(AudioNames groupName)
{
Context.AudioService.PlayRepeatedly(AudioNames.UISounds,0, AudioGroupType.Music);
}
public void MenuChoosePanelCreated(UIPanel panel)
{
panel.gameObject.SetActive(true);
panel.Open();
}
}
}