|
|
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 GameObject CheckReplyTip;
|
|
|
public GameObject ReplyFalseTip;
|
|
|
public GameObject ReplyTrueTip;
|
|
|
public bool isReply = false;
|
|
|
public bool ReplyCheck = false;
|
|
|
|
|
|
public Text timerTxt;
|
|
|
public Text replyTxt;
|
|
|
|
|
|
public GameObject stopwall;
|
|
|
// private float timer;
|
|
|
// private bool wait = true;
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
{
|
|
|
////任务触发倒计时
|
|
|
//timer=Const.GetPassAccTime(GameRoot.Instance.PassIndex);
|
|
|
|
|
|
viewChangeBtn.onClick.AddListener(ChangeView);
|
|
|
roadInfoBtn.onClick.AddListener(()=>{ GameRoot.Instance.infoWnd.SetRoadInfoActive(true); }
|
|
|
);
|
|
|
accidentBtn.onClick.AddListener(EnterAccident);
|
|
|
accidentProcesBtn.onClick.AddListener(() => {
|
|
|
if (GameRoot.Instance.PassIndex == 1)
|
|
|
{
|
|
|
|
|
|
GameRoot.Instance.accidentWindow.gameObject.SetActive(true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GameRoot.Instance.accidentWindow2.gameObject.SetActive(true);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
GameRoot.Instance.pt.AddTimeTask((int th)=> { 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";
|
|
|
//}
|
|
|
|
|
|
if (ReplyCheck)
|
|
|
{
|
|
|
|
|
|
if (replyTxt.text != "")
|
|
|
{
|
|
|
|
|
|
if (replyTxt.text == "Y" || replyTxt.text == "Y\n")
|
|
|
{
|
|
|
|
|
|
accidentProcesBtn.interactable = true;
|
|
|
CheckReplyTip.SetActive(false);
|
|
|
ReplyTrueTip.SetActive(true);
|
|
|
GameRoot.Instance.pt.AddTimeTask((int te) => { ReplyTrueTip.SetActive(false); }, 2, PETimeUnit.Second);
|
|
|
ReplyCheck = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
accidentProcesBtn.interactable = false;
|
|
|
ReplyFalseTip.SetActive(true);
|
|
|
ReplyCheck = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 0为3D试图,1为2D视图
|
|
|
/// </summary>
|
|
|
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();
|
|
|
stopwall.SetActive(true);
|
|
|
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.viewWnd.AccStartAni();
|
|
|
GameRoot.Instance.viewWnd.cameraGroup.SetActive(true);
|
|
|
GameRoot.Instance.pt.AddTimeTask((int Accani) =>
|
|
|
{
|
|
|
//等待平台结果提示
|
|
|
ReplyCheck = true;
|
|
|
|
|
|
CheckReplyTip.SetActive(true);
|
|
|
GameRoot.Instance.viewWnd.cameraGroup.SetActive(false);
|
|
|
}, 8, PETimeUnit.Second
|
|
|
);
|
|
|
|
|
|
|
|
|
if (GameRoot.Instance.PassIndex == 2)
|
|
|
{
|
|
|
GameRoot.Instance.accidentWindow2.OpenRescueInfoWnd();
|
|
|
accidentProcesBtn.interactable = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|