work_branch #12
@@ -2,6 +2,6 @@ using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public record struct BackBtnClickedSignal;
|
||||
public record struct ReturnToMainMenuSignal;
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:b4c9f7fbf1e144933a1797dc208ece5f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -1,26 +1,58 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Core.Contracts.Features.Loading;
|
||||
using Darkmatter.Core.Contracts.Services.Scenes;
|
||||
using Darkmatter.Core.Enums.Services.Scenes;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Colorbook.System;
|
||||
|
||||
public class ColorbookFlowController : IAsyncStartable
|
||||
public class ColorbookFlowController : IAsyncStartable, IDisposable
|
||||
{
|
||||
private readonly IDrawingCatalogController _drawingCatalog;
|
||||
private readonly ILoadingScreen _loadingScreen;
|
||||
private readonly IEventBus _eventBus;
|
||||
private readonly ISceneService _sceneService;
|
||||
|
||||
public ColorbookFlowController(IDrawingCatalogController drawingCatalog, ILoadingScreen loadingScreen)
|
||||
private IDisposable _returnToMainMenuSubscription;
|
||||
|
||||
public ColorbookFlowController(IDrawingCatalogController drawingCatalog, ILoadingScreen loadingScreen, IEventBus eventBus, ISceneService sceneService)
|
||||
{
|
||||
_drawingCatalog = drawingCatalog;
|
||||
_loadingScreen = loadingScreen;
|
||||
_eventBus = eventBus;
|
||||
_sceneService = sceneService;
|
||||
}
|
||||
|
||||
|
||||
public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
|
||||
{
|
||||
_returnToMainMenuSubscription = _eventBus.Subscribe<ReturnToMainMenuSignal>(OnReturnToMainMenu);
|
||||
_loadingScreen.SetProgress(1f);
|
||||
await _drawingCatalog.InitializeAsync(cancellation);
|
||||
_loadingScreen.Hide();
|
||||
}
|
||||
|
||||
private void OnReturnToMainMenu(ReturnToMainMenuSignal signal)
|
||||
{
|
||||
LoadMainMenuSceneAsync().Forget(UnityEngine.Debug.LogException);
|
||||
}
|
||||
|
||||
private async UniTask LoadMainMenuSceneAsync(CancellationToken ct = default)
|
||||
{
|
||||
_loadingScreen.Show();
|
||||
var progress = new Progress<float>(p => _loadingScreen.SetProgress(p * 0.5f));
|
||||
await _sceneService.LoadSceneAsync(nameof(GameScene.MainMenu), progress, ct);
|
||||
var mappedProgress = new Progress<float>(p => _loadingScreen.SetProgress(0.5f + p * 0.25f));
|
||||
await _sceneService.UnloadSceneAsync(nameof(GameScene.Colorbook), mappedProgress, ct);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_returnToMainMenuSubscription?.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace Darkmatter.Features.DrawingCatalog
|
||||
|
||||
private void OnBackBtnClicked()
|
||||
{
|
||||
_eventBus.Publish(new BackBtnClickedSignal());
|
||||
_eventBus.Publish(new ReturnToMainMenuSignal());
|
||||
Debug.Log("Back button clicked in Drawing Catalog");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Darkmatter.Features.MainMenuFlow.Flow
|
||||
public UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
|
||||
{
|
||||
_playBtnClickedSubscription = _eventBus.Subscribe<PlayBtnClickedSignal>(OnPlayBtnClicked);
|
||||
_loadingScreen.SetProgress(1f);
|
||||
_loadingScreen.Hide();
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user