using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class CoinCounter : MonoBehaviour
{
public TextMeshProUGUI tmp;
public TextMeshProUGUI revengeSign;
public GameObject revengeSignGo;
void OnEnable()
{
SetRevengePriceVisibility(false);
UpdateCoins(PlayerPrefs.GetInt("CoinsCount", 0));
ComWrapper.onCoinAdded.AddListener(UpdateCoins);
ComWrapper.onCoinRemoved.AddListener(UpdateCoins);
SettingsManager.OnSettingsChanged.AddListener(UpdateCoins);
}
private void OnDisable()
{
ComWrapper.onCoinAdded.RemoveListener(UpdateCoins);
ComWrapper.onCoinRemoved.AddListener(UpdateCoins);
}
private void UpdateCoins() => UpdateCoins(ComWrapper.Balance);
public void UpdateCoins(int newCount)
{
string valutaName = PlayerPrefs.GetString("ValutaName", "руб.");
tmp.text = $"{newCount} {valutaName}";
}
public void SetRevengePriceVisibility(bool visibility)
{
revengeSignGo.SetActive(visibility);
int price = PlayerPrefs.GetInt("PriceRevenge", 10);
string valutaName = PlayerPrefs.GetString("ValutaName", "руб.");
revengeSign.text = $"Повторная игра:
{price} {valutaName}";
}
}