61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using TMPro;
|
||
using UnityEngine;
|
||
|
||
public class AwardsInstruction : MonoBehaviour
|
||
{
|
||
[SerializeField] private TextMeshProUGUI BalanceLabel;
|
||
[SerializeField] private GameObject RevengeGO;
|
||
[SerializeField] private TextMeshProUGUI RevengeLabel;
|
||
|
||
private bool _freeplay;
|
||
private int _revengePrice;
|
||
private int _normalPrice;
|
||
private string _valuta;
|
||
public void Init()
|
||
{
|
||
_freeplay = SettingsManager.GetBool(SettingKey.Freeplay, false);
|
||
_revengePrice = SettingsManager.GetInt(SettingKey.RevengePrice, 10);
|
||
_normalPrice = SettingsManager.GetInt(SettingKey.GamePrice, 10);
|
||
_valuta = SettingsManager.GetString(SettingKey.Valuta, "руб.");
|
||
|
||
if (!_freeplay)
|
||
{
|
||
WalletManager.OnBalanceChanged += UpdateBalance;
|
||
UpdateBalance(WalletManager.Balance);
|
||
ConfigureRevengeSign();
|
||
}
|
||
RevengeGO.SetActive(!_freeplay);
|
||
BalanceLabel.gameObject.SetActive(!_freeplay);
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
WalletManager.OnBalanceChanged -= UpdateBalance;
|
||
}
|
||
|
||
private void UpdateBalance(int balance)
|
||
{
|
||
if (_freeplay) return;
|
||
string valutaPluralized = _valuta == "руб." ? PluralizeUtil.Rubles(balance) : PluralizeUtil.Tokens(balance);
|
||
BalanceLabel.text = $"Баланс: {balance} {valutaPluralized}";
|
||
}
|
||
|
||
private void ConfigureRevengeSign()
|
||
{
|
||
string priceText;
|
||
int balance = WalletManager.Balance;
|
||
string valutaPluralized = _valuta == "руб." ? PluralizeUtil.Rubles(_revengePrice) : PluralizeUtil.Tokens(_revengePrice);
|
||
//if (_revengePrice < _normalPrice)
|
||
//{
|
||
// priceText = $"<s>{_normalPrice}</s> {_revengePrice}";
|
||
//}
|
||
//else
|
||
//{
|
||
priceText = $"{_revengePrice}";
|
||
//}
|
||
RevengeLabel.text = $"{priceText} {valutaPluralized}";
|
||
}
|
||
|
||
|
||
}
|