123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using GameFramework.Event;
- using UnityEngine;
- using UnityEngine.Playables;
- //选项、拖拽
- public enum IT_FaultQuestionType
- {
- select,
- trigger
- }
- public enum IT_FaultType
- {
- power,
- fan,
- ram,
- cpu,
- hardDisk,
- battery,
- none,
- }
- public struct StepItemTriggerData
- {
- public IT_FaultQuestionType questionType;
- public IT_FaultType faultType; //如果是选择题的话选择对应错误
- public UI_TriggerItemType item_1;
- public UI_TriggerItemType item_2;
- public float timeLineStart;
- public float timeLineEnd;
- }
- public class IT_FaultFixCtrl : MonoBehaviour
- {
- public PlayableDirector powerTimeLine;
- public PlayableDirector fanTimeLine;
- public PlayableDirector ramTimeLine;
- public PlayableDirector hardDiskTimeLine;
- public PlayableDirector batteryTimeLine;
- //步骤统计
- private int powerFaultStepCount = 6;
- private int fanFaultStepCount = 7;
- private int currentStepIndex = 0;
- private int ramFaultStepCount = 6;
- private int hardDiskStepCount = 6;
- private int batteryStepCount = 6;
- private IT_FaultType currentType = IT_FaultType.none;
- private List<StepItemTriggerData> powerStepList;
- private List<StepItemTriggerData> fanStepList;
- private List<StepItemTriggerData> ramStepList;
- private List<StepItemTriggerData> hardDiskStepList;
- private List<StepItemTriggerData> batteryStepList;
- private void Awake()
- {
- InitPowerStep();
- InitFanStep();
- InitRamStep();
- InitHardDiskStep();
- InitBatteryStep();
- }
- private void Start()
- {
- GameMain.Event.Subscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
- GameMain.Event.Subscribe(SelectFaultItemEvent.EventId, OnGetSelectFaultItem);
- GameMain.Event.Subscribe(IT_FaultStartEvent.EventId, OnGetIT_FaultStart);
- }
- private void OnDestroy()
- {
- if (GameMain.Event.Check(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone))
- {
- GameMain.Event.Unsubscribe(UI_ItemMoveDoneEvent.EventId, OnGetUI_ItemMoveDone);
- }
- if (GameMain.Event.Check(SelectFaultItemEvent.EventId, OnGetSelectFaultItem))
- {
- GameMain.Event.Unsubscribe(SelectFaultItemEvent.EventId, OnGetSelectFaultItem);
- }
- if (GameMain.Event.Check(IT_FaultStartEvent.EventId, OnGetIT_FaultStart))
- {
- GameMain.Event.Unsubscribe(IT_FaultStartEvent.EventId, OnGetIT_FaultStart);
- }
- }
- //初始化步骤中匹配的拖拽项
- private void InitPowerStep()
- {
- powerStepList = new List<StepItemTriggerData>();
- //第1步选择电源问题
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.select,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.none,
- item_2 = UI_TriggerItemType.none,
- timeLineStart = 25.1f,
- timeLineEnd = -1
- });
- //第2步拖拽手套到手上,合成戴手套的手
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.hand,
- item_2 = UI_TriggerItemType.gloves,
- timeLineStart = -1,
- timeLineEnd = -1
- });
- //第3步拖拽戴手套的手到电源卡扣位置
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.powerLock,
- timeLineStart = 59,
- timeLineEnd = 61
- });
- //第4步拖拽戴手套的手到电源位置拉出电源
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.power,
- timeLineStart = 61,
- timeLineEnd = 65
- });
- //第5步拖拽电源到插槽位置
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.power,
- item_2 = UI_TriggerItemType.powerSetPos,
- timeLineStart = 73,
- timeLineEnd = 79
- });
- //第6步拖拽戴手套的手到电源位置插紧电源
- powerStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.power,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.power,
- timeLineStart = 79,
- timeLineEnd = 84
- });
- }
- private void InitFanStep()
- {
- fanStepList = new List<StepItemTriggerData>();
- //第1步选择风扇问题
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.select,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.none,
- item_2 = UI_TriggerItemType.none,
- timeLineStart = 10,
- timeLineEnd = -1
- });
- //第2步拖拽手套到手上,合成戴手套的手
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.hand,
- item_2 = UI_TriggerItemType.gloves,
- timeLineStart = 61,
- timeLineEnd = -1
- });
- //第3步拖拽螺丝刀到机箱盖
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.screwdriver,
- item_2 = UI_TriggerItemType.chassisCoverLock,
- timeLineStart = 61,
- timeLineEnd = 66
- });
- //第4步拖拽戴手套的手到机箱盖卡口位置
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.chassisCoverLock,
- timeLineStart = 67,
- timeLineEnd = 75
- });
- //第5步拖拽戴手套的手到风扇位置
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.fan,
- timeLineStart = 75,
- timeLineEnd = 80
- });
- //第6步拖拽戴风扇到风扇安装位置
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.fan,
- item_2 = UI_TriggerItemType.fanSetPos,
- timeLineStart = 87,
- timeLineEnd = 90
- });
- //第7步拖拽戴机箱盖到安装位置
- fanStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.fan,
- item_1 = UI_TriggerItemType.chassisCover,
- item_2 = UI_TriggerItemType.chassisCoverSetPos,
- timeLineStart = 93,
- timeLineEnd = 100
- });
- }
- private void InitRamStep()
- {
- ramStepList = new List<StepItemTriggerData>();
- //第1步选择内存问题
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.select,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.none,
- item_2 = UI_TriggerItemType.none,
- timeLineStart = 21,
- timeLineEnd = -1
- });
- //第2步拖拽手套到手上,合成戴手套的手
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.hand,
- item_2 = UI_TriggerItemType.gloves,
- timeLineStart = 21,
- timeLineEnd = -1
- });
- //第三步拆机箱盖
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.screwdriver,
- item_2 = UI_TriggerItemType.chassisCoverLock,
- timeLineStart = 21,
- timeLineEnd = 24
- });
- //第四步拆内存
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.ram,
- timeLineStart = 44,
- timeLineEnd = 46
- });
- //第五步装内存
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.ram,
- item_2 = UI_TriggerItemType.ramPos,
- timeLineStart = 52,
- timeLineEnd = 62
- });
- //第六步装机箱盖
- ramStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.ram,
- item_1 = UI_TriggerItemType.chassisCover,
- item_2 = UI_TriggerItemType.chassisCoverSetPos,
- timeLineStart = 68,
- timeLineEnd = 72
- });
- }
- private void InitHardDiskStep()
- {
- hardDiskStepList = new List<StepItemTriggerData>();
- //第一步选择硬盘问题
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.select,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.none,
- item_2 = UI_TriggerItemType.none,
- timeLineStart = 10,
- timeLineEnd = -1
- });
- //第二步合成戴手套的手
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.hand,
- item_2 = UI_TriggerItemType.gloves,
- timeLineStart = 10,
- timeLineEnd = -1
- });
- //第三步从机箱上拆下硬盘
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.hardDisk,
- timeLineStart = 23,
- timeLineEnd = 33
- });
- //第四步用螺丝刀拆卸硬盘
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.screwdriver,
- item_2 = UI_TriggerItemType.hardDisk,
- timeLineStart = 40,
- timeLineEnd = 48
- });
- //第五步装上新硬盘
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.hardDisk,
- item_2 = UI_TriggerItemType.hardDiskPos,
- timeLineStart = 57,
- timeLineEnd = 63
- });
- //第六步插紧硬盘盒
- hardDiskStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.hardDisk,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.hardDiskPos,
- timeLineStart = 71,
- timeLineEnd = 74
- });
- }
-
- private void InitBatteryStep()
- {
- //第一步选择电池问题
- batteryStepList = new List<StepItemTriggerData>();
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.select,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.none,
- item_2 = UI_TriggerItemType.none,
- timeLineStart = 10,
- timeLineEnd = -1
- });
- //第二部合成手套
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.hand,
- item_2 = UI_TriggerItemType.gloves,
- timeLineStart = 21,
- timeLineEnd = -1
- });
- //第三步拔线
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.handWithGloves,
- item_2 = UI_TriggerItemType.chassisCoverLock,
- timeLineStart = 21,
- timeLineEnd = 25
- });
- //第四步用螺丝刀拆电池
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.screwdriver,
- item_2 = UI_TriggerItemType.battery,
- timeLineStart = 35,
- timeLineEnd = 43
- });
- //第五步装上新电池
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.battery,
- item_2 = UI_TriggerItemType.batteryPos,
- timeLineStart = 45,
- timeLineEnd = 49
- });
- //第六步装上机箱盖
- batteryStepList.Add(new StepItemTriggerData()
- {
- questionType = IT_FaultQuestionType.trigger,
- faultType = IT_FaultType.battery,
- item_1 = UI_TriggerItemType.chassisCover,
- item_2 = UI_TriggerItemType.chassisCoverSetPos,
- timeLineStart = 60,
- timeLineEnd = 63
- });
- }
-
- private void ReSetFaultFix()
- {
- currentStepIndex = 0;
- if (currentType == IT_FaultType.fan)
- {
- fanTimeLine.Stop();
- fanTimeLine.time = fanStepList[0].timeLineStart;
- }
- if (currentType == IT_FaultType.power)
- {
- powerTimeLine.Stop();
- powerTimeLine.time = powerStepList[0].timeLineStart;
- }
-
- if (currentType == IT_FaultType.ram)
- {
- ramTimeLine.Stop();
- ramTimeLine.time = ramStepList[0].timeLineStart;
- }
-
- if (currentType == IT_FaultType.hardDisk)
- {
- hardDiskTimeLine.Stop();
- hardDiskTimeLine.time = hardDiskStepList[0].timeLineStart;
- }
-
- if (currentType == IT_FaultType.battery)
- {
- batteryTimeLine.Stop();
- batteryTimeLine.time = batteryStepList[0].timeLineStart;
- }
- }
- private async void OnGetIT_FaultStart(object sender, GameEventArgs e)
- {
- IT_FaultStartEvent args = (IT_FaultStartEvent)e;
- if (args.type == IT_FaultType.fan && currentType != IT_FaultType.fan)
- {
- currentType = IT_FaultType.fan;
- currentStepIndex = 0;
- powerTimeLine.Stop();
- ramTimeLine.Stop();
- hardDiskTimeLine.Stop();
- batteryTimeLine.Stop();
- powerTimeLine.gameObject.SetActive(false);
- ramTimeLine.gameObject.SetActive(false);
- hardDiskTimeLine.gameObject.SetActive(false);
- batteryTimeLine.gameObject.SetActive(false);
-
- fanTimeLine.gameObject.SetActive(true);
- fanTimeLine.time = fanStepList[0].timeLineStart;
- fanTimeLine.Play();
- await Task.Delay(50);
- fanTimeLine.Pause();
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
- if (args.type == IT_FaultType.power && currentType != IT_FaultType.power)
- {
- currentType = IT_FaultType.power;
- currentStepIndex = 0;
- fanTimeLine.Stop();
- ramTimeLine.Stop();
- hardDiskTimeLine.Stop();
- batteryTimeLine.Stop();
- fanTimeLine.gameObject.SetActive(false);
- ramTimeLine.gameObject.SetActive(false);
- hardDiskTimeLine.gameObject.SetActive(false);
- batteryTimeLine.gameObject.SetActive(false);
-
- powerTimeLine.gameObject.SetActive(true);
- powerTimeLine.time = powerStepList[0].timeLineStart;
- powerTimeLine.Play();
- await Task.Delay(50);
- powerTimeLine.Pause();
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
-
- if (args.type == IT_FaultType.ram && currentType != IT_FaultType.ram)
- {
- currentType = IT_FaultType.ram;
- currentStepIndex = 0;
- fanTimeLine.Stop();
- powerTimeLine.Stop();
- hardDiskTimeLine.Stop();
- batteryTimeLine.Stop();
-
- powerTimeLine.gameObject.SetActive(false);
- fanTimeLine.gameObject.SetActive(false);
- hardDiskTimeLine.gameObject.SetActive(false);
- batteryTimeLine.gameObject.SetActive(false);
-
- ramTimeLine.gameObject.SetActive(true);
- ramTimeLine.time = ramStepList[0].timeLineStart;
- ramTimeLine.Play();
- await Task.Delay(50);
- ramTimeLine.Pause();
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
-
- if (args.type == IT_FaultType.hardDisk && currentType != IT_FaultType.hardDisk)
- {
- currentType = IT_FaultType.hardDisk;
- currentStepIndex = 0;
- fanTimeLine.Stop();
- powerTimeLine.Stop();
- ramTimeLine.Stop();
- batteryTimeLine.Stop();
-
- powerTimeLine.gameObject.SetActive(false);
- fanTimeLine.gameObject.SetActive(false);
- ramTimeLine.gameObject.SetActive(false);
- batteryTimeLine.gameObject.SetActive(false);
-
- hardDiskTimeLine.gameObject.SetActive(true);
- hardDiskTimeLine.time = hardDiskStepList[0].timeLineStart;
- hardDiskTimeLine.Play();
- await Task.Delay(50);
- hardDiskTimeLine.Pause();
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
-
- if (args.type == IT_FaultType.battery && currentType != IT_FaultType.battery)
- {
- currentType = IT_FaultType.battery;
- currentStepIndex = 0;
- fanTimeLine.Stop();
- powerTimeLine.Stop();
- ramTimeLine.Stop();
- hardDiskTimeLine.Stop();
-
- powerTimeLine.gameObject.SetActive(false);
- fanTimeLine.gameObject.SetActive(false);
- ramTimeLine.gameObject.SetActive(false);
- hardDiskTimeLine.gameObject.SetActive(false);
-
- batteryTimeLine.gameObject.SetActive(true);
- batteryTimeLine.time = batteryStepList[0].timeLineStart;
- batteryTimeLine.Play();
- await Task.Delay(50);
- batteryTimeLine.Pause();
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
- }
- private async void OnGetUI_ItemMoveDone(object sender, GameEventArgs e)
- {
- List<StepItemTriggerData> currentList = null;
- int stepCount = -1;
- PlayableDirector currentPlayableDirector = null;
- switch (currentType)
- {
- case IT_FaultType.fan:
- currentList = fanStepList;
- stepCount = fanFaultStepCount;
- currentPlayableDirector = fanTimeLine;
- break;
- case IT_FaultType.power:
- currentList = powerStepList;
- stepCount = powerFaultStepCount;
- currentPlayableDirector = powerTimeLine;
- break;
- case IT_FaultType.ram:
- currentList = ramStepList;
- stepCount = ramFaultStepCount;
- currentPlayableDirector = ramTimeLine;
- break;
- case IT_FaultType.hardDisk:
- currentList = hardDiskStepList;
- stepCount = hardDiskStepCount;
- currentPlayableDirector = hardDiskTimeLine;
- break;
- case IT_FaultType.battery:
- currentList = batteryStepList;
- stepCount = batteryStepCount;
- currentPlayableDirector = batteryTimeLine;
- break;
- }
- if (currentList[currentStepIndex].questionType == IT_FaultQuestionType.trigger)
- {
- UI_ItemMoveDoneEvent args = (UI_ItemMoveDoneEvent)e;
- Debug.Log($"{args.item_1}:{args.item_2} {currentList[currentStepIndex].item_1}:{currentList[currentStepIndex].item_2}");
- bool pass = false;
- if (args.item_1 == currentList[currentStepIndex].item_1)
- {
- if (args.item_2 == currentList[currentStepIndex].item_2)
- {
- pass = true;
- }
- }
- else if (args.item_2 == currentList[currentStepIndex].item_1)
- {
- if (args.item_1 == currentList[currentStepIndex].item_2)
- {
- pass = true;
- }
- }
- if (pass)
- {
- if (currentList[currentStepIndex].timeLineEnd != -1)
- {
- currentPlayableDirector.Play();
- await Task.Delay((int)(currentList[currentStepIndex].timeLineEnd - currentList[currentStepIndex].timeLineStart) * 1000);
- currentPlayableDirector.Pause();
- }
- currentStepIndex++;
- if (currentStepIndex >= stepCount)
- {
- GameMain.Event.Fire(this, IT_TrainStudyDoneEvent.Create());
- }
- else
- {
- //todo nextStep
- currentPlayableDirector.time = currentList[currentStepIndex].timeLineStart;
- currentPlayableDirector.Play();
- await Task.Delay(50);
- currentPlayableDirector.Pause();
- Debug.Log($"{currentType} {currentStepIndex}");
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
- }
- }
- }
- private async void OnGetSelectFaultItem(object sender, GameEventArgs e)
- {
- List<StepItemTriggerData> currentList = null;
- int stepCount = -1;
- PlayableDirector currentPlayableDirector = null;
- switch (currentType)
- {
- case IT_FaultType.fan:
- currentList = fanStepList;
- stepCount = fanFaultStepCount;
- currentPlayableDirector = fanTimeLine;
- break;
- case IT_FaultType.power:
- currentList = powerStepList;
- stepCount = powerFaultStepCount;
- currentPlayableDirector = powerTimeLine;
- break;
- case IT_FaultType.ram:
- currentList = ramStepList;
- stepCount = ramFaultStepCount;
- currentPlayableDirector = ramTimeLine;
- break;
- case IT_FaultType.hardDisk:
- currentList = hardDiskStepList;
- stepCount = hardDiskStepCount;
- currentPlayableDirector = hardDiskTimeLine;
- break;
- case IT_FaultType.battery:
- currentList = batteryStepList;
- stepCount = batteryStepCount;
- currentPlayableDirector = batteryTimeLine;
- break;
- }
- if (currentList[currentStepIndex].questionType == IT_FaultQuestionType.select)
- {
- SelectFaultItemEvent args = (SelectFaultItemEvent)e;
- //Debug.Log($"{args.faultType} {currentList[currentStepIndex].faultType}");
- if (args.faultType == currentList[currentStepIndex].faultType)
- {
- if (currentList[currentStepIndex].timeLineEnd != -1)
- {
- currentPlayableDirector.Play();
- await Task.Delay((int)(currentList[currentStepIndex].timeLineEnd - currentList[currentStepIndex].timeLineStart) * 1000);
- currentPlayableDirector.Pause();
- }
- currentStepIndex++;
- if (currentStepIndex >= stepCount)
- {
- //todo 完成
- }
- else
- {
- //todo nextStep
- currentPlayableDirector.time = currentList[currentStepIndex].timeLineStart;
- currentPlayableDirector.Play();
- await Task.Delay(50);
- currentPlayableDirector.Pause();
- Debug.Log($"{currentType} {currentStepIndex}");
- GameMain.Event.Fire(this, IT_FaultNextEvent.Create(currentType, currentStepIndex));
- }
- }
- }
- }
- }
|