Merge pull request 'work_branch' (#5) from work_branch into main
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
8
Assets/Darkmatter/Code/Features/MainMenu.meta
Normal file
8
Assets/Darkmatter/Code/Features/MainMenu.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99f56c35c78a8df4c864137f645cb7fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Features.Mainmenu",
|
||||
"rootNamespace": "Darkmatter.Features.Mainmenu",
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:68765d262e2128e4ab49c983f3411946",
|
||||
"GUID:80ecb87cae9c44d19824e70ea7229748",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24689bdd721a690468786e8d3718a343
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Features/MainMenu/Installers.meta
Normal file
8
Assets/Darkmatter/Code/Features/MainMenu/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897e6d60e776fc648870bdd8e37d1bf0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Mainmenu
|
||||
{
|
||||
public class MainmenuFeatureModule: MonoBehaviour, IModule
|
||||
{
|
||||
[SerializeField] private MainmenuView mainmenuView;
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
if(mainmenuView!= null)
|
||||
{
|
||||
builder.RegisterEntryPoint<MainmenuPresenter>().WithParameter(mainmenuView);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11551a88f8a7aed4ea3d9b1333736a95
|
||||
8
Assets/Darkmatter/Code/Features/MainMenu/Mascot.meta
Normal file
8
Assets/Darkmatter/Code/Features/MainMenu/Mascot.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b253e003d7c03b74e8a92292c3597830
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Mainmenu
|
||||
{
|
||||
public class MainmenuPresenter : IStartable, IDisposable
|
||||
{
|
||||
private readonly MainmenuView _view;
|
||||
|
||||
public MainmenuPresenter(MainmenuView view)
|
||||
{
|
||||
_view = view;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_view.OnPlayBtnClickedEvent += OnPlayBtnClicked;
|
||||
}
|
||||
|
||||
private void OnPlayBtnClicked()
|
||||
{
|
||||
Debug.Log("Play Btn Clicked");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_view.OnPlayBtnClickedEvent -= OnPlayBtnClicked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8133519fbded9f44e8500998f6f84a9d
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.Mainmenu
|
||||
{
|
||||
public class MainmenuView : MonoBehaviour
|
||||
{
|
||||
[Header("UI Elements")]
|
||||
[SerializeField] private Button playBtn;
|
||||
[SerializeField] private ParticleSystem playBtnParticle;
|
||||
[SerializeField] private Animator playBtnAnimator;
|
||||
|
||||
[SerializeField] private SkeletonGraphic mascotSkeletonGraphic;
|
||||
|
||||
[Header("Mascot Animations")]
|
||||
[SerializeField] private string jumpAnimation = "jump";
|
||||
[SerializeField] private string idleAnimation = "idle";
|
||||
[SerializeField] private string helloAnimation = "hello";
|
||||
[SerializeField] private float helloInterval = 5f;
|
||||
|
||||
public event Action OnPlayBtnClickedEvent;
|
||||
|
||||
private CancellationTokenSource helloCts;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
playBtn.onClick.AddListener(OnPlayBtnClicked);
|
||||
PlayMascotIntro();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
helloCts?.Cancel();
|
||||
helloCts?.Dispose();
|
||||
helloCts = null;
|
||||
}
|
||||
|
||||
private void PlayMascotIntro()
|
||||
{
|
||||
var state = mascotSkeletonGraphic.AnimationState;
|
||||
state.SetAnimation(0, jumpAnimation, false);
|
||||
state.AddAnimation(0, idleAnimation, true, 0f);
|
||||
|
||||
helloCts = CancellationTokenSource.CreateLinkedTokenSource(this.GetCancellationTokenOnDestroy());
|
||||
HelloLoopAsync(helloCts.Token).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid HelloLoopAsync(CancellationToken token)
|
||||
{
|
||||
var state = mascotSkeletonGraphic.AnimationState;
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(helloInterval), cancellationToken: token);
|
||||
state.SetAnimation(0, helloAnimation, false);
|
||||
state.AddAnimation(0, idleAnimation, true, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayBtnClicked()
|
||||
{
|
||||
playBtn.interactable = false;
|
||||
playBtnAnimator.enabled = false;
|
||||
PlayBtnSequenceAsync(this.GetCancellationTokenOnDestroy()).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid PlayBtnSequenceAsync(CancellationToken token)
|
||||
{
|
||||
playBtnParticle.Play();
|
||||
await UniTask.WaitUntil(() => !playBtnParticle.IsAlive(true), cancellationToken: token);
|
||||
OnPlayBtnClickedEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2e90f858cdbce54abda9b9150c05a27
|
||||
Reference in New Issue
Block a user