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 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; 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; } }