using System.Collections; using TMPro; using UnityEngine; public class ClientGameTypingSceneController : MonoBehaviour { public static ClientGameTypingSceneController Instance; public GameObject introPanel; public GameObject playPanel; public GameObject stopPanel; public GameObject finishPanel; public TMP_Text playCountdownText; public TMP_InputField playInputField; private int playCountdownSecVal = 60; private void Awake() { Instance = this; } public void init() { processStep(1); } IEnumerator StatusCountdown() { yield return new WaitForSeconds(1f); playCountdownSecVal--; playCountdownText.text = "時間倒數 " + playCountdownSecVal.ToString() + "秒"; if (playCountdownSecVal > 0) { StartCoroutine(StatusCountdown()); } else { processStep(3); } } IEnumerator NextStep(int step, int waitSec) { yield return new WaitForSeconds(waitSec); processStep(step); } public void processStep(int step) { if (introPanel) { introPanel.SetActive(step == 1); if (step == 1) { playCountdownSecVal = 10; StartCoroutine(NextStep(2, 3)); } } if (playPanel) { playPanel.SetActive(step == 2); if (step == 2) { StartCoroutine(StatusCountdown()); } } if (stopPanel) { stopPanel.SetActive(step == 3); if (step == 3) { if (ClientMessageHandler.Instance) { ClientMessageHandler.Instance.SendMessageToServer("gameTypingResult", playInputField.text); } StartCoroutine(NextStep(4, 3)); } } if (finishPanel) { finishPanel.SetActive(step == 4); } } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } // Update is called once per frame void Update() { } }