55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class MovesAndTimeCounter : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField] TextMeshProUGUI movesLabel;
|
|
[SerializeField] string movesPrefix = "Ходы: ";
|
|
|
|
[SerializeField] TextMeshProUGUI timeLabel;
|
|
[SerializeField] string timePrefix = "Время: ";
|
|
|
|
[SerializeField] int digitsAfterComma = 2;
|
|
|
|
private bool visible = false;
|
|
private GameManager gm;
|
|
public void SetVisibility(bool visible)
|
|
{
|
|
this.visible = visible;
|
|
|
|
movesLabel.enabled = visible;
|
|
timeLabel.enabled = visible;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
SetVisibility(false);
|
|
gm = GameManager.instance;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (!visible) return;
|
|
|
|
UpdateTime();
|
|
UpdateMoves();
|
|
|
|
}
|
|
|
|
private void UpdateTime()
|
|
{
|
|
float time = gm.vsBotThinkTime;
|
|
time = (int)(time*Mathf.Pow(10, digitsAfterComma));
|
|
time = time / Mathf.Pow(10, digitsAfterComma);
|
|
timeLabel.text = timePrefix + time;
|
|
}
|
|
private void UpdateMoves()
|
|
{
|
|
movesLabel.text = movesPrefix + gm.vsBotMoves;
|
|
}
|
|
|
|
}
|