Rhytm minigame base
This commit is contained in:
1 parent
258900d1d6
commit
329cc98ade
7696 files changed
+238891
-619017
No files matched your search
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class BeatLine : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform startPosition;
|
||||
[SerializeField] private Transform spotPosition;
|
||||
|
||||
public Vector3 StartPosition => startPosition.position;
|
||||
public Vector3 SpotPosition => spotPosition.position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5b224e8ccea4322bbe71c479a72582f
|
||||
timeCreated: 1794690076
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class BeatLineZone : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d93103cfed541bd9580655c518a2496
|
||||
timeCreated: 1794778337
|
||||
@@ -0,0 +1,26 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class MusicMinigameComboText : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text comboText;
|
||||
|
||||
[SerializeField] private float shakeStrength;
|
||||
[SerializeField] private float shakeDuration;
|
||||
|
||||
public async UniTaskVoid SetComboText(int combo)
|
||||
{
|
||||
LMotion.Shake
|
||||
.Create(1, shakeStrength, shakeDuration)
|
||||
.BindToLocalScaleXYZ(comboText.transform);
|
||||
|
||||
// StringBuilder
|
||||
comboText.SetText('x' + combo.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5f82f4d138540fdb4a8e050e53a5924
|
||||
timeCreated: 1794695037
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class MusicMinigameEnemyHealth : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image health;
|
||||
|
||||
public void SetEnemyHealth(float healthPercent)
|
||||
{
|
||||
health.fillAmount = healthPercent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5079a8f7043e457490e20a72a13926a5
|
||||
timeCreated: 1794694475
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Alchemy.Inspector;
|
||||
using Code.Infrastructure.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class MusicMinigamePanel : UIPanel
|
||||
{
|
||||
[TabGroup("OpenClose")]
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
[TabGroup("OpenClose")]
|
||||
[SerializeField] private float leadTime;
|
||||
[TabGroup("OpenClose")]
|
||||
[SerializeField] private float starterScale;
|
||||
|
||||
[TabGroup("SubElements")]
|
||||
[SerializeField] private BeatLine[] beatLines;
|
||||
[TabGroup("SubElements")]
|
||||
[SerializeField] private MusicMinigamePlayerHealth playerHealth;
|
||||
[TabGroup("SubElements")]
|
||||
[SerializeField] private MusicMinigameEnemyHealth enemyHealth;
|
||||
[TabGroup("SubElements")]
|
||||
[SerializeField] private MusicMinigameComboText comboText;
|
||||
[TabGroup("SubElements")]
|
||||
[SerializeField] private RectTransform beatLineZone;
|
||||
|
||||
public ReadOnlyArray<BeatLine> BeatLines { get; private set; }
|
||||
public MusicMinigamePlayerHealth PlayerHealth => playerHealth;
|
||||
public MusicMinigameEnemyHealth EnemyHealth => enemyHealth;
|
||||
public MusicMinigameComboText MusicMinigameComboText => comboText;
|
||||
public RectTransform BeatLineZone => beatLineZone;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
BeatLines = beatLines;
|
||||
}
|
||||
|
||||
public override async UniTask Open(CancellationToken cts = default)
|
||||
{
|
||||
var canvasGroupMotion = LMotion
|
||||
.Create(0, 1f, leadTime)
|
||||
.BindToAlpha(canvasGroup);
|
||||
|
||||
var scale = LMotion
|
||||
.Create(starterScale, 1f, leadTime)
|
||||
.WithEase(Ease.InBounce)
|
||||
.BindToLocalScaleXYZ(transform);
|
||||
|
||||
await UniTask.WhenAll(
|
||||
canvasGroupMotion.ToUniTask(cts),
|
||||
scale.ToUniTask(cts));
|
||||
}
|
||||
|
||||
public override async UniTask Close(CancellationToken cts = default)
|
||||
{
|
||||
var canvasGroupMotion = LMotion
|
||||
.Create(1f, 0, leadTime)
|
||||
.BindToAlpha(canvasGroup);
|
||||
|
||||
var scale = LMotion
|
||||
.Create(1f, starterScale, leadTime)
|
||||
.WithEase(Ease.InBounce)
|
||||
.BindToLocalScaleXYZ(transform);
|
||||
|
||||
await UniTask.WhenAll(
|
||||
canvasGroupMotion.ToUniTask(cts),
|
||||
scale.ToUniTask(cts));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 186e32a47b28436aa814d067cee27ad5
|
||||
timeCreated: 1794689064
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Game.Minigames.MusicGame.UI
|
||||
{
|
||||
public class MusicMinigamePlayerHealth : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject heartPrefab;
|
||||
|
||||
private List<GameObject> _hearts = new();
|
||||
|
||||
// sbe
|
||||
public void SetHealth(int count)
|
||||
{
|
||||
if (_hearts.Count < count)
|
||||
for (; count > 0; count--)
|
||||
_hearts.Add(Instantiate(heartPrefab, transform));
|
||||
else if (count >= 0)
|
||||
{
|
||||
for (var toDelete = _hearts.Count - count; toDelete > 0; toDelete--)
|
||||
{
|
||||
Destroy(_hearts[toDelete - 1]);
|
||||
_hearts.RemoveAt(toDelete - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DecreaseHealth()
|
||||
{
|
||||
if (_hearts.Count <= 0) return;
|
||||
|
||||
Destroy(_hearts[0]);
|
||||
_hearts.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a7df6486b9b42529f373f1a54a58f52
|
||||
timeCreated: 1794690928
|
||||
Reference in new issue
Block a user