using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public enum GameSateType { 游戏开始 = 0, 部署阶段 = 1, 塌方巡检=2, } public class GameRoot : MonoSingleton { [Header("Manager")] public DriveManager driveManager; public CameraManager cameraManager; [Header("Window")] public GameObject StartWnd; public MenuWindow menuWindow; public InfoWindow infoWindow; public SceneSlectedWnd sceneSlectedWnd; public GameModeWindow gameModeWindow; [Header("提示队列")] public Animator tipAni; private Queue m_TipsQueue = new Queue(); private bool isTipsShow = false; [Header("系统时间")] public Text month; public Text day; public Text hour; public Text min; [Header("游戏状态机")] public Animator StateAnimator; private string GameStateParameters = "currentStateID"; public Text GameStateTxt; protected override void Awake() { base.Awake(); driveManager.Init(); cameraManager.Init(); menuWindow.Init(); infoWindow.Init(); sceneSlectedWnd.Init(); gameModeWindow.Init(); } private void Update() { CheckTipQueue(); UpdateSysTime(); } private void UpdateSysTime() { month.text = System.DateTime.Now.Month.ToString(); day.text = System.DateTime.Now.Day.ToString(); hour.text = System.DateTime.Now.Hour.ToString(); min.text = System.DateTime.Now.Minute.ToString(); } private void CheckTipQueue() { if (m_TipsQueue.Count == 0) return; if (m_TipsQueue.Count > 0 && isTipsShow == false) { tipAni.GetComponentInChildren().text = m_TipsQueue.Dequeue(); isTipsShow = true; tipAni.gameObject.SetActive(true); tipAni.CrossFade("tip", 0.1f); StartTimeAction(1.3f, () => { tipAni.gameObject.SetActive(false); isTipsShow = false; }); } } public void AddTipQueue(string str) { m_TipsQueue.Enqueue(str); } public void StartTimeAction(float sec, Action action) { StartCoroutine(TimeAction(sec, action)); } IEnumerator TimeAction(float sec, Action action) { yield return new WaitForSeconds(sec); action?.Invoke(); } public void SetGameState(GameSateType gameSate) { int id = ((int)gameSate); StateAnimator.SetInteger(GameStateParameters, id); } public void SetGameState(int StateId) { StateAnimator.SetInteger(GameStateParameters, StateId); } }