using Assets.Scenes.Ride.Scripts; using Assets.Scripts.Apis.Models; using System; using UnityEngine; using UnityEngine.UI; public class GameRoomCountDownController : PFUIPanel { public Text count; public Text endCount; private int Seconds { get; set; } public GameRoomModel GameRoom { get; set; } private Action Callback { get; set; } protected override void Awake() { base.Awake(); } public override void Show() { base.Show(); } public void Init(int seconds,Action action,bool isEnd = false) { Seconds = seconds; Callback = action; endCount.gameObject.SetActive(isEnd); } float timer = 0f; private void Update() { timer -= Time.deltaTime; while (timer < 0) { if (Seconds == 0) { Callback?.Invoke(); } if (Seconds < 0) { gameObject.SetActive(false); } else { count.text = Helper.FormatTicks(Seconds); endCount.text = Helper.FormatTicks(Seconds); } Seconds--; timer += 1f; } } }