44 lines
871 B
C#
44 lines
871 B
C#
![]() |
using UnityEngine;
|
||
|
using TMPro;
|
||
|
|
||
|
public class Skywalker_BlueberryManager : MonoBehaviour
|
||
|
{
|
||
|
public static Skywalker_BlueberryManager Instance;
|
||
|
|
||
|
[Header("UI Reference")]
|
||
|
public TextMeshProUGUI blueberryText;
|
||
|
|
||
|
private int blueberryCount = 0;
|
||
|
|
||
|
void Awake()
|
||
|
{
|
||
|
if (Instance == null) Instance = this;
|
||
|
else Destroy(gameObject);
|
||
|
|
||
|
UpdateUI();
|
||
|
}
|
||
|
|
||
|
public void AddBlueberry(int amount)
|
||
|
{
|
||
|
blueberryCount += amount;
|
||
|
UpdateUI();
|
||
|
}
|
||
|
|
||
|
public bool UseBlueberry()
|
||
|
{
|
||
|
if (blueberryCount > 0)
|
||
|
{
|
||
|
blueberryCount--;
|
||
|
UpdateUI();
|
||
|
return true; // success
|
||
|
}
|
||
|
return false; // no blueberries left
|
||
|
}
|
||
|
|
||
|
private void UpdateUI()
|
||
|
{
|
||
|
if (blueberryText != null)
|
||
|
blueberryText.text = $"Blueberries: {blueberryCount}";
|
||
|
}
|
||
|
}
|