별조각픽업
This commit is contained in:
46
Assets/02_Scripts/Managers/CollectionManager.cs
Normal file
46
Assets/02_Scripts/Managers/CollectionManager.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user