123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using UnityEngine;
- using UnityEngine.UI;
- [System.Serializable]
- public enum YJType {
- YELLOW,
- ORANGE,
- RED
- }
- public class XHDDLayer : YZTRootLayer
- {
- public RectTransform qxhddContent;
- public RectTransform xhddContent;
- public Button enterBtn;
- public Button exitBtn;
- public Button playBtn;
- public List<Text> threeStepBtns = new List<Text>();
- public Dropdown yjDropdown;
- public Button[] yjButtons;
- public YJType yJType;
- public string[,] allYAContent = new string[3, 3];
- bool playing = false;
- // Start is called before the first frame update
- void Start()
- {
- InitYAContent();
- InitButton();
- }
- private void OnEnable()
- {
- CameraManager.SwitchCamera(0);
- StaticLod.instance.OnFoucusStatic(1);
- }
- void InitYAContent() {
- allYAContent[0, 0] = "当预报洪水将达到或超过蓄滞洪区启用标准时(套口进洪闸的设防水位为32m),发布黄色预警,做好运用准备。";
- allYAContent[0, 1] = "分洪前线指挥部及其下设七个责任组责任人和成员迅速进入运用准备状态,服从前指的统一调度。";
- allYAContent[0, 2] = "分蓄洪区内各个乡镇、村组确定1名领导专门负责承担警报发布和传递任务。警报一经发布,各项避洪工作必须迅速及时,不得有误。";
- allYAContent[1, 0] = "当需要区内人员转移时,发布橙色预警,开始实施分蓄洪区内居民转移、清场等工作。";
- allYAContent[1, 1] = "人员转移时机根据荆江河段及城陵矶附近地区实时水情、防洪工程情况和区内人员转移所需时间等确定。";
- allYAContent[1, 2] = "采取电视、广播、电话、传真、汽笛、敲锣、挂旗、报警器、鸣枪或挨户通知等一切可能的形式迅速向分洪区传播分洪转移命令。";
- allYAContent[2, 0] = "当决定启用蓄滞洪区时,发布红色警报。";
- allYAContent[2, 1] = "开启套口进洪闸或实施上车湾口门爆破,开始分蓄洪。";
- allYAContent[2, 2] = "红色警报期持续至具备返迁条件时为止。";
- }
- void InitButton() {
- enterBtn.onClick.AddListener(() =>
- {
- qxhddContent.gameObject.SetActive(false);
- xhddContent.gameObject.SetActive(true);
- });
- exitBtn.onClick.AddListener(() =>
- {
- qxhddContent.gameObject.SetActive(true);
- xhddContent.gameObject.SetActive(false);
- playBtn.interactable = true;
- playing = false;
- AllRestore();
- });
- for (int i = 0; i < yjButtons.Length; i++) {
- int temp = i;
- yjButtons[i].onClick.AddListener(() =>
- {
- if (!playing) {
- ClearAllText();
- }
- for (int j = 0; j < yjButtons.Length; j++) {
- yjButtons[j].GetComponent<CanvasGroup>().alpha = 0.2f;
-
- }
- yjButtons[temp].GetComponent<CanvasGroup>().alpha = 1f;
- yJType = (YJType)temp;
- yjDropdown.value = temp;
- });
-
- }
- playBtn.onClick.AddListener(() =>
- {
- ClearAllText();
- playing = true;
- playBtn.interactable = false;
- ControlYJ();
- });
- }
- void AllRestore() {
- TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;
- TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);
- Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;
- material.SetFloat("_ClipLength", 1);
- }
- void ClearAllText() {
- for (int i = 0; i < threeStepBtns.Count; i++) {
- threeStepBtns[i].text = "";
- }
- }
- async void ControlYJ() {
- switch (yJType) {
- case YJType.YELLOW:
- TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;
- threeStepBtns[0].text = allYAContent[(int)yJType, 0];
- await Task.Delay(1000);
- if (!playing) {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird1");
- await Task.Delay(2000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- TimeLineControl.instance.transform.GetChild(1).GetChild(1).DOLocalMove(new Vector3(0, 0, 31.2f), 12.0f);
- await Task.Delay(11000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- threeStepBtns[1].text = allYAContent[(int)yJType, 1];
- StaticLod.instance.OnFoucusStatic("Bird2");
- await Task.Delay(3000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- threeStepBtns[2].text = allYAContent[(int)yJType, 2];
- playBtn.interactable = true;
- break;
- case YJType.ORANGE:
- TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);
- TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);
- threeStepBtns[0].text = allYAContent[(int)yJType, 0];
- await Task.Delay(1000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird2");
- await Task.Delay(2000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(true);
- await Task.Delay(8000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- threeStepBtns[1].text = allYAContent[(int)yJType, 1];
- StaticLod.instance.OnFoucusStatic("Bird3");
- await Task.Delay(3000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- threeStepBtns[2].text = allYAContent[(int)yJType, 2];
- playBtn.interactable = true;
- break;
- case YJType.RED:
- Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;
- material.SetFloat("_ClipLength", 1);
- TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);
- TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(false);
- threeStepBtns[0].text = allYAContent[(int)yJType, 0];
- await Task.Delay(1000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird2");
- await Task.Delay(3000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird4");
- ActionInstance._Instance.ModelAni_On?.Invoke();
- await Task.Delay(1200);
- TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(true);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- await Task.Delay(500);
-
- material.SetFloat("_ClipLength", 0.981f);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- threeStepBtns[1].text = allYAContent[(int)yJType, 1];
- await Task.Delay(2000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird5");
- DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.881f, 4f);
- await Task.Delay(5000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
- StaticLod.instance.OnFoucusStatic("Bird3");
- DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.1f, 6f);
- await Task.Delay(6000);
- if (!playing)
- {
- playBtn.interactable = true;
- return;
- }
-
- threeStepBtns[2].text = allYAContent[(int)yJType, 2];
- playBtn.interactable = true;
- break;
- }
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- }
|