72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using Code.Debug;
|
|
using Code.Infrastructure.Audio;
|
|
using Code.Infrastructure.Generators;
|
|
using Code.Infrastructure.Loadings;
|
|
using Code.Infrastructure.SceneLoader;
|
|
using Code.Infrastructure.UI;
|
|
using Code.Infrastructure.UI.Panels;
|
|
using Reflex.Core;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace Code.Infrastructure.App.States
|
|
{
|
|
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
|
[StateRaisingEvent]
|
|
public partial class MainMenuState : IUIPanelLoaded, IReadyToPlayHandle, IOnMainMenuSceneLoadedHandler
|
|
{
|
|
public MainMenuState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
|
|
{
|
|
}
|
|
|
|
public override AppStates myState => AppStates.MainMenu;
|
|
private Loading _loading;
|
|
protected override void OnEnterState()
|
|
{
|
|
EventBus.Subscribe(this);
|
|
|
|
_loading = new Loading(2, LoadComplete);
|
|
|
|
Context.UIService.TryLoadPanel(UIPanelType.DebugSceneChooser);
|
|
// Context.AudioFactory.LoadAudioClips(AudioNames.UISounds);
|
|
Context.SceneLoader.LoadSceneAsync(SceneId.MainMenu, LoadSceneMode.Single).Forget();
|
|
Context.AudioService.PlayRepeatedly(AudioNames.UISounds,0);
|
|
}
|
|
|
|
protected override void OnExitState()
|
|
{
|
|
// Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
|
|
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
|
|
EventBus.Unsubscribe(this);
|
|
}
|
|
|
|
public void UILoaded(UIPanelType uiPanelType)
|
|
{
|
|
if (uiPanelType != UIPanelType.DebugSceneChooser) return;
|
|
|
|
Context.UIService.OpenPanel(uiPanelType);
|
|
_loading.DoProgress();
|
|
}
|
|
|
|
private void LoadComplete()
|
|
{
|
|
Context.UIService.OpenPanel(UIPanelType.DebugSceneChooser);
|
|
Context.UIService.ClosePanel(UIPanelType.Loading);
|
|
}
|
|
|
|
public void OnReadyToPlay(AudioNames groupName)
|
|
{
|
|
_loading.DoProgress();
|
|
Context.AudioService.PlayRepeatedly(AudioNames.UISounds,0);
|
|
}
|
|
|
|
public void OnMainMenuSceneLoaded()
|
|
{
|
|
_loading.DoProgress();
|
|
}
|
|
|
|
public void OnMainMenuSceneInitialized(Container container)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |