Scriptum/Assets/Scripts/REFACTORING/Application/AccountBalance/PanelCashController.cs

47 lines
1018 B
C#
Raw Permalink Normal View History

2022-12-24 15:14:41 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
class PanelCashController : MonoBehaviour
{
[Header("Current Value")]
public int AccountBalanceValue;
[Header("Account Balance")]
[SerializeField] public TextMeshProUGUI displayedValue;
public void Start()
{
// Get current remembered value
var balanceManager = AccountBalanceManager.Instance;
if (balanceManager == null)
throw new NullReferenceException("AccountBalanceManager not found!!!");
RefreshPanel(balanceManager.Gold);
DisplayePlayerAccountBalance();
}
// synch status after selling, buying item
public void RefreshPanel(int gold)
{
AccountBalanceValue = gold;
DisplayePlayerAccountBalance();
}
public void DisplayePlayerAccountBalance()
{
displayedValue.text = $"{AccountBalanceValue}";
}
}