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,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user