chip-gameV3/Assets/Scripts/Menu/FastCheckCounters.cs
sega 8a6d23b77d Реорг Scripts
Разделено на 4 модуля
- Menu
- Gameplay
- Settings
- Common
2026-07-15 10:49:55 +03:00

64 lines
1.8 KiB
C#

using PrizeSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FastCheckCounters : MonoBehaviour
{
string PRIZE_BASE = "Счетчик призов ";
string STARTS_BASE = "Внесено монет ";
string NULLABLE = "(обнуляемый)";
string UNNULLABLE = "(глобальный)";
public TextMeshProUGUI starts, startsNul, prize, prizeNul;
public Image timerImage;
public float timeToDisable = 3;
Coroutine coroutine;
private void OnEnable()
{
RefreshUI();
timeToDisable = 3;
coroutine = StartCoroutine(disabling());
}
private void OnDisable()
{
if (coroutine != null) StopCoroutine(coroutine);
}
private void Update()
{
bool keepCondition = In.GetButton(ButtonPinMapping.startOnePlayer) && In.GetButton(ButtonPinMapping.startTwoPlayers);
if (keepCondition)
{
timeToDisable = Math.Clamp(timeToDisable + Time.deltaTime * 2, 0, 3);
}
}
void RefreshUI()
{
starts.text = STARTS_BASE + UNNULLABLE + ": " + PlayerPrefs.GetInt(PrizeSystemManager.key_cash);
startsNul.text = STARTS_BASE + NULLABLE + ": " + PlayerPrefs.GetInt(PrizeSystemManager.key_cashNul);
prize.text = PRIZE_BASE + UNNULLABLE + ": " + PlayerPrefs.GetInt(PrizeSystemManager.key_prizesgiven);
prizeNul.text = PRIZE_BASE + NULLABLE + ": " + PlayerPrefs.GetInt(PrizeSystemManager.key_prizesgivenNul);
}
IEnumerator disabling()
{
while (timeToDisable > 0)
{
timeToDisable -= Time.deltaTime;
timerImage.fillAmount = timeToDisable / 3;
yield return null;
}
gameObject.SetActive(false);
}
}