AppTrainStudyForm.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using DG.Tweening;
  5. using GameFramework;
  6. using GameFramework.Event;
  7. using UnityEngine;
  8. using UnityEngine.SceneManagement;
  9. using UnityEngine.Serialization;
  10. using UnityEngine.UI;
  11. using UnityGameFramework.Runtime;
  12. public class AppTrainStudyForm : UIFormLogic
  13. {
  14. private GameObject _trainPanel;
  15. private GameObject _learnPanel;
  16. private GameObject _faultPanel;
  17. private GameObject _trainDoneTips;
  18. private GameObject _faultDoneTips;
  19. private Button _reStartButton;
  20. public Sprite[] learnModelButtonImg;
  21. public Sprite[] trainModelButtonImg;
  22. public Sprite[] bugModelButtonImg;
  23. private Button _learnButton;
  24. private Button _trainButton;
  25. private Button _faultButton;
  26. private IT_TrainModelType _currentType;
  27. private GameObject messagePanel;
  28. private Text nameText;
  29. private Text messageText;
  30. //todo App认知的文字
  31. private const string GSEMessage =
  32. "GSE作为管控平台,集成监控、调度与自动化,提供全方位系统管理,确保系统组件协同高效运行。通过智能调度和资源优化,实现高性能、稳定性和可扩展性的系统运维。";
  33. private const string CMDBMessage =
  34. "CMDB是配置管理数据库,详细记录系统组件配置信息,支持实时状态监测和智能配置管理。通过构建组件之间的关系图,实现对整个系统配置的清晰可视化,提供数据支持系统稳定性和可靠性。";
  35. private const string JobMessage =
  36. "Job作为作业平台,提供作业任务的调度和执行服务。通过灵活的调度策略,实现系统作业的自动化管理,优化任务执行效率,确保系统作业的高效执行和调度。";
  37. private const string PaaSMessage =
  38. "PaaS是集成平台,提供全套的开发、部署和运行平台。通过集成开发工具、服务和运行环境,简化应用程序的构建和管理,支持快速应用开发、测试和上线,推动业务创新。";
  39. private const string BKDataMessage =
  40. "BKData是大数据平台,专注于大规模数据处理与分析。提供高性能的数据存储和处理引擎,支持数据驱动决策,为企业提供强大的数据处理和分析能力。";
  41. private const string ApptSaaSMessage =
  42. "ApptSaaS为Saas应用提供专用测试环境,用于验证应用功能、性能和稳定性。通过模拟真实场景和大规模用户负载,确保Saas应用在发布前经过全面、严格的测试。";
  43. private const string AppoSaaSMessage =
  44. "AppoSaaS是Saas应用的正式生产环境,提供高可用、稳定和安全的服务。通过灵活的扩展性和自动化运维,确保用户在任何时间都能正常、高效地使用Saas应用。";
  45. private const string LicenseMessage =
  46. "License管理模块用于管理软件许可证和用户权限。通过严格的许可证管理,确保软件合法使用,同时支持许可证的分发、监控和维护。";
  47. private const string NginxWebMessage =
  48. "NginxWeb是高性能的Web服务器和反向代理,用于处理HTTP请求。支持负载均衡、反向代理和静态文件服务,提供快速、可靠的Web服务。";
  49. private const string MySQLMessage =
  50. "MySQL是开源的关系型数据库管理系统,用于存储和检索结构化数据。通过支持事务处理和复杂查询,提供稳定可靠的数据库服务。";
  51. private const string RedisMessage =
  52. "Redis是高性能的内存数据库,用于快速数据存储和检索。支持多种数据结构,适用于缓存、消息队列和实时数据处理等场景。";
  53. private const string ZookeeperMessage =
  54. "Zookeeper提供分布式系统协调服务,管理配置信息和分布式锁,确保系统的一致性和可用性。通过提供高度可靠的分布式协调支持,为复杂系统的协同运行提供基础。";
  55. private const string MongoDBMessage =
  56. "MongoDB是非关系型数据库管理系统,支持灵活的文档存储。适用于大数据和实时应用场景,提供高效、可扩展的数据库服务。";
  57. private const string RabbitMQMessage =
  58. "RabbitMQ是开源的消息队列系统,用于实现应用程序间的异步通信。支持事件驱动架构,提高系统的松耦合性和可扩展性。";
  59. private const string InfluxDBMessage =
  60. "InfluxDB是专注于时序数据的数据库,适用于监控和IoT场景。提供高效的时序数据存储和查询,满足大规模时序数据分析的需求。";
  61. private const string VirtualenvMessage =
  62. "Virtualenv是用于创建和管理Python虚拟环境的工具。通过实现项目隔离和依赖管理,提供灵活的Python环境支持。";
  63. private const string DockerMessage =
  64. "Docker提供容器化解决方案,封装应用及其依赖项,实现跨平台和快速部署。通过容器化技术,简化应用程序的开发、测试和部署流程,提高系统的灵活性和可移植性。";
  65. bool haveFixed = false;
  66. private GameObject tarinList;
  67. private Button trainB1;
  68. private Button trainB2;
  69. private GameObject faultList;
  70. //$$$
  71. public Button[] faultButtons;
  72. public GameObject faultChoicePanel;
  73. public GameObject[] faultChoices;
  74. protected override void OnInit(object userData)
  75. {
  76. base.OnInit(userData);
  77. _trainPanel = this.transform.Find("trainPanel").gameObject;
  78. _learnPanel = this.transform.Find("learnPanel").gameObject;
  79. _faultPanel = this.transform.Find("faultPanel").gameObject;
  80. InItUiComponent();
  81. }
  82. protected override void OnOpen(object userData)
  83. {
  84. base.OnOpen(userData);
  85. _trainDoneTips.SetActive(false);
  86. GameMain.Event.Subscribe(App_TrainStudyShowTargetInfoEvent.EventId,ChangeTargetMessage);
  87. _learnPanel.SetActive(true);
  88. _trainPanel.SetActive(false);
  89. _learnButton.image.sprite = learnModelButtonImg[1];
  90. _trainButton.image.sprite = trainModelButtonImg[0];
  91. _faultButton.image.sprite = bugModelButtonImg[0];
  92. ChangeToLearn(true,0.1f);
  93. tarinList.SetActive(false);
  94. //_currentType = IT_TrainModelType.learn;
  95. //GameMain.Event.Fire(this,IT_StartLearnTargetInfoEvent.Create());
  96. }
  97. protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
  98. {
  99. base.OnUpdate(elapseSeconds, realElapseSeconds);
  100. }
  101. private void InItUiComponent()
  102. {
  103. _trainDoneTips = _trainPanel.transform.Find("DoneTips").gameObject;
  104. _trainDoneTips.SetActive(false);
  105. messagePanel = _learnPanel.transform.Find("messagePanel").gameObject;
  106. messagePanel.SetActive(false);
  107. nameText = messagePanel.transform.Find("nameText").GetComponent<Text>();
  108. messageText = messagePanel.transform.Find("messageText").GetComponent<Text>();
  109. _faultDoneTips = _faultPanel.transform.Find("DoneTips").gameObject;
  110. _faultDoneTips.SetActive(false);
  111. _faultPanel.SetActive(false);
  112. _reStartButton = _trainPanel.transform.Find("TrainButton/Verlist/reStartButton").GetComponent<Button>();
  113. _reStartButton.onClick.AddListener(() =>
  114. {
  115. GameMain.Event.Fire(this,ReStart_IT_TrainStudyEvent.Create());
  116. });
  117. _learnButton = this.transform.Find("Navi/B1").GetComponent<Button>();
  118. _learnButton.onClick.AddListener(()=> {
  119. ChangeToLearn(true,0.1f);
  120. });
  121. _trainButton = this.transform.Find("Navi/B2").GetComponent<Button>();
  122. _trainButton.onClick.AddListener(ChangeToTrain);
  123. _faultButton = this.transform.Find("Navi/B3").GetComponent<Button>();
  124. _faultButton.onClick.AddListener(()=>
  125. {
  126. ChangeToFault();
  127. });
  128. tarinList = this.transform.Find("Navi/trainlist").gameObject;
  129. trainB1 = this.transform.Find("Navi/trainlist/B1").GetComponent<Button>();
  130. trainB2 = this.transform.Find("Navi/trainlist/B2").GetComponent<Button>();
  131. trainB1.onClick.AddListener(() =>
  132. {
  133. GameMain.Event.Fire(this,App_TrainAniEvent.Create(1));
  134. tarinList.SetActive(false);
  135. });
  136. trainB2.onClick.AddListener(() =>
  137. {
  138. GameMain.Event.Fire(this, App_TrainAniEvent.Create(2));
  139. tarinList.SetActive(false);
  140. });
  141. faultList = this.transform.Find("Navi/faultlist").gameObject;
  142. //$$$------------------------
  143. faultChoicePanel = this.transform.Find($"faultChoicePanel").gameObject;
  144. faultChoices = new GameObject[10];
  145. for (int i = 0; i < 10; i++)
  146. {
  147. faultChoices[i] = this.transform.Find($"faultChoicePanel/BG/Quest_{i + 1}").gameObject;
  148. faultChoices[i].SetActive(false);
  149. }
  150. faultChoicePanel.SetActive(false);
  151. faultButtons = new Button[10];
  152. for (int i = 0; i < 10; i++)
  153. {
  154. faultButtons[i] = this.transform.Find($"Navi/faultlist/B{i + 1}").GetComponent<Button>();
  155. }
  156. faultButtons[0].onClick.AddListener(() => { faultChoicesClick(0); });
  157. faultButtons[1].onClick.AddListener(() => { faultChoicesClick(1); });
  158. faultButtons[2].onClick.AddListener(() => { faultChoicesClick(2); });
  159. faultButtons[3].onClick.AddListener(() => { faultChoicesClick(3); });
  160. faultButtons[4].onClick.AddListener(() => { faultChoicesClick(4); });
  161. faultButtons[5].onClick.AddListener(() => { faultChoicesClick(5); });
  162. faultButtons[6].onClick.AddListener(() => { faultChoicesClick(6); });
  163. faultButtons[7].onClick.AddListener(() => { faultChoicesClick(7); });
  164. faultButtons[8].onClick.AddListener(() => { faultChoicesClick(8); });
  165. faultButtons[9].onClick.AddListener(() => { faultChoicesClick(9); });
  166. faultChoicePanel.SetActive(false);
  167. //$$$------------------------
  168. tarinList.SetActive(false);
  169. }
  170. //$$$------------------------
  171. private void faultChoicesClick(int index)
  172. {
  173. foreach (var objs in faultChoices)
  174. {
  175. objs.SetActive(false);
  176. }
  177. GameMain.Event.Fire(this, FaultChoicesChangeEvent.Create(index));
  178. faultChoices[index].SetActive(true);
  179. faultChoicePanel.SetActive(true);
  180. faultList.SetActive(false);
  181. }
  182. protected override void OnClose(bool isShutdown, object userData)
  183. {
  184. base.OnClose(isShutdown, userData);
  185. GameMain.Event.Unsubscribe(App_TrainStudyShowTargetInfoEvent.EventId,ChangeTargetMessage);
  186. }
  187. private async void ChangeToLearn(bool force = false,float delayTime = 0.0f)
  188. {
  189. if(_currentType==IT_TrainModelType.learn && !force)
  190. return;
  191. if (SceneManager.GetActiveScene().name != "TrainStudy6")
  192. SceneManager.LoadScene("TrainStudy6");
  193. tarinList.SetActive(false);
  194. await Task.Delay((int)(delayTime * 1000));
  195. GameMain.Event.Fire(this,App_TrainStudyStateEvent.Create(false));
  196. GameMain.Event.Fire(this,App_StartLearnTargetInfoEvent.Create());
  197. _currentType = IT_TrainModelType.learn;
  198. _learnButton.image.sprite = learnModelButtonImg[1];
  199. _trainButton.image.sprite = trainModelButtonImg[0];
  200. _faultButton.image.sprite = bugModelButtonImg[0];
  201. _trainPanel.SetActive(false);
  202. _learnPanel.SetActive(true);
  203. _faultPanel.SetActive(false);
  204. tarinList.SetActive(false);
  205. //$$$------------------------
  206. faultChoicePanel.SetActive(false);
  207. }
  208. private void ChangeToTrain()
  209. {
  210. faultList.SetActive(false);
  211. tarinList.SetActive(true);
  212. if(_currentType==IT_TrainModelType.train)
  213. return;
  214. _learnPanel.SetActive(false);
  215. _faultPanel.SetActive(false);
  216. _learnButton.image.sprite = learnModelButtonImg[0];
  217. _trainButton.image.sprite = trainModelButtonImg[1];
  218. _faultButton.image.sprite = bugModelButtonImg[0];
  219. _currentType = IT_TrainModelType.train;
  220. if (SceneManager.GetActiveScene().name != "TrainStudy6_1")
  221. SceneManager.LoadScene("TrainStudy6_1");
  222. //_trainPanel.SetActive(true);
  223. //$$$------------------------
  224. faultChoicePanel.SetActive(false);
  225. }
  226. private void ChangeToFault(bool force = false)
  227. {
  228. tarinList.SetActive(false);
  229. faultList.SetActive(true);
  230. GameMain.Event.Fire(this, Cool_TrainStudyStateEvent.Create(false));
  231. GameMain.Event.Fire(this, Cool_StartLearnTargetInfoEvent.Create(false));
  232. _learnButton.image.sprite = learnModelButtonImg[0];
  233. _trainButton.image.sprite = trainModelButtonImg[0];
  234. _faultButton.image.sprite = bugModelButtonImg[1];
  235. _faultPanel.SetActive(true);
  236. _trainPanel.SetActive(false);
  237. _learnPanel.SetActive(false);
  238. _currentType = IT_TrainModelType.fault;
  239. _faultPanel.transform.Find($"Doc").gameObject.SetActive(false);
  240. _faultPanel.transform.Find($"FixButton").gameObject.SetActive(false);
  241. _faultPanel.transform.Find($"Tools").GetComponent<RectTransform>().localPosition = new Vector3(1120, 0, 0);
  242. if (SceneManager.GetActiveScene().name != "TrainStudy6_2" || force)
  243. SceneManager.LoadScene("TrainStudy6_2");
  244. //$$$------------------------
  245. faultChoicePanel.SetActive(false);
  246. }
  247. private void ChangeTargetMessage(object sender,GameEventArgs e)
  248. {
  249. App_TrainStudyShowTargetInfoEvent args = (App_TrainStudyShowTargetInfoEvent)e;
  250. switch (args._Type)
  251. {
  252. case AppHardWaryType.GSE:
  253. nameText.text = "GSE 管控平台";
  254. messageText.text = GSEMessage;
  255. if (!messagePanel.activeSelf)
  256. {
  257. messagePanel.SetActive(true);
  258. }
  259. break;
  260. case AppHardWaryType.CMDB:
  261. nameText.text = "CMDB配置平台";
  262. messageText.text = CMDBMessage;
  263. if (!messagePanel.activeSelf)
  264. {
  265. messagePanel.SetActive(true);
  266. }
  267. break;
  268. case AppHardWaryType.Job:
  269. nameText.text = "Job作业平台";
  270. messageText.text = JobMessage;
  271. if (!messagePanel.activeSelf)
  272. {
  273. messagePanel.SetActive(true);
  274. }
  275. break;
  276. case AppHardWaryType.PaaS:
  277. nameText.text = "PaaS集成平台";
  278. messageText.text = PaaSMessage;
  279. if (!messagePanel.activeSelf)
  280. {
  281. messagePanel.SetActive(true);
  282. }
  283. break;
  284. case AppHardWaryType.BKData:
  285. nameText.text = "BKData数据平台";
  286. messageText.text = BKDataMessage;
  287. if (!messagePanel.activeSelf)
  288. {
  289. messagePanel.SetActive(true);
  290. }
  291. break;
  292. case AppHardWaryType.ApptSaaS:
  293. nameText.text = "ApptSaaS测试环境";
  294. messageText.text = ApptSaaSMessage;
  295. if (!messagePanel.activeSelf)
  296. {
  297. messagePanel.SetActive(true);
  298. }
  299. break;
  300. case AppHardWaryType.AppoSaaS:
  301. nameText.text = "AppoSaaS正式环境";
  302. messageText.text = AppoSaaSMessage;
  303. if (!messagePanel.activeSelf)
  304. {
  305. messagePanel.SetActive(true);
  306. }
  307. break;
  308. case AppHardWaryType.License:
  309. nameText.text = "License许可";
  310. messageText.text = LicenseMessage;
  311. if (!messagePanel.activeSelf)
  312. {
  313. messagePanel.SetActive(true);
  314. }
  315. break;
  316. case AppHardWaryType.NginxWeb:
  317. nameText.text = "NginxWeb服务器";
  318. messageText.text = NginxWebMessage;
  319. if (!messagePanel.activeSelf)
  320. {
  321. messagePanel.SetActive(true);
  322. }
  323. break;
  324. case AppHardWaryType.MySQL:
  325. nameText.text = "MySQL关系型数据库";
  326. messageText.text = MySQLMessage;
  327. if (!messagePanel.activeSelf)
  328. {
  329. messagePanel.SetActive(true);
  330. }
  331. break;
  332. case AppHardWaryType.Redis:
  333. nameText.text = "Redis内存数据库";
  334. messageText.text = RedisMessage;
  335. if (!messagePanel.activeSelf)
  336. {
  337. messagePanel.SetActive(true);
  338. }
  339. break;
  340. case AppHardWaryType.Zookeeper:
  341. nameText.text = "Zookeeper分布式应用程序协调服务";
  342. messageText.text = ZookeeperMessage;
  343. if (!messagePanel.activeSelf)
  344. {
  345. messagePanel.SetActive(true);
  346. }
  347. break;
  348. case AppHardWaryType.MongoDB:
  349. nameText.text = "MongoDB非关系型数据库";
  350. messageText.text = MongoDBMessage;
  351. if (!messagePanel.activeSelf)
  352. {
  353. messagePanel.SetActive(true);
  354. }
  355. break;
  356. case AppHardWaryType.RabbitMQ:
  357. nameText.text = "RabbitMQ消息队列";
  358. messageText.text = RabbitMQMessage;
  359. if (!messagePanel.activeSelf)
  360. {
  361. messagePanel.SetActive(true);
  362. }
  363. break;
  364. case AppHardWaryType.InfluxDB:
  365. nameText.text = "InfluxDB时序型数据库";
  366. messageText.text = InfluxDBMessage;
  367. if (!messagePanel.activeSelf)
  368. {
  369. messagePanel.SetActive(true);
  370. }
  371. break;
  372. case AppHardWaryType.Virtualenv:
  373. nameText.text = "Virtualenv虚拟环境";
  374. messageText.text = VirtualenvMessage;
  375. if (!messagePanel.activeSelf)
  376. {
  377. messagePanel.SetActive(true);
  378. }
  379. break;
  380. case AppHardWaryType.Docker:
  381. nameText.text = "Docker虚拟环境";
  382. messageText.text = DockerMessage;
  383. if (!messagePanel.activeSelf)
  384. {
  385. messagePanel.SetActive(true);
  386. }
  387. break;
  388. case AppHardWaryType.none:
  389. messagePanel.SetActive(false);
  390. break;
  391. }
  392. }
  393. private void ReSetTrainUI(object sender,GameEventArgs e)
  394. {
  395. _trainDoneTips.SetActive(false);
  396. }
  397. private void OnIT_TrainStudyDone(object sender, GameEventArgs e)
  398. {
  399. _trainDoneTips.SetActive(true);
  400. //GameMain.UI.OpenUIForm("Tips", "Pop");
  401. }
  402. }