IT_FaultFixCtrl.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using GameFramework.Event;
  6. using UnityEngine;
  7. using UnityEngine.Playables;
  8. //选项、拖拽
  9. public enum IT_FaultQuestionType
  10. {
  11. select,
  12. trigger
  13. }
  14. public enum IT_FaultType
  15. {
  16. power,
  17. fan,
  18. ram,
  19. cpu,
  20. hardDisk,
  21. battery,
  22. none,
  23. }
  24. public struct StepItemTriggerData
  25. {
  26. public IT_FaultQuestionType questionType;
  27. public IT_FaultType faultType; //如果是选择题的话选择对应错误
  28. public UI_TriggerItemType item_1;
  29. public UI_TriggerItemType item_2;
  30. public float timeLineStart;
  31. public float timeLineEnd;
  32. }
  33. public class IT_FaultFixCtrl : MonoBehaviour
  34. {
  35. public PlayableDirector powerTimeLine;
  36. public PlayableDirector fanTimeLine;
  37. public PlayableDirector ramTimeLine;
  38. public PlayableDirector hardDiskTimeLine;
  39. public PlayableDirector batteryTimeLine;
  40. //步骤统计
  41. private int powerFaultStepCount = 6;
  42. private int fanFaultStepCount = 7;
  43. private int currentStepIndex = 0;
  44. private int ramFaultStepCount = 6;
  45. private int hardDiskStepCount = 6;
  46. private int batteryStepCount = 6;
  47. private IT_FaultType currentType = IT_FaultType.none;
  48. private List<StepItemTriggerData> powerStepList;
  49. private List<StepItemTriggerData> fanStepList;
  50. private List<StepItemTriggerData> ramStepList;
  51. private List<StepItemTriggerData> hardDiskStepList;
  52. private List<StepItemTriggerData> batteryStepList;
  53. private void Awake()
  54. {
  55. InitPowerStep();
  56. InitFanStep();
  57. InitRamStep();
  58. InitHardDiskStep();
  59. InitBatteryStep();
  60. }
  61. private void Start()
  62. {
  63. GameMain.Event.Subscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
  64. GameMain.Event.Subscribe(SelectFaultItemEvent.EventId, OnGetSelectFaultItem);
  65. GameMain.Event.Subscribe(IT_FaultStartEvent.EventId, OnGetIT_FaultStart);
  66. }
  67. private void OnDestroy()
  68. {
  69. if (GameMain.Event.Check(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone))
  70. {
  71. GameMain.Event.Unsubscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
  72. }
  73. if (GameMain.Event.Check(SelectFaultItemEvent.EventId, OnGetSelectFaultItem))
  74. {
  75. GameMain.Event.Unsubscribe(SelectFaultItemEvent.EventId, OnGetSelectFaultItem);
  76. }
  77. if (GameMain.Event.Check(IT_FaultStartEvent.EventId, OnGetIT_FaultStart))
  78. {
  79. GameMain.Event.Unsubscribe(IT_FaultStartEvent.EventId, OnGetIT_FaultStart);
  80. }
  81. }
  82. //初始化步骤中匹配的拖拽项
  83. private void InitPowerStep()
  84. {
  85. powerStepList = new List<StepItemTriggerData>();
  86. //第1步选择电源问题
  87. powerStepList.Add(new StepItemTriggerData()
  88. {
  89. questionType = IT_FaultQuestionType.select,
  90. faultType = IT_FaultType.power,
  91. item_1 = UI_TriggerItemType.none,
  92. item_2 = UI_TriggerItemType.none,
  93. timeLineStart = 25.1f,
  94. timeLineEnd = -1
  95. });
  96. //第2步拖拽手套到手上,合成戴手套的手
  97. powerStepList.Add(new StepItemTriggerData()
  98. {
  99. questionType = IT_FaultQuestionType.trigger,
  100. faultType = IT_FaultType.power,
  101. item_1 = UI_TriggerItemType.hand,
  102. item_2 = UI_TriggerItemType.gloves,
  103. timeLineStart = -1,
  104. timeLineEnd = -1
  105. });
  106. //第3步拖拽戴手套的手到电源卡扣位置
  107. powerStepList.Add(new StepItemTriggerData()
  108. {
  109. questionType = IT_FaultQuestionType.trigger,
  110. faultType = IT_FaultType.power,
  111. item_1 = UI_TriggerItemType.handWithGloves,
  112. item_2 = UI_TriggerItemType.powerLock,
  113. timeLineStart = 59,
  114. timeLineEnd = 61
  115. });
  116. //第4步拖拽戴手套的手到电源位置拉出电源
  117. powerStepList.Add(new StepItemTriggerData()
  118. {
  119. questionType = IT_FaultQuestionType.trigger,
  120. faultType = IT_FaultType.power,
  121. item_1 = UI_TriggerItemType.handWithGloves,
  122. item_2 = UI_TriggerItemType.power,
  123. timeLineStart = 61,
  124. timeLineEnd = 65
  125. });
  126. //第5步拖拽电源到插槽位置
  127. powerStepList.Add(new StepItemTriggerData()
  128. {
  129. questionType = IT_FaultQuestionType.trigger,
  130. faultType = IT_FaultType.power,
  131. item_1 = UI_TriggerItemType.power,
  132. item_2 = UI_TriggerItemType.powerSetPos,
  133. timeLineStart = 73,
  134. timeLineEnd = 79
  135. });
  136. //第6步拖拽戴手套的手到电源位置插紧电源
  137. powerStepList.Add(new StepItemTriggerData()
  138. {
  139. questionType = IT_FaultQuestionType.trigger,
  140. faultType = IT_FaultType.power,
  141. item_1 = UI_TriggerItemType.handWithGloves,
  142. item_2 = UI_TriggerItemType.power,
  143. timeLineStart = 79,
  144. timeLineEnd = 84
  145. });
  146. }
  147. private void InitFanStep()
  148. {
  149. fanStepList = new List<StepItemTriggerData>();
  150. //第1步选择风扇问题
  151. fanStepList.Add(new StepItemTriggerData()
  152. {
  153. questionType = IT_FaultQuestionType.select,
  154. faultType = IT_FaultType.fan,
  155. item_1 = UI_TriggerItemType.none,
  156. item_2 = UI_TriggerItemType.none,
  157. timeLineStart = 10,
  158. timeLineEnd = -1
  159. });
  160. //第2步拖拽手套到手上,合成戴手套的手
  161. fanStepList.Add(new StepItemTriggerData()
  162. {
  163. questionType = IT_FaultQuestionType.trigger,
  164. faultType = IT_FaultType.fan,
  165. item_1 = UI_TriggerItemType.hand,
  166. item_2 = UI_TriggerItemType.gloves,
  167. timeLineStart = 61,
  168. timeLineEnd = -1
  169. });
  170. //第3步拖拽螺丝刀到机箱盖
  171. fanStepList.Add(new StepItemTriggerData()
  172. {
  173. questionType = IT_FaultQuestionType.trigger,
  174. faultType = IT_FaultType.fan,
  175. item_1 = UI_TriggerItemType.screwdriver,
  176. item_2 = UI_TriggerItemType.chassisCoverLock,
  177. timeLineStart = 61,
  178. timeLineEnd = 66
  179. });
  180. //第4步拖拽戴手套的手到机箱盖卡口位置
  181. fanStepList.Add(new StepItemTriggerData()
  182. {
  183. questionType = IT_FaultQuestionType.trigger,
  184. faultType = IT_FaultType.fan,
  185. item_1 = UI_TriggerItemType.handWithGloves,
  186. item_2 = UI_TriggerItemType.chassisCoverLock,
  187. timeLineStart = 67,
  188. timeLineEnd = 75
  189. });
  190. //第5步拖拽戴手套的手到风扇位置
  191. fanStepList.Add(new StepItemTriggerData()
  192. {
  193. questionType = IT_FaultQuestionType.trigger,
  194. faultType = IT_FaultType.fan,
  195. item_1 = UI_TriggerItemType.handWithGloves,
  196. item_2 = UI_TriggerItemType.fan,
  197. timeLineStart = 75,
  198. timeLineEnd = 80
  199. });
  200. //第6步拖拽戴风扇到风扇安装位置
  201. fanStepList.Add(new StepItemTriggerData()
  202. {
  203. questionType = IT_FaultQuestionType.trigger,
  204. faultType = IT_FaultType.fan,
  205. item_1 = UI_TriggerItemType.fan,
  206. item_2 = UI_TriggerItemType.fanSetPos,
  207. timeLineStart = 87,
  208. timeLineEnd = 90
  209. });
  210. //第7步拖拽戴机箱盖到安装位置
  211. fanStepList.Add(new StepItemTriggerData()
  212. {
  213. questionType = IT_FaultQuestionType.trigger,
  214. faultType = IT_FaultType.fan,
  215. item_1 = UI_TriggerItemType.chassisCover,
  216. item_2 = UI_TriggerItemType.chassisCoverSetPos,
  217. timeLineStart = 93,
  218. timeLineEnd = 100
  219. });
  220. }
  221. private void InitRamStep()
  222. {
  223. ramStepList = new List<StepItemTriggerData>();
  224. //第1步选择内存问题
  225. ramStepList.Add(new StepItemTriggerData()
  226. {
  227. questionType = IT_FaultQuestionType.select,
  228. faultType = IT_FaultType.ram,
  229. item_1 = UI_TriggerItemType.none,
  230. item_2 = UI_TriggerItemType.none,
  231. timeLineStart = 21,
  232. timeLineEnd = -1
  233. });
  234. //第2步拖拽手套到手上,合成戴手套的手
  235. ramStepList.Add(new StepItemTriggerData()
  236. {
  237. questionType = IT_FaultQuestionType.trigger,
  238. faultType = IT_FaultType.ram,
  239. item_1 = UI_TriggerItemType.hand,
  240. item_2 = UI_TriggerItemType.gloves,
  241. timeLineStart = 21,
  242. timeLineEnd = -1
  243. });
  244. //第三步拆机箱盖
  245. ramStepList.Add(new StepItemTriggerData()
  246. {
  247. questionType = IT_FaultQuestionType.trigger,
  248. faultType = IT_FaultType.ram,
  249. item_1 = UI_TriggerItemType.screwdriver,
  250. item_2 = UI_TriggerItemType.chassisCoverLock,
  251. timeLineStart = 21,
  252. timeLineEnd = 24
  253. });
  254. //第四步拆内存
  255. ramStepList.Add(new StepItemTriggerData()
  256. {
  257. questionType = IT_FaultQuestionType.trigger,
  258. faultType = IT_FaultType.ram,
  259. item_1 = UI_TriggerItemType.handWithGloves,
  260. item_2 = UI_TriggerItemType.ram,
  261. timeLineStart = 44,
  262. timeLineEnd = 46
  263. });
  264. //第五步装内存
  265. ramStepList.Add(new StepItemTriggerData()
  266. {
  267. questionType = IT_FaultQuestionType.trigger,
  268. faultType = IT_FaultType.ram,
  269. item_1 = UI_TriggerItemType.ram,
  270. item_2 = UI_TriggerItemType.ramPos,
  271. timeLineStart = 52,
  272. timeLineEnd = 62
  273. });
  274. //第六步装机箱盖
  275. ramStepList.Add(new StepItemTriggerData()
  276. {
  277. questionType = IT_FaultQuestionType.trigger,
  278. faultType = IT_FaultType.ram,
  279. item_1 = UI_TriggerItemType.chassisCover,
  280. item_2 = UI_TriggerItemType.chassisCoverSetPos,
  281. timeLineStart = 68,
  282. timeLineEnd = 72
  283. });
  284. }
  285. private void InitHardDiskStep()
  286. {
  287. hardDiskStepList = new List<StepItemTriggerData>();
  288. //第一步选择硬盘问题
  289. hardDiskStepList.Add(new StepItemTriggerData()
  290. {
  291. questionType = IT_FaultQuestionType.select,
  292. faultType = IT_FaultType.hardDisk,
  293. item_1 = UI_TriggerItemType.none,
  294. item_2 = UI_TriggerItemType.none,
  295. timeLineStart = 10,
  296. timeLineEnd = -1
  297. });
  298. //第二步合成戴手套的手
  299. hardDiskStepList.Add(new StepItemTriggerData()
  300. {
  301. questionType = IT_FaultQuestionType.trigger,
  302. faultType = IT_FaultType.hardDisk,
  303. item_1 = UI_TriggerItemType.hand,
  304. item_2 = UI_TriggerItemType.gloves,
  305. timeLineStart = 10,
  306. timeLineEnd = -1
  307. });
  308. //第三步从机箱上拆下硬盘
  309. hardDiskStepList.Add(new StepItemTriggerData()
  310. {
  311. questionType = IT_FaultQuestionType.trigger,
  312. faultType = IT_FaultType.hardDisk,
  313. item_1 = UI_TriggerItemType.handWithGloves,
  314. item_2 = UI_TriggerItemType.hardDisk,
  315. timeLineStart = 23,
  316. timeLineEnd = 33
  317. });
  318. //第四步用螺丝刀拆卸硬盘
  319. hardDiskStepList.Add(new StepItemTriggerData()
  320. {
  321. questionType = IT_FaultQuestionType.trigger,
  322. faultType = IT_FaultType.hardDisk,
  323. item_1 = UI_TriggerItemType.screwdriver,
  324. item_2 = UI_TriggerItemType.hardDisk,
  325. timeLineStart = 40,
  326. timeLineEnd = 48
  327. });
  328. //第五步装上新硬盘
  329. hardDiskStepList.Add(new StepItemTriggerData()
  330. {
  331. questionType = IT_FaultQuestionType.trigger,
  332. faultType = IT_FaultType.hardDisk,
  333. item_1 = UI_TriggerItemType.hardDisk,
  334. item_2 = UI_TriggerItemType.hardDiskPos,
  335. timeLineStart = 57,
  336. timeLineEnd = 63
  337. });
  338. //第六步插紧硬盘盒
  339. hardDiskStepList.Add(new StepItemTriggerData()
  340. {
  341. questionType = IT_FaultQuestionType.trigger,
  342. faultType = IT_FaultType.hardDisk,
  343. item_1 = UI_TriggerItemType.handWithGloves,
  344. item_2 = UI_TriggerItemType.hardDiskPos,
  345. timeLineStart = 71,
  346. timeLineEnd = 74
  347. });
  348. }
  349. private void InitBatteryStep()
  350. {
  351. //第一步选择电池问题
  352. batteryStepList = new List<StepItemTriggerData>();
  353. batteryStepList.Add(new StepItemTriggerData()
  354. {
  355. questionType = IT_FaultQuestionType.select,
  356. faultType = IT_FaultType.battery,
  357. item_1 = UI_TriggerItemType.none,
  358. item_2 = UI_TriggerItemType.none,
  359. timeLineStart = 10,
  360. timeLineEnd = -1
  361. });
  362. //第二部合成手套
  363. batteryStepList.Add(new StepItemTriggerData()
  364. {
  365. questionType = IT_FaultQuestionType.trigger,
  366. faultType = IT_FaultType.battery,
  367. item_1 = UI_TriggerItemType.hand,
  368. item_2 = UI_TriggerItemType.gloves,
  369. timeLineStart = 21,
  370. timeLineEnd = -1
  371. });
  372. //第三步拔线
  373. batteryStepList.Add(new StepItemTriggerData()
  374. {
  375. questionType = IT_FaultQuestionType.trigger,
  376. faultType = IT_FaultType.battery,
  377. item_1 = UI_TriggerItemType.handWithGloves,
  378. item_2 = UI_TriggerItemType.chassisCoverLock,
  379. timeLineStart = 21,
  380. timeLineEnd = 25
  381. });
  382. //第四步用螺丝刀拆电池
  383. batteryStepList.Add(new StepItemTriggerData()
  384. {
  385. questionType = IT_FaultQuestionType.trigger,
  386. faultType = IT_FaultType.battery,
  387. item_1 = UI_TriggerItemType.screwdriver,
  388. item_2 = UI_TriggerItemType.battery,
  389. timeLineStart = 35,
  390. timeLineEnd = 43
  391. });
  392. //第五步装上新电池
  393. batteryStepList.Add(new StepItemTriggerData()
  394. {
  395. questionType = IT_FaultQuestionType.trigger,
  396. faultType = IT_FaultType.battery,
  397. item_1 = UI_TriggerItemType.battery,
  398. item_2 = UI_TriggerItemType.batteryPos,
  399. timeLineStart = 45,
  400. timeLineEnd = 49
  401. });
  402. //第六步装上机箱盖
  403. batteryStepList.Add(new StepItemTriggerData()
  404. {
  405. questionType = IT_FaultQuestionType.trigger,
  406. faultType = IT_FaultType.battery,
  407. item_1 = UI_TriggerItemType.chassisCover,
  408. item_2 = UI_TriggerItemType.chassisCoverSetPos,
  409. timeLineStart = 60,
  410. timeLineEnd = 63
  411. });
  412. }
  413. private void ReSetFaultFix()
  414. {
  415. currentStepIndex = 0;
  416. if (currentType == IT_FaultType.fan)
  417. {
  418. fanTimeLine.Stop();
  419. fanTimeLine.time = fanStepList[0].timeLineStart;
  420. }
  421. if (currentType == IT_FaultType.power)
  422. {
  423. powerTimeLine.Stop();
  424. powerTimeLine.time = powerStepList[0].timeLineStart;
  425. }
  426. if (currentType == IT_FaultType.ram)
  427. {
  428. ramTimeLine.Stop();
  429. ramTimeLine.time = ramStepList[0].timeLineStart;
  430. }
  431. if (currentType == IT_FaultType.hardDisk)
  432. {
  433. hardDiskTimeLine.Stop();
  434. hardDiskTimeLine.time = hardDiskStepList[0].timeLineStart;
  435. }
  436. if (currentType == IT_FaultType.battery)
  437. {
  438. batteryTimeLine.Stop();
  439. batteryTimeLine.time = batteryStepList[0].timeLineStart;
  440. }
  441. }
  442. private async void OnGetIT_FaultStart(object sender, GameEventArgs e)
  443. {
  444. IT_FaultStartEvent args = (IT_FaultStartEvent)e;
  445. if (args.type == IT_FaultType.fan && currentType != IT_FaultType.fan)
  446. {
  447. currentType = IT_FaultType.fan;
  448. currentStepIndex = 0;
  449. powerTimeLine.Stop();
  450. ramTimeLine.Stop();
  451. hardDiskTimeLine.Stop();
  452. batteryTimeLine.Stop();
  453. powerTimeLine.gameObject.SetActive(false);
  454. ramTimeLine.gameObject.SetActive(false);
  455. hardDiskTimeLine.gameObject.SetActive(false);
  456. batteryTimeLine.gameObject.SetActive(false);
  457. fanTimeLine.gameObject.SetActive(true);
  458. fanTimeLine.time = fanStepList[0].timeLineStart;
  459. fanTimeLine.Play();
  460. await Task.Delay(50);
  461. fanTimeLine.Pause();
  462. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  463. }
  464. if (args.type == IT_FaultType.power && currentType != IT_FaultType.power)
  465. {
  466. currentType = IT_FaultType.power;
  467. currentStepIndex = 0;
  468. fanTimeLine.Stop();
  469. ramTimeLine.Stop();
  470. hardDiskTimeLine.Stop();
  471. batteryTimeLine.Stop();
  472. fanTimeLine.gameObject.SetActive(false);
  473. ramTimeLine.gameObject.SetActive(false);
  474. hardDiskTimeLine.gameObject.SetActive(false);
  475. batteryTimeLine.gameObject.SetActive(false);
  476. powerTimeLine.gameObject.SetActive(true);
  477. powerTimeLine.time = powerStepList[0].timeLineStart;
  478. powerTimeLine.Play();
  479. await Task.Delay(50);
  480. powerTimeLine.Pause();
  481. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  482. }
  483. if (args.type == IT_FaultType.ram && currentType != IT_FaultType.ram)
  484. {
  485. currentType = IT_FaultType.ram;
  486. currentStepIndex = 0;
  487. fanTimeLine.Stop();
  488. powerTimeLine.Stop();
  489. hardDiskTimeLine.Stop();
  490. batteryTimeLine.Stop();
  491. powerTimeLine.gameObject.SetActive(false);
  492. fanTimeLine.gameObject.SetActive(false);
  493. hardDiskTimeLine.gameObject.SetActive(false);
  494. batteryTimeLine.gameObject.SetActive(false);
  495. ramTimeLine.gameObject.SetActive(true);
  496. ramTimeLine.time = ramStepList[0].timeLineStart;
  497. ramTimeLine.Play();
  498. await Task.Delay(50);
  499. ramTimeLine.Pause();
  500. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  501. }
  502. if (args.type == IT_FaultType.hardDisk && currentType != IT_FaultType.hardDisk)
  503. {
  504. currentType = IT_FaultType.hardDisk;
  505. currentStepIndex = 0;
  506. fanTimeLine.Stop();
  507. powerTimeLine.Stop();
  508. ramTimeLine.Stop();
  509. batteryTimeLine.Stop();
  510. powerTimeLine.gameObject.SetActive(false);
  511. fanTimeLine.gameObject.SetActive(false);
  512. ramTimeLine.gameObject.SetActive(false);
  513. batteryTimeLine.gameObject.SetActive(false);
  514. hardDiskTimeLine.gameObject.SetActive(true);
  515. hardDiskTimeLine.time = hardDiskStepList[0].timeLineStart;
  516. hardDiskTimeLine.Play();
  517. await Task.Delay(50);
  518. hardDiskTimeLine.Pause();
  519. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  520. }
  521. if (args.type == IT_FaultType.battery && currentType != IT_FaultType.battery)
  522. {
  523. currentType = IT_FaultType.battery;
  524. currentStepIndex = 0;
  525. fanTimeLine.Stop();
  526. powerTimeLine.Stop();
  527. ramTimeLine.Stop();
  528. hardDiskTimeLine.Stop();
  529. powerTimeLine.gameObject.SetActive(false);
  530. fanTimeLine.gameObject.SetActive(false);
  531. ramTimeLine.gameObject.SetActive(false);
  532. hardDiskTimeLine.gameObject.SetActive(false);
  533. batteryTimeLine.gameObject.SetActive(true);
  534. batteryTimeLine.time = batteryStepList[0].timeLineStart;
  535. batteryTimeLine.Play();
  536. await Task.Delay(50);
  537. batteryTimeLine.Pause();
  538. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  539. }
  540. }
  541. private async void OnGetUI_ItemMoveDone(object sender, GameEventArgs e)
  542. {
  543. List<StepItemTriggerData> currentList = null;
  544. int stepCount = -1;
  545. PlayableDirector currentPlayableDirector = null;
  546. switch (currentType)
  547. {
  548. case IT_FaultType.fan:
  549. currentList = fanStepList;
  550. stepCount = fanFaultStepCount;
  551. currentPlayableDirector = fanTimeLine;
  552. break;
  553. case IT_FaultType.power:
  554. currentList = powerStepList;
  555. stepCount = powerFaultStepCount;
  556. currentPlayableDirector = powerTimeLine;
  557. break;
  558. case IT_FaultType.ram:
  559. currentList = ramStepList;
  560. stepCount = ramFaultStepCount;
  561. currentPlayableDirector = ramTimeLine;
  562. break;
  563. case IT_FaultType.hardDisk:
  564. currentList = hardDiskStepList;
  565. stepCount = hardDiskStepCount;
  566. currentPlayableDirector = hardDiskTimeLine;
  567. break;
  568. case IT_FaultType.battery:
  569. currentList = batteryStepList;
  570. stepCount = batteryStepCount;
  571. currentPlayableDirector = batteryTimeLine;
  572. break;
  573. }
  574. if (currentList[currentStepIndex].questionType == IT_FaultQuestionType.trigger)
  575. {
  576. UI_ItemMoveDoneEvent args = (UI_ItemMoveDoneEvent)e;
  577. Debug.Log($"{args.item_1}:{args.item_2} {currentList[currentStepIndex].item_1}:{currentList[currentStepIndex].item_2}");
  578. bool pass = false;
  579. if (args.item_1 == currentList[currentStepIndex].item_1)
  580. {
  581. if (args.item_2 == currentList[currentStepIndex].item_2)
  582. {
  583. pass = true;
  584. }
  585. }
  586. else if (args.item_2 == currentList[currentStepIndex].item_1)
  587. {
  588. if (args.item_1 == currentList[currentStepIndex].item_2)
  589. {
  590. pass = true;
  591. }
  592. }
  593. if (pass)
  594. {
  595. if (currentList[currentStepIndex].timeLineEnd != -1)
  596. {
  597. currentPlayableDirector.Play();
  598. await Task.Delay((int)(currentList[currentStepIndex].timeLineEnd - currentList[currentStepIndex].timeLineStart) * 1000);
  599. currentPlayableDirector.Pause();
  600. }
  601. currentStepIndex++;
  602. if (currentStepIndex >= stepCount)
  603. {
  604. GameMain.Event.Fire(this, IT_TrainStudyDoneEvent.Create());
  605. }
  606. else
  607. {
  608. //todo nextStep
  609. currentPlayableDirector.time = currentList[currentStepIndex].timeLineStart;
  610. currentPlayableDirector.Play();
  611. await Task.Delay(50);
  612. currentPlayableDirector.Pause();
  613. Debug.Log($"{currentType} {currentStepIndex}");
  614. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  615. }
  616. }
  617. }
  618. }
  619. private async void OnGetSelectFaultItem(object sender, GameEventArgs e)
  620. {
  621. List<StepItemTriggerData> currentList = null;
  622. int stepCount = -1;
  623. PlayableDirector currentPlayableDirector = null;
  624. switch (currentType)
  625. {
  626. case IT_FaultType.fan:
  627. currentList = fanStepList;
  628. stepCount = fanFaultStepCount;
  629. currentPlayableDirector = fanTimeLine;
  630. break;
  631. case IT_FaultType.power:
  632. currentList = powerStepList;
  633. stepCount = powerFaultStepCount;
  634. currentPlayableDirector = powerTimeLine;
  635. break;
  636. case IT_FaultType.ram:
  637. currentList = ramStepList;
  638. stepCount = ramFaultStepCount;
  639. currentPlayableDirector = ramTimeLine;
  640. break;
  641. case IT_FaultType.hardDisk:
  642. currentList = hardDiskStepList;
  643. stepCount = hardDiskStepCount;
  644. currentPlayableDirector = hardDiskTimeLine;
  645. break;
  646. case IT_FaultType.battery:
  647. currentList = batteryStepList;
  648. stepCount = batteryStepCount;
  649. currentPlayableDirector = batteryTimeLine;
  650. break;
  651. }
  652. if (currentList[currentStepIndex].questionType == IT_FaultQuestionType.select)
  653. {
  654. SelectFaultItemEvent args = (SelectFaultItemEvent)e;
  655. //Debug.Log($"{args.faultType} {currentList[currentStepIndex].faultType}");
  656. if (args.faultType == currentList[currentStepIndex].faultType)
  657. {
  658. if (currentList[currentStepIndex].timeLineEnd != -1)
  659. {
  660. currentPlayableDirector.Play();
  661. await Task.Delay((int)(currentList[currentStepIndex].timeLineEnd - currentList[currentStepIndex].timeLineStart) * 1000);
  662. currentPlayableDirector.Pause();
  663. }
  664. currentStepIndex++;
  665. if (currentStepIndex >= stepCount)
  666. {
  667. //todo 完成
  668. }
  669. else
  670. {
  671. //todo nextStep
  672. currentPlayableDirector.time = currentList[currentStepIndex].timeLineStart;
  673. currentPlayableDirector.Play();
  674. await Task.Delay(50);
  675. currentPlayableDirector.Pause();
  676. Debug.Log($"{currentType} {currentStepIndex}");
  677. GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
  678. }
  679. }
  680. }
  681. }
  682. }