You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.7 KiB
118 lines
2.7 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
public enum GameSateType
|
|
{
|
|
游戏开始 = 0,
|
|
部署阶段 = 1,
|
|
塌方巡检=2,
|
|
}
|
|
public class GameRoot : MonoSingleton<GameRoot>
|
|
{
|
|
|
|
[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<string> m_TipsQueue = new Queue<string>();
|
|
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>().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);
|
|
}
|
|
|
|
}
|