using System.Collections; using System.Collections.Generic; using UnityEngine; using Cinemachine; using UnityEngine.SceneManagement; using UnityEngine.UI; using DG.Tweening; public class Canvas : MonoBehaviour { int questionAnswer=-1; public GameObject mask; public GameObject tip; public GameObject toolBag; public GameObject errorTip; public GameObject step1_1; public GameObject step1_2; public GameObject step2_1; public GameObject moveTip; public GameObject person1; public GameObject person2; private void Awake() { } private void OnEnable() { } private void Start() { EventManager.Instance.register("StartTip", StartTip); EventManager.Instance.register("Step1_1", Step1_1); EventManager.Instance.register("PanDuanSafe", SafeUIChange); EventManager.Instance.register("SafeOperate", SafeOperate); } void StartTip(params object[] args) { tip.SetActive(true); } void Step1_1(params object[] args) { tip.SetActive(false); toolBag.SetActive(true); step1_1.SetActive(true); } public void Question(int value) { questionAnswer = value; } public void SunbmitOne() { if (questionAnswer==0) { Invoke("wait", 0.5f); } else { errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("当前操作有误,请重试"); } } void wait() { toolBag.SetActive(false); person1.SetActive(false); step1_2.SetActive(true); } public void FinishOperate() { if (GameObject.FindGameObjectsWithTag("ZAW").Length == 0) { GameObject obj = Instantiate(Resources.Load("operate"),GameObject.FindWithTag("Grid").transform); obj.GetComponent().str = "2-清理周边环境"; step1_2.SetActive(false); errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("恭喜通关",60); EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true); } else { errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("当前环境还处于危险状态,请继续重试"); } } void SafeUIChange(params object[] data) { if ((bool)data[0]) { GameObject obj = Instantiate(Resources.Load("operate"), GameObject.FindWithTag("Grid").transform); obj.GetComponent().str = "1-确认现场环境安全"; if ((bool)data[1]) { errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("恭喜通关",60); EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true); } else { step1_2.GetComponent().SafeFinish(); } } else { errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("当前环境判断错误,请重新判断"); } } void SafeOperate(params object[] data) { if ((int)data[0] == 0) { mask.SetActive(true); mask.GetComponent().DOColor(new Color(0, 0, 0, 1), 1); errorTip.SetActive(true); errorTip.GetComponentInChildren().InitThis("正在转移"); Invoke("CloseMask", 3); step1_2.SetActive(false); } else if ((int)data[0] == 1) { step1_2.GetComponent().Remove(); } } void CloseMask() { mask.GetComponent().DOColor(new Color(0, 0, 0, 0), 1); mask.SetActive(false); } }