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

61 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class MovesAndTimeCounter : MonoBehaviour
{
[SerializeField] TextMeshProUGUI movesLabel;
[SerializeField] string movesPrefix = "Ходы: ";
[SerializeField] TextMeshProUGUI timeLabel;
[SerializeField] string timePrefix = "Время: ";
[SerializeField] List<Graphic> graphicsToVisibility;
[SerializeField] int digitsAfterComma = 2;
private bool visible = false;
private GameManager gm;
public void SetVisibility(bool visible)
{
this.visible = visible;
foreach (Graphic g in graphicsToVisibility)
{
g.enabled = visible;
}
}
private void Start()
{
SetVisibility(false);
gm = GameManager.instance;
}
void Update()
{
if (!visible) return;
UpdateTime();
UpdateMoves();
}
private void UpdateTime()
{
float time = gm.vsBotThinkTime;
timeLabel.text = $"{timePrefix}{time.ToString($"F{digitsAfterComma}")}";
}
private void UpdateMoves()
{
movesLabel.text = movesPrefix + gm.vsBotMoves;
}
}