using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MenuWnd : MonoBehaviour { //视图索引 private int viewIndex = 0; public Button viewChangeBtn; public Button roadInfoBtn; public Button accidentBtn;//事故演练按钮 public Button accidentProcesBtn; public GameObject unit2DIcon; public GameObject CarGourp1; public GameObject threeDcamera; public GameObject twoDcamera; public GameObject finalCamera; public Text timerTxt; private float timer=Const.AccTime; private bool wait = true; // Start is called before the first frame update public void Init() { viewChangeBtn.onClick.AddListener(ChangeView); roadInfoBtn.onClick.AddListener(()=>{ GameRoot.Instance.infoWnd.SetRoadInfoActive(true); } ); accidentBtn.onClick.AddListener(EnterAccident); accidentProcesBtn.onClick.AddListener(() => { GameRoot.Instance.accidentWindow.gameObject.SetActive(true); }); GameRoot.Instance.pt.AddTimeTask((int t)=> { threeDcamera.SetActive(false); },1,PETimeUnit.Second,1); } public void Update() { if (timer <= 0) { wait = false; accidentBtn.interactable = true; timerTxt.gameObject.SetActive(false); } if (wait) { timer =timer- Time.deltaTime; timerTxt.text = ((int)timer).ToString()+"s"; } } /// /// 0为3D试图,1为2D视图 /// public void ChangeView() { switch (viewIndex) { case 0: viewIndex = 1; break; case 1: viewIndex = 0; break; } switch (viewIndex) { case 0: twoDcamera.SetActive(true); threeDcamera.SetActive(false); break; case 1: twoDcamera.SetActive(false); threeDcamera.SetActive(true); break; } GameRoot.Instance.infoWnd.SetColorTitleActive(); } public void EnterAccident() { CarSys.Instance.StopCreatCar(); viewChangeBtn.gameObject.SetActive(false); //视角切换 twoDcamera.SetActive(true); threeDcamera.SetActive(false); //交警图标 unit2DIcon.SetActive(true); CarGourp1.SetActive(true); roadInfoBtn.gameObject.SetActive(false); accidentBtn.gameObject.SetActive(false); accidentProcesBtn.gameObject.SetActive(true); //打开事故提示 GameRoot.Instance.infoWnd.pass1Info.SetActive(true); GameRoot.Instance.pt.AddTimeTask((int d) => { GameRoot.Instance.infoWnd.pass1Info.SetActive(false); } , 2.0, PETimeUnit.Second, 1); } }