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.

115 lines
2.9 KiB

3 years ago
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;
3 years ago
public GameObject threeDcamera;
public GameObject twoDcamera;
public GameObject finalCamera;
public Text timerTxt;
3 years ago
private float timer=Const.AccTime;
private bool wait = true;
3 years ago
// Start is called before the first frame update
3 years ago
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);
});
3 years ago
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";
}
3 years ago
}
/// <summary>
/// 0为3D试图1为2D视图
/// </summary>
3 years ago
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;
3 years ago
}
GameRoot.Instance.infoWnd.SetColorTitleActive();
3 years ago
}
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);
}
3 years ago
}