32 lines
601 B
C#
32 lines
601 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class CoinBag : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text coinText;
|
|
[SerializeField] private GameEventListener_Int onCoinDrop;
|
|
|
|
public int currentCoin;
|
|
|
|
private void Awake()
|
|
{
|
|
onCoinDrop.Response.AddListener(ChangeAmount);
|
|
|
|
UpdateCoinText();
|
|
}
|
|
|
|
|
|
public void ChangeAmount(int amount)
|
|
{
|
|
currentCoin += amount;
|
|
UpdateCoinText();
|
|
}
|
|
|
|
private void UpdateCoinText()
|
|
{
|
|
coinText.text = currentCoin.ToString();
|
|
}
|
|
}
|