Loading finalized
This commit is contained in:
8
Assets/Darkmatter/Code/Features/Coloring/Commands.meta
Normal file
8
Assets/Darkmatter/Code/Features/Coloring/Commands.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02004f7c20c0640778c41a7643c2da82
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Features/Loading/Installers.meta
Normal file
8
Assets/Darkmatter/Code/Features/Loading/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d5d2ca79d314453cba062c16dce8181
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Loading
|
||||
{
|
||||
public class LoadingFeatureModule : MonoBehaviour,IModule
|
||||
{
|
||||
[SerializeField] private LoadingScreenView loadingScreenView;
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterEntryPoint<LoadingPresenter>().WithParameter(loadingScreenView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 673a21bf7c6bb430eadece2a989d79ac
|
||||
@@ -1,85 +0,0 @@
|
||||
using PrimeTween;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.Loading
|
||||
{
|
||||
public class LoadingScreenView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Slider loadingSlider;
|
||||
[SerializeField] private TMP_Text statusText;
|
||||
[SerializeField] private float loadingSmoothTime = 10f;
|
||||
[SerializeField] private float messageHoldDuration = 2f;
|
||||
[SerializeField] private float messageFadeDuration = 0.4f;
|
||||
public float LoadingSmoothTime => loadingSmoothTime;
|
||||
|
||||
private static readonly string[] StatusLines = {
|
||||
"Blue is arguing with red...",
|
||||
"The crayons are dancing...",
|
||||
"Yellow spilled everywhere...",
|
||||
"Chasing escaped paint drops...",
|
||||
"Untying rainbow knots...",
|
||||
"Cleaning glitter explosions...",
|
||||
"The color monsters are hungry...",
|
||||
"Mixing mystery colors...",
|
||||
"Someone ate the purple paint...",
|
||||
"Teaching green to behave..."
|
||||
};
|
||||
|
||||
private Sequence _statusSequence;
|
||||
private int _statusIndex;
|
||||
|
||||
public void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
StartStatusCycle();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
StopStatusCycle();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetProgress(float progress)
|
||||
{
|
||||
if (loadingSlider != null) loadingSlider.value = progress;
|
||||
}
|
||||
|
||||
private void StartStatusCycle()
|
||||
{
|
||||
if (statusText == null || StatusLines.Length == 0) return;
|
||||
|
||||
StopStatusCycle();
|
||||
|
||||
_statusIndex = Random.Range(0, StatusLines.Length);
|
||||
statusText.text = StatusLines[_statusIndex];
|
||||
statusText.alpha = 0f;
|
||||
|
||||
_statusSequence = Sequence.Create(useUnscaledTime: true, cycles: -1)
|
||||
.Chain(Tween.Alpha(statusText, 1f, messageFadeDuration, Ease.OutQuad))
|
||||
.ChainDelay(messageHoldDuration)
|
||||
.Chain(Tween.Alpha(statusText, 0f, messageFadeDuration, Ease.InQuad))
|
||||
.ChainCallback(AdvanceStatusLine);
|
||||
}
|
||||
|
||||
private void StopStatusCycle()
|
||||
{
|
||||
if (_statusSequence.isAlive) _statusSequence.Stop();
|
||||
_statusSequence = default;
|
||||
}
|
||||
|
||||
private void AdvanceStatusLine()
|
||||
{
|
||||
if (statusText == null) return;
|
||||
_statusIndex = (_statusIndex + 1) % StatusLines.Length;
|
||||
statusText.text = StatusLines[_statusIndex];
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StopStatusCycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Darkmatter/Code/Features/Loading/UI.meta
Normal file
8
Assets/Darkmatter/Code/Features/Loading/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43e5eadd1991e4cbcb672bf0fd4dfde9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using PrimeTween;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.Loading
|
||||
{
|
||||
public class LoadingScreenView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Slider loadingSlider;
|
||||
[SerializeField] private TMP_Text statusText;
|
||||
[SerializeField] private float loadingSmoothTime = 10f;
|
||||
[SerializeField] private float dotInterval = 0.4f;
|
||||
public float LoadingSmoothTime => loadingSmoothTime;
|
||||
|
||||
private static readonly string[] StatusLines = {
|
||||
"Blue is arguing with red",
|
||||
"The crayons are dancing",
|
||||
"Yellow spilled everywhere",
|
||||
"Chasing escaped paint drops",
|
||||
"Untying rainbow knots",
|
||||
"Cleaning glitter explosions",
|
||||
"The color monsters are hungry",
|
||||
"Mixing mystery colors",
|
||||
"Someone ate the purple paint",
|
||||
"Teaching green to behave"
|
||||
};
|
||||
|
||||
private static readonly string[] DotFrames = { ".", "..", "..." };
|
||||
|
||||
private string _baseLine;
|
||||
private int _dotIndex;
|
||||
private Sequence _dotSequence;
|
||||
|
||||
public void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
if (statusText == null || StatusLines.Length == 0) return;
|
||||
|
||||
_baseLine = StatusLines[Random.Range(0, StatusLines.Length)];
|
||||
_dotIndex = 0;
|
||||
statusText.text = _baseLine + DotFrames[_dotIndex];
|
||||
|
||||
StartDotAnimation();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
StopDotAnimation();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetProgress(float progress)
|
||||
{
|
||||
if (loadingSlider != null) loadingSlider.value = progress;
|
||||
}
|
||||
|
||||
private void StartDotAnimation()
|
||||
{
|
||||
StopDotAnimation();
|
||||
_dotSequence = Sequence.Create(useUnscaledTime: true, cycles: -1)
|
||||
.ChainDelay(dotInterval)
|
||||
.ChainCallback(AdvanceDots);
|
||||
}
|
||||
|
||||
private void StopDotAnimation()
|
||||
{
|
||||
if (_dotSequence.isAlive) _dotSequence.Stop();
|
||||
_dotSequence = default;
|
||||
}
|
||||
|
||||
private void AdvanceDots()
|
||||
{
|
||||
if (statusText == null || string.IsNullOrEmpty(_baseLine)) return;
|
||||
_dotIndex = (_dotIndex + 1) % DotFrames.Length;
|
||||
statusText.text = _baseLine + DotFrames[_dotIndex];
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StopDotAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Darkmatter.Core.Data.Signals.Features.AppBoot;
|
||||
using Darkmatter.Core.Data.Signals.Features.MainMenu;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using UnityEngine;
|
||||
using VContainer.Unity;
|
||||
@@ -32,7 +33,7 @@ namespace Darkmatter.Features.Mainmenu
|
||||
|
||||
private void OnPlayBtnClicked()
|
||||
{
|
||||
Debug.Log("Play Btn Clicked");
|
||||
_eventBus.Publish(new PlayBtnClickedSignal());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
8
Assets/Darkmatter/Code/Features/MainMenuFlow.meta
Normal file
8
Assets/Darkmatter/Code/Features/MainMenuFlow.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4bb322f193284fd9b4ebb75c3916408
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Features.MainMenuFlow",
|
||||
"rootNamespace": "Darkmatter.Features.MainMenuFlow",
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:b4c9f7fbf1e144933a1797dc208ece5f",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:729fabb77852b4d3eae2417d9564dc37",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70ab456139c5746eab129dca59e89914
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Features/MainMenuFlow/Flow.meta
Normal file
8
Assets/Darkmatter/Code/Features/MainMenuFlow/Flow.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb104c5c062454ec3880d2bd33072c28
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Features.Loading;
|
||||
using Darkmatter.Core.Contracts.Services.Scenes;
|
||||
using Darkmatter.Core.Data.Signals.Features.MainMenu;
|
||||
using Darkmatter.Core.Enums.Services.Scenes;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.MainMenuFlow.Flow
|
||||
{
|
||||
public class MainMenuFlow : IAsyncStartable, IDisposable
|
||||
{
|
||||
private readonly ILoadingScreen _loadingScreen;
|
||||
private readonly ISceneService _sceneService;
|
||||
private readonly IEventBus _eventBus;
|
||||
|
||||
private IDisposable _playBtnClickedSubscription;
|
||||
|
||||
public MainMenuFlow(ILoadingScreen loadingScreen, ISceneService sceneService,IEventBus eventBus)
|
||||
{
|
||||
_loadingScreen = loadingScreen;
|
||||
_sceneService = sceneService;
|
||||
_eventBus = eventBus;
|
||||
}
|
||||
|
||||
public UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
|
||||
{
|
||||
_playBtnClickedSubscription = _eventBus.Subscribe<PlayBtnClickedSignal>(OnPlayBtnClicked);
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnPlayBtnClicked(PlayBtnClickedSignal obj)
|
||||
{
|
||||
LoadColorbookSceneAsync().Forget();
|
||||
}
|
||||
|
||||
private async UniTask LoadColorbookSceneAsync(CancellationToken ct = default)
|
||||
{
|
||||
_loadingScreen.Show();
|
||||
var progress = new Progress<float>(p => _loadingScreen.SetProgress(p * 0.5f));
|
||||
await _sceneService.LoadSceneAsync(nameof(GameScene.Colorbook), progress, ct);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_playBtnClickedSubscription?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8d9b6d57244943f8af779f3a8c58b69
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a84095e2dae4453d83dd936705b54bb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.MainMenuFlow
|
||||
{
|
||||
public class MainMenuFlowFeatureModule : MonoBehaviour, IModule
|
||||
{
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterEntryPoint<Flow.MainMenuFlow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537a5a77a85a141519e96811f4f4e0a3
|
||||
Reference in New Issue
Block a user