47 lines
891 B
C#
47 lines
891 B
C#
using UnityEngine;
|
|
|
|
public class CollectionManager : MonoBehaviour
|
|
{
|
|
public static CollectionManager Instance;
|
|
|
|
[Header("Star Data")]
|
|
private int _currentStars = 0;
|
|
|
|
[Header("CollectionHuds")]
|
|
[SerializeField] private StarPieceHud _starPieceHud;
|
|
|
|
public int GetStarCount => _currentStars;
|
|
void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
UpdateUI();
|
|
}
|
|
|
|
public void AddStar(int amount)
|
|
{
|
|
_currentStars += amount;
|
|
UpdateUI();
|
|
|
|
Debug.Log("Star Added: " + amount + " / Total Star: " + _currentStars);
|
|
}
|
|
|
|
void UpdateUI()
|
|
{
|
|
if(_starPieceHud != null)
|
|
{
|
|
_starPieceHud.RefreshUI();
|
|
}
|
|
}
|
|
}
|