using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AccidentWindow : MonoBehaviour { public Button ChuLiBtn; public GameObject ChuliWnd; public GameObject pocileOne; public GameObject pocileTwo; public GameObject HuoDongChe; public Button policeAction1; public Button policeAction2; public Button closeBtn; public Text stateTxt; public Text succeedTxt; public void Init() { ChuLiBtn.onClick.AddListener(OpenChuLiWnd); policeAction1.onClick.AddListener(PoliceActionOne); policeAction2.onClick.AddListener(PoliceActionTwo); closeBtn.onClick.AddListener(() => { this.gameObject.SetActive(false); }); this.gameObject.SetActive(false); } public void OpenChuLiWnd() { ChuliWnd.gameObject.SetActive(true); } public void PoliceActionTwo() { pocileTwo.gameObject.SetActive(true); pocileTwo.GetComponent().CrossFade("policecar2", 0.5f); this.gameObject.SetActive(false); ChuLiBtn.gameObject.SetActive(false); stateTxt.text = " 处理中"; ChuliWnd.SetActive(false); GameRoot.Instance.pt.AddTimeTask((int t) => { GameRoot.Instance.menuWnd.threeDcamera.SetActive(false); GameRoot.Instance.menuWnd.twoDcamera.SetActive(false); GameRoot.Instance.ClearUI(); GameRoot.Instance.menuWnd.finalCamera.SetActive(true); HuoDongChe.GetComponent().CrossFade("HuoDongChe1", 0.1f); GameOver(); }, 18.5f, PETimeUnit.Second, 1); } public void PoliceActionOne() { pocileOne.gameObject.SetActive(true); pocileOne.GetComponent().CrossFade("policecar1", 0.5f); this.gameObject.SetActive(false); ChuLiBtn.gameObject.SetActive(false); stateTxt.text = " 处理中"; ChuliWnd.SetActive(false); GameRoot.Instance.pt.AddTimeTask((int t) => { GameRoot.Instance.menuWnd.threeDcamera.SetActive(false); GameRoot.Instance.menuWnd.twoDcamera.SetActive(false); GameRoot.Instance.ClearUI(); GameRoot.Instance.menuWnd.finalCamera.SetActive(true); HuoDongChe.GetComponent().CrossFade("HuoDongChe1", 0.1f); GameOver(); }, 22f, PETimeUnit.Second, 1); } private void GameOver() { GameRoot.Instance.pt.AddTimeTask((int t) => { Time.timeScale = 0; succeedTxt.gameObject.SetActive(true); }, 6, PETimeUnit.Second); } }