123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using DG.Tweening;
- using GameFramework;
- using GameFramework.Event;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.Serialization;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- public class CoolTrainStudyForm : UIFormLogic
- {
- private GameObject _trainPanel;
- private GameObject _learnPanel;
- private GameObject _faultPanel;
- private GameObject _trainDoneTips;
- private GameObject _faultDoneTips;
- private Button _reStartButton;
- public Sprite[] learnModelButtonImg;
- public Sprite[] trainModelButtonImg;
- public Sprite[] bugModelButtonImg;
- private Button _learnButton;
- private Button _trainButton;
- private Button _faultButton;
- private IT_TrainModelType _currentType;
- private GameObject messagePanel;
- private Text nameText;
- private Text messageText;
- private const string CoolingTowerMessage =
- "冷却水塔是用于散热的关键组件。它将通过冷却机组循环的热水暴露在空气中,通过蒸发的方式带走热量,将冷却水重新供应给机组。这样可以有效地降低冷却水的温度。";
- private const string ChilledWaterPumpMessage =
- "冷水泵负责将冷却水从冷却水塔输送到制冷设备(例如精密空调或冷却卷管系统)中。这确保了冷却水能够流经整个系统,吸收热量,并将其带回冷却水塔进行散热。";
- private const string BufferTankMessage =
- "蓄冷罐用于存储额外的冷却水,并平衡系统中的水流。它可以帮助调整水循环系统中的压力和流速,并提供一个冷却水的储备。";
- private const string PrecisionAirConditionerMessage =
- "精密空调是一种用于维持恒定温湿度的设备。在水冷机组中,精密空调通常用于冷却机房或其他对温湿度要求较高的场所。它通过冷却水循环来调节室内温度。";
- private const string CompressorMessage =
- "压缩机是水冷机组中的核心组件,负责将低温、低压的蒸发冷媒气体压缩成高温、高压的气体。这个过程使冷媒能够释放吸收的热量,从而实现制冷效果。";
- private const string CoolingUnitControlMessage =
- "冷却机组控制系统监测和控制整个水冷机组的运行。它通常包括温度、湿度、压力等传感器,以及自动控制系统,确保系统以最佳方式运行,提供稳定的制冷效果。";
- bool haveFixed = false;
- private GameObject tarinList;
- private Button trainB1;
- private Button trainB2;
- private Button trainB3;
- private Button trainB4;
- private Button trainB5;
- private GameObject faultList;
- private Button faultB1;
- private Button faultB2;
- private Button faultB3;
- //$$$
- public Button[] faultButtons;
- public GameObject faultChoicePanel;
- public GameObject[] faultChoices;
- public GameObject[] highPressureFaultTips;
- public GameObject[] lowPressureFaultTips;
- public GameObject[] fault3Tips;
- private RectTransform faultTools;
- private GameObject faultSelectButtons;
- private Cool_FaultToolList faultToolList;
- private Button sbButton;
- private Button ysjButton;
- private Button qlysjButton;
- private Button lmButton;
- protected override void OnInit(object userData)
- {
- base.OnInit(userData);
- _trainPanel = this.transform.Find("trainPanel").gameObject;
- _learnPanel = this.transform.Find("learnPanel").gameObject;
- _faultPanel = this.transform.Find("faultPanel").gameObject;
- InItUiComponent();
- InitFaultTips();
- }
- protected override void OnOpen(object userData)
- {
- base.OnOpen(userData);
- _trainDoneTips.SetActive(false);
- GameMain.Event.Subscribe(ReStart_IT_TrainStudyEvent.EventId, ReSetTrainUI);
- GameMain.Event.Subscribe(IT_TrainStudyDoneEvent.EventId, OnIT_TrainStudyDone);
- GameMain.Event.Subscribe(Cool_TrainStudyShowTargetInfoEvent.EventId, ChangeTargetMessage);
- GameMain.Event.Subscribe(Cool_FaultNextEvent.EventId, OnGetCool_FaultNext);
- _learnPanel.SetActive(true);
- _trainPanel.SetActive(false);
- _learnButton.image.sprite = learnModelButtonImg[1];
- _trainButton.image.sprite = trainModelButtonImg[0];
- _faultButton.image.sprite = bugModelButtonImg[0];
- ChangeToLearn(true, 0.1f);
- tarinList.SetActive(false);
- //_currentType = IT_TrainModelType.learn;
- //GameMain.Event.Fire(this,IT_StartLearnTargetInfoEvent.Create());
- }
- protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- {
- base.OnUpdate(elapseSeconds, realElapseSeconds);
- }
- private void InItUiComponent()
- {
- _trainDoneTips = _trainPanel.transform.Find("DoneTips").gameObject;
- _trainDoneTips.SetActive(false);
- messagePanel = _learnPanel.transform.Find("messagePanel").gameObject;
- messagePanel.SetActive(false);
- nameText = messagePanel.transform.Find("nameText").GetComponent<Text>();
- messageText = messagePanel.transform.Find("messageText").GetComponent<Text>();
- _faultDoneTips = _faultPanel.transform.Find("DoneTips").gameObject;
- _faultDoneTips.SetActive(false);
- _faultPanel.SetActive(false);
- _reStartButton = _trainPanel.transform.Find("TrainButton/Verlist/reStartButton").GetComponent<Button>();
- _reStartButton.onClick.AddListener(() => { GameMain.Event.Fire(this, ReStart_IT_TrainStudyEvent.Create()); });
- _learnButton = this.transform.Find("Navi/B1").GetComponent<Button>();
- _learnButton.onClick.AddListener(() => { ChangeToLearn(true, 0.1f); });
- _trainButton = this.transform.Find("Navi/B2").GetComponent<Button>();
- _trainButton.onClick.AddListener(ChangeToTrain);
- _faultButton = this.transform.Find("Navi/B3").GetComponent<Button>();
- _faultButton.onClick.AddListener(() => { ChangeToFault(); });
- tarinList = this.transform.Find("Navi/trainlist").gameObject;
- trainB1 = this.transform.Find("Navi/trainlist/B1").GetComponent<Button>();
- trainB2 = this.transform.Find("Navi/trainlist/B2").GetComponent<Button>();
- trainB3 = this.transform.Find("Navi/trainlist/B3").GetComponent<Button>();
- trainB4 = this.transform.Find("Navi/trainlist/B4").GetComponent<Button>();
- trainB5 = this.transform.Find("Navi/trainlist/B5").GetComponent<Button>();
- trainB1.onClick.AddListener(() =>
- {
- GameMain.Event.Fire(this, Cool_TrainAniEvent.Create(1));
- tarinList.SetActive(false);
- });
- trainB2.onClick.AddListener(() =>
- {
- GameMain.Event.Fire(this, Cool_TrainAniEvent.Create(2));
- tarinList.SetActive(false);
- });
- trainB3.onClick.AddListener(() =>
- {
- GameMain.Event.Fire(this, Cool_TrainAniEvent.Create(3));
- tarinList.SetActive(false);
- });
- trainB4.onClick.AddListener(() =>
- {
- GameMain.Event.Fire(this, Cool_TrainAniEvent.Create(4));
- tarinList.SetActive(false);
- });
- trainB5.onClick.AddListener(() =>
- {
- GameMain.Event.Fire(this, Cool_TrainAniEvent.Create(5));
- tarinList.SetActive(false);
- });
- tarinList.SetActive(false);
- faultList = this.transform.Find("Navi/faultlist").gameObject;
- faultB1 = this.transform.Find("Navi/faultlist/B1").GetComponent<Button>();
- faultB2 = this.transform.Find("Navi/faultlist/B2").GetComponent<Button>();
- faultB3 = this.transform.Find("Navi/faultlist/B3").GetComponent<Button>();
- faultB1.onClick.AddListener(() =>
- {
- foreach (var objs in faultChoices)
- {
- objs.SetActive(false);
- }
- faultChoicePanel.SetActive(false);
- GameMain.Event.Fire(this, FaultChoicesChangeEvent.Create(-1));
- GameMain.Event.Fire(this, Cool_FaultStartEvent.Create(Cool_FaultType.highPressure));
- faultList.SetActive(false);
- });
- faultB2.onClick.AddListener(() =>
- {
- foreach (var objs in faultChoices)
- {
- objs.SetActive(false);
- }
- faultChoicePanel.SetActive(false);
- GameMain.Event.Fire(this, FaultChoicesChangeEvent.Create(-1));
- GameMain.Event.Fire(this, Cool_FaultStartEvent.Create(Cool_FaultType.lowPressure));
- faultList.SetActive(false);
- });
- faultB3.onClick.AddListener(() =>
- {
- foreach (var objs in faultChoices)
- {
- objs.SetActive(false);
- }
- faultChoicePanel.SetActive(false);
- GameMain.Event.Fire(this, FaultChoicesChangeEvent.Create(-1));
- GameMain.Event.Fire(this, Cool_FaultStartEvent.Create(Cool_FaultType.pumpError));
- faultList.SetActive(false);
- });
- //$$$------------------------
- faultChoicePanel = this.transform.Find($"faultChoicePanel").gameObject;
- faultChoices = new GameObject[8];
- for (int i = 0; i < 8; i++)
- {
- faultChoices[i] = this.transform.Find($"faultChoicePanel/BG/Quest_{i + 1}").gameObject;
- faultChoices[i].SetActive(false);
- }
- faultChoicePanel.SetActive(false);
- faultButtons = new Button[7];
- for (int i = 0; i < 7; i++)
- {
- faultButtons[i] = this.transform.Find($"Navi/faultlist/B{i + 4}").GetComponent<Button>();
- }
- faultButtons[0].onClick.AddListener(() => { faultChoicesClick(0); });
- faultButtons[1].onClick.AddListener(() => { faultChoicesClick(1); });
- faultButtons[2].onClick.AddListener(() => { faultChoicesClick(2); });
- faultButtons[3].onClick.AddListener(() => { faultChoicesClick(3); });
- faultButtons[4].onClick.AddListener(() => { faultChoicesClick(4); });
- faultButtons[5].onClick.AddListener(() => { faultChoicesClick(5); });
- faultButtons[6].onClick.AddListener(() => { faultChoicesClick(6); });
- faultChoicePanel.SetActive(false);
- //$$$------------------------
- faultList.SetActive(false);
- }
- //$$$------------------------
- private void faultChoicesClick(int index)
- {
- foreach (var obj in highPressureFaultTips)
- {
- obj.SetActive(false);
- }
- foreach (var obj in lowPressureFaultTips)
- {
- obj.SetActive(false);
- }
- foreach (var obj in fault3Tips)
- {
- obj.SetActive(false);
- }
- faultList.SetActive(false);
- foreach (var objs in faultChoices)
- {
- objs.SetActive(false);
- }
- GameMain.Event.Fire(this, FaultChoicesChangeEvent.Create(index));
- faultChoices[index].SetActive(true);
- faultChoicePanel.SetActive(true);
- faultList.SetActive(false);
- }
- private void InitFaultTips()
- {
- highPressureFaultTips = new GameObject[4];
- for (int i = 0; i < highPressureFaultTips.Length; i++)
- {
- highPressureFaultTips[i] = _faultPanel.transform.Find($"Doc/BG/Step1_{i}").gameObject;
- highPressureFaultTips[i].SetActive(false);
- }
- lowPressureFaultTips = new GameObject[4];
- for (int i = 0; i < lowPressureFaultTips.Length; i++)
- {
- lowPressureFaultTips[i] = _faultPanel.transform.Find($"Doc/BG/Step2_{i}").gameObject;
- lowPressureFaultTips[i].SetActive(false);
- }
- fault3Tips = new GameObject[6];
- for (int i = 0; i < fault3Tips.Length; i++)
- {
- fault3Tips[i] = _faultPanel.transform.Find($"Doc/BG/Step3_{i}").gameObject;
- fault3Tips[i].SetActive(false);
- }
- faultTools = _faultPanel.transform.Find($"Tools").GetComponent<RectTransform>();
- faultTools.localPosition = new Vector3(1120, 0, 0);
- faultSelectButtons = _faultPanel.transform.Find($"FixButton").gameObject;
- sbButton = _faultPanel.transform.Find("FixButton/Verlist/sbButton").GetComponent<Button>();
- ysjButton = _faultPanel.transform.Find("FixButton/Verlist/ysjButton").GetComponent<Button>();
- qlysjButton = _faultPanel.transform.Find("FixButton/Verlist/qlysjButton").GetComponent<Button>();
- lmButton = _faultPanel.transform.Find("FixButton/Verlist/lmButton").GetComponent<Button>();
- sbButton.onClick.AddListener(() => { GameMain.Event.Fire(this, Cool_SelectFaultItemEvent.Create(Cool_FaultType.pumpError)); });
- ysjButton.onClick.AddListener(() => { GameMain.Event.Fire(this, Cool_SelectFaultItemEvent.Create(Cool_FaultType.airConditioning)); });
- qlysjButton.onClick.AddListener(() => { GameMain.Event.Fire(this, Cool_SelectFaultItemEvent.Create(Cool_FaultType.highPressure)); });
- lmButton.onClick.AddListener(() => { GameMain.Event.Fire(this, Cool_SelectFaultItemEvent.Create(Cool_FaultType.lowPressure)); });
- faultSelectButtons.SetActive(false);
- faultToolList = faultTools.GetComponent<Cool_FaultToolList>();
- }
- protected override void OnClose(bool isShutdown, object userData)
- {
- base.OnClose(isShutdown, userData);
- GameMain.Event.Unsubscribe(ReStart_IT_TrainStudyEvent.EventId, ReSetTrainUI);
- GameMain.Event.Unsubscribe(IT_TrainStudyDoneEvent.EventId, OnIT_TrainStudyDone);
- GameMain.Event.Unsubscribe(Cool_TrainStudyShowTargetInfoEvent.EventId, ChangeTargetMessage);
- GameMain.Event.Unsubscribe(Cool_FaultNextEvent.EventId, OnGetCool_FaultNext);
- }
- private async void ChangeToLearn(bool force = false, float delayTime = 0.0f)
- {
- tarinList.SetActive(false);
- _faultDoneTips.SetActive(false);
- faultList.SetActive(false);
- if (_currentType == IT_TrainModelType.learn && !force)
- return;
- if (SceneManager.GetActiveScene().name != "TrainStudy3_1")
- SceneManager.LoadScene("TrainStudy3_1");
- await Task.Delay((int)(delayTime * 1000));
- GameMain.Event.Fire(this, Cool_TrainStudyStateEvent.Create(false));
- GameMain.Event.Fire(this, Cool_StartLearnTargetInfoEvent.Create());
- _currentType = IT_TrainModelType.learn;
- _learnButton.image.sprite = learnModelButtonImg[1];
- _trainButton.image.sprite = trainModelButtonImg[0];
- _faultButton.image.sprite = bugModelButtonImg[0];
- _trainPanel.SetActive(false);
- _learnPanel.SetActive(true);
- _faultPanel.SetActive(false);
- tarinList.SetActive(false);
- //$$$------------------------
- faultChoicePanel.SetActive(false);
- }
- private void ChangeToTrain()
- {
- faultList.SetActive(false);
- tarinList.SetActive(true);
- if (_currentType == IT_TrainModelType.train)
- return;
- _learnPanel.SetActive(false);
- _faultPanel.SetActive(false);
- _learnButton.image.sprite = learnModelButtonImg[0];
- _trainButton.image.sprite = trainModelButtonImg[1];
- _faultButton.image.sprite = bugModelButtonImg[0];
- _currentType = IT_TrainModelType.train;
- if (SceneManager.GetActiveScene().name != "TrainStudy3")
- SceneManager.LoadScene("TrainStudy3");
- //_trainPanel.SetActive(true);
- //$$$------------------------
- faultChoicePanel.SetActive(false);
- }
- private void ChangeToFault(bool force = false)
- {
- tarinList.SetActive(false);
- faultList.SetActive(true);
- if (_currentType == IT_TrainModelType.fault && !force)
- return;
- GameMain.Event.Fire(this, Cool_TrainStudyStateEvent.Create(false));
- GameMain.Event.Fire(this, Cool_StartLearnTargetInfoEvent.Create(false));
- _learnButton.image.sprite = learnModelButtonImg[0];
- _trainButton.image.sprite = trainModelButtonImg[0];
- _faultButton.image.sprite = bugModelButtonImg[1];
- _faultPanel.SetActive(true);
- _trainPanel.SetActive(false);
- _learnPanel.SetActive(false);
- _currentType = IT_TrainModelType.fault;
- _faultPanel.transform.Find($"Doc").gameObject.SetActive(false);
- _faultPanel.transform.Find($"FixButton").gameObject.SetActive(false);
- _faultPanel.transform.Find($"Tools").GetComponent<RectTransform>().localPosition = new Vector3(1120, 0, 0);
- if (SceneManager.GetActiveScene().name != "TrainStudy3_2" || force)
- SceneManager.LoadScene("TrainStudy3_2");
- //$$$------------------------
- faultChoicePanel.SetActive(false);
- }
- private void ChangeTargetMessage(object sender, GameEventArgs e)
- {
- Cool_TrainStudyShowTargetInfoEvent args = (Cool_TrainStudyShowTargetInfoEvent)e;
- switch (args._Type)
- {
- case CoolHardWaryType.CoolingTower:
- nameText.text = "冷却水塔";
- messageText.text = CoolingTowerMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.ChilledWaterPump:
- nameText.text = "冷水泵";
- messageText.text = ChilledWaterPumpMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.BufferTank:
- nameText.text = "蓄冷罐";
- messageText.text = BufferTankMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.PrecisionAirConditioner:
- nameText.text = "精密空调";
- messageText.text = PrecisionAirConditionerMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.Compressor:
- nameText.text = "压缩机";
- messageText.text = CompressorMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.CoolingUnitControl:
- nameText.text = "冷却机组控制";
- messageText.text = CoolingUnitControlMessage;
- if (!messagePanel.activeSelf)
- {
- messagePanel.SetActive(true);
- }
- break;
- case CoolHardWaryType.none:
- messagePanel.SetActive(false);
- break;
- }
- }
- private void ReSetTrainUI(object sender, GameEventArgs e)
- {
- _trainDoneTips.SetActive(false);
- }
- private void OnIT_TrainStudyDone(object sender, GameEventArgs e)
- {
- _faultDoneTips.SetActive(true);
- ChangeToFault(true);
- //GameMain.UI.OpenUIForm("Tips", "Pop");
- }
- private void OnGetCool_FaultNext(object sender, GameEventArgs e)
- {
- Cool_FaultNextEvent args = (Cool_FaultNextEvent)e;
- _faultPanel.transform.Find($"Doc").gameObject.SetActive(true);
- switch (args.FaultType)
- {
- case Cool_FaultType.highPressure:
- for (int i = 0; i < highPressureFaultTips.Length; i++)
- {
- highPressureFaultTips[i].SetActive(false);
- }
- highPressureFaultTips[args.stepIndex].SetActive(true);
- if (args.stepIndex == 0)
- {
- for (int i = 0; i < lowPressureFaultTips.Length; i++)
- {
- lowPressureFaultTips[i].SetActive(false);
- }
- for (int i = 0; i < fault3Tips.Length; i++)
- {
- fault3Tips[i].SetActive(false);
- }
- faultSelectButtons.SetActive(true);
- faultTools.localPosition = new Vector3(1120, 0, 0);
- faultToolList.ReSetToolList(1);
- }
- else
- {
- faultSelectButtons.SetActive(false);
- faultTools.localPosition = new Vector3(920, 0, 0);
- }
- break;
- case Cool_FaultType.lowPressure:
- for (int i = 0; i < lowPressureFaultTips.Length; i++)
- {
- lowPressureFaultTips[i].SetActive(false);
- }
- lowPressureFaultTips[args.stepIndex].SetActive(true);
- if (args.stepIndex == 0)
- {
- for (int i = 0; i < highPressureFaultTips.Length; i++)
- {
- highPressureFaultTips[i].SetActive(false);
- }
- for (int i = 0; i < fault3Tips.Length; i++)
- {
- fault3Tips[i].SetActive(false);
- }
- faultSelectButtons.SetActive(true);
- faultTools.localPosition = new Vector3(1120, 0, 0);
- faultToolList.ReSetToolList(0);
- }
- else
- {
- faultSelectButtons.SetActive(false);
- faultTools.localPosition = new Vector3(920, 0, 0);
- }
- break;
- case Cool_FaultType.pumpError:
- for (int i = 0; i < fault3Tips.Length; i++)
- {
- fault3Tips[i].SetActive(false);
- }
- fault3Tips[args.stepIndex].SetActive(true);
- if (args.stepIndex == 0)
- {
- for (int i = 0; i < highPressureFaultTips.Length; i++)
- {
- highPressureFaultTips[i].SetActive(false);
- }
- for (int i = 0; i < lowPressureFaultTips.Length; i++)
- {
- lowPressureFaultTips[i].SetActive(false);
- }
- faultSelectButtons.SetActive(true);
- faultTools.localPosition = new Vector3(1120, 0, 0);
- faultToolList.ReSetToolList(0);
- }
- else
- {
- faultSelectButtons.SetActive(false);
- faultTools.localPosition = new Vector3(920, 0, 0);
- }
- break;
- }
- }
- }
|