XHDDLayer.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. using DG.Tweening;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. [System.Serializable]
  8. public enum YJType {
  9. YELLOW,
  10. ORANGE,
  11. RED
  12. }
  13. public class XHDDLayer : YZTRootLayer
  14. {
  15. public RectTransform qxhddContent;
  16. public RectTransform xhddContent;
  17. public Button enterBtn;
  18. public Button exitBtn;
  19. public Button playBtn;
  20. public List<Text> threeStepBtns = new List<Text>();
  21. public Dropdown yjDropdown;
  22. public Button[] yjButtons;
  23. public YJType yJType;
  24. public string[,] allYAContent = new string[3, 3];
  25. bool playing = false;
  26. // Start is called before the first frame update
  27. void Start()
  28. {
  29. InitYAContent();
  30. InitButton();
  31. }
  32. private void OnEnable()
  33. {
  34. CameraManager.SwitchCamera(0);
  35. StaticLod.instance.OnFoucusStatic(1);
  36. }
  37. void InitYAContent() {
  38. allYAContent[0, 0] = "当预报洪水将达到或超过蓄滞洪区启用标准时(套口进洪闸的设防水位为32m),发布黄色预警,做好运用准备。";
  39. allYAContent[0, 1] = "分洪前线指挥部及其下设七个责任组责任人和成员迅速进入运用准备状态,服从前指的统一调度。";
  40. allYAContent[0, 2] = "分蓄洪区内各个乡镇、村组确定1名领导专门负责承担警报发布和传递任务。警报一经发布,各项避洪工作必须迅速及时,不得有误。";
  41. allYAContent[1, 0] = "当需要区内人员转移时,发布橙色预警,开始实施分蓄洪区内居民转移、清场等工作。";
  42. allYAContent[1, 1] = "人员转移时机根据荆江河段及城陵矶附近地区实时水情、防洪工程情况和区内人员转移所需时间等确定。";
  43. allYAContent[1, 2] = "采取电视、广播、电话、传真、汽笛、敲锣、挂旗、报警器、鸣枪或挨户通知等一切可能的形式迅速向分洪区传播分洪转移命令。";
  44. allYAContent[2, 0] = "当决定启用蓄滞洪区时,发布红色警报。";
  45. allYAContent[2, 1] = "开启套口进洪闸或实施上车湾口门爆破,开始分蓄洪。";
  46. allYAContent[2, 2] = "红色警报期持续至具备返迁条件时为止。";
  47. }
  48. void InitButton() {
  49. enterBtn.onClick.AddListener(() =>
  50. {
  51. qxhddContent.gameObject.SetActive(false);
  52. xhddContent.gameObject.SetActive(true);
  53. });
  54. exitBtn.onClick.AddListener(() =>
  55. {
  56. qxhddContent.gameObject.SetActive(true);
  57. xhddContent.gameObject.SetActive(false);
  58. playBtn.interactable = true;
  59. playing = false;
  60. AllRestore();
  61. });
  62. for (int i = 0; i < yjButtons.Length; i++) {
  63. int temp = i;
  64. yjButtons[i].onClick.AddListener(() =>
  65. {
  66. if (!playing) {
  67. ClearAllText();
  68. }
  69. for (int j = 0; j < yjButtons.Length; j++) {
  70. yjButtons[j].GetComponent<CanvasGroup>().alpha = 0.2f;
  71. }
  72. yjButtons[temp].GetComponent<CanvasGroup>().alpha = 1f;
  73. yJType = (YJType)temp;
  74. yjDropdown.value = temp;
  75. });
  76. }
  77. playBtn.onClick.AddListener(() =>
  78. {
  79. ClearAllText();
  80. playing = true;
  81. playBtn.interactable = false;
  82. ControlYJ();
  83. });
  84. }
  85. void AllRestore() {
  86. TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;
  87. TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);
  88. Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;
  89. material.SetFloat("_ClipLength", 1);
  90. }
  91. void ClearAllText() {
  92. for (int i = 0; i < threeStepBtns.Count; i++) {
  93. threeStepBtns[i].text = "";
  94. }
  95. }
  96. async void ControlYJ() {
  97. switch (yJType) {
  98. case YJType.YELLOW:
  99. TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;
  100. threeStepBtns[0].text = allYAContent[(int)yJType, 0];
  101. await Task.Delay(1000);
  102. if (!playing) {
  103. playBtn.interactable = true;
  104. return;
  105. }
  106. StaticLod.instance.OnFoucusStatic("Bird1");
  107. await Task.Delay(2000);
  108. if (!playing)
  109. {
  110. playBtn.interactable = true;
  111. return;
  112. }
  113. TimeLineControl.instance.transform.GetChild(1).GetChild(1).DOLocalMove(new Vector3(0, 0, 31.2f), 12.0f);
  114. await Task.Delay(11000);
  115. if (!playing)
  116. {
  117. playBtn.interactable = true;
  118. return;
  119. }
  120. threeStepBtns[1].text = allYAContent[(int)yJType, 1];
  121. StaticLod.instance.OnFoucusStatic("Bird2");
  122. await Task.Delay(3000);
  123. if (!playing)
  124. {
  125. playBtn.interactable = true;
  126. return;
  127. }
  128. threeStepBtns[2].text = allYAContent[(int)yJType, 2];
  129. playBtn.interactable = true;
  130. break;
  131. case YJType.ORANGE:
  132. TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);
  133. TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);
  134. threeStepBtns[0].text = allYAContent[(int)yJType, 0];
  135. await Task.Delay(1000);
  136. if (!playing)
  137. {
  138. playBtn.interactable = true;
  139. return;
  140. }
  141. StaticLod.instance.OnFoucusStatic("Bird2");
  142. await Task.Delay(2000);
  143. if (!playing)
  144. {
  145. playBtn.interactable = true;
  146. return;
  147. }
  148. TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(true);
  149. await Task.Delay(8000);
  150. if (!playing)
  151. {
  152. playBtn.interactable = true;
  153. return;
  154. }
  155. threeStepBtns[1].text = allYAContent[(int)yJType, 1];
  156. StaticLod.instance.OnFoucusStatic("Bird3");
  157. await Task.Delay(3000);
  158. if (!playing)
  159. {
  160. playBtn.interactable = true;
  161. return;
  162. }
  163. threeStepBtns[2].text = allYAContent[(int)yJType, 2];
  164. playBtn.interactable = true;
  165. break;
  166. case YJType.RED:
  167. Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;
  168. material.SetFloat("_ClipLength", 1);
  169. TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);
  170. TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(false);
  171. threeStepBtns[0].text = allYAContent[(int)yJType, 0];
  172. await Task.Delay(1000);
  173. if (!playing)
  174. {
  175. playBtn.interactable = true;
  176. return;
  177. }
  178. StaticLod.instance.OnFoucusStatic("Bird2");
  179. await Task.Delay(3000);
  180. if (!playing)
  181. {
  182. playBtn.interactable = true;
  183. return;
  184. }
  185. StaticLod.instance.OnFoucusStatic("Bird4");
  186. ActionInstance._Instance.ModelAni_On?.Invoke();
  187. await Task.Delay(1200);
  188. TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(true);
  189. if (!playing)
  190. {
  191. playBtn.interactable = true;
  192. return;
  193. }
  194. await Task.Delay(500);
  195. material.SetFloat("_ClipLength", 0.981f);
  196. if (!playing)
  197. {
  198. playBtn.interactable = true;
  199. return;
  200. }
  201. threeStepBtns[1].text = allYAContent[(int)yJType, 1];
  202. await Task.Delay(2000);
  203. if (!playing)
  204. {
  205. playBtn.interactable = true;
  206. return;
  207. }
  208. StaticLod.instance.OnFoucusStatic("Bird5");
  209. DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.881f, 4f);
  210. await Task.Delay(5000);
  211. if (!playing)
  212. {
  213. playBtn.interactable = true;
  214. return;
  215. }
  216. StaticLod.instance.OnFoucusStatic("Bird3");
  217. DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.1f, 6f);
  218. await Task.Delay(6000);
  219. if (!playing)
  220. {
  221. playBtn.interactable = true;
  222. return;
  223. }
  224. threeStepBtns[2].text = allYAContent[(int)yJType, 2];
  225. playBtn.interactable = true;
  226. break;
  227. }
  228. }
  229. // Update is called once per frame
  230. void Update()
  231. {
  232. }
  233. }