sea-battle/Assets/Scripts/Settings/CountersView.cs

47 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CountersView : MonoBehaviour
{
[SerializeField] TextMeshProUGUI Prizes;
[SerializeField] TextMeshProUGUI PrizesNullable;
[SerializeField] TextMeshProUGUI Starts;
[SerializeField] TextMeshProUGUI StartsNullable;
[SerializeField] TextMeshProUGUI NumberGamesForPrize;
private string prizes;
private string prizesNullable;
private string starts;
private string startsNullable;
private string numberGamesForPrize;
public void Initialize()
{
prizes = Prizes.text;
prizesNullable = PrizesNullable.text;
starts = Starts.text;
startsNullable = StartsNullable.text;
numberGamesForPrize = NumberGamesForPrize.text;
View();
}
// Обновляем счётчики каждый раз при открытии панели
private void OnEnable()
{
if (prizes != null) // уже инициализированы через Initialize()
View();
}
public void View()
{
Prizes.text = prizes + PlayerPrefs.GetInt(PrizeSystem.key_prizesgiven, 0);
PrizesNullable.text = prizesNullable + PlayerPrefs.GetInt(PrizeSystem.key_prizesgivenNul, 0);
Starts.text = starts + PlayerPrefs.GetInt(PrizeSystem.key_starts, 0);
StartsNullable.text = startsNullable + PlayerPrefs.GetInt(PrizeSystem.key_startsNul, 0);
NumberGamesForPrize.text = numberGamesForPrize + DifficultyManager.GetChance().ToString();
}
}