FaBaoDetailsPanel.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Core.Language;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using GameLogic.Bag;
  8. using GameLogic.Hero;
  9. using UnityEngine;
  10. using Utility;
  11. namespace Fort23.Mono
  12. {
  13. [UIBinding(prefab = "FaBaoDetailsPanel")]
  14. public partial class FaBaoDetailsPanel : UIPanel
  15. {
  16. List<FaBaoSkillWidget> faBaoSkillWidgets = new List<FaBaoSkillWidget>();
  17. List<ItemWidgetType1> itemWidgetType1s = new List<ItemWidgetType1>();
  18. List<FaBaoWidget> faBaoWidgets = new List<FaBaoWidget>();
  19. FaBaoWidget currentFaBaoWidget = null;
  20. FaBaoInfo currentFaBaoInfo;
  21. private ItemInfo _itemInfo;
  22. private bool isUpGrade = false;
  23. private List<FaBaoInfo> shownFaBaoInfos;
  24. private void Init()
  25. {
  26. IsShowAppBar = false;
  27. isAddStack = false;
  28. isPopUi = true;
  29. }
  30. protected override void AddEvent()
  31. {
  32. }
  33. protected override void DelEvent()
  34. {
  35. }
  36. public override CTask GetFocus()
  37. {
  38. // AppBarPanel.ClosePanel();
  39. return base.GetFocus();
  40. }
  41. public override void AddButtonEvent()
  42. {
  43. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  44. }
  45. public async void CustomInit(ItemInfo itemInfo)
  46. {
  47. _itemInfo = itemInfo;
  48. AccountFileInfo.FaBaoData faaData = new AccountFileInfo.FaBaoData();
  49. faaData.id = itemInfo.config.associateVlaue[1];
  50. faaData.level = 1;
  51. faaData.useIndex = -1;
  52. FaBaoInfo faBaoInfo = new FaBaoInfo(faaData);
  53. currentFaBaoInfo = faBaoInfo;
  54. UpdateFaBaoUI(faBaoInfo);
  55. }
  56. private async CTask UpdateFaBaoUI(FaBaoInfo faBaoInfo)
  57. {
  58. using (CTaskAwaitBuffer cts = new CTaskAwaitBuffer())
  59. {
  60. Text_Level.text = faBaoInfo.FabaoPowerupConfig.ID + "级";
  61. Text_FaBaoName.text = LanguageManager.Instance.Text(faBaoInfo.FabaoConfig.name);
  62. Text_Power.text = $"强度:{faBaoInfo.qiangDu}";
  63. Text_Desc.text = UtilTools.GetString(LanguageManager.Instance.Text(faBaoInfo.SkillConfig.dec),
  64. faBaoInfo.effectValue);
  65. Text_ItemDesc.text = LanguageManager.Instance.Text(_itemInfo.config.itemDesc);
  66. Icon_FaBaoIcon.icon_name = faBaoInfo.SkillConfig.icon;
  67. switch (faBaoInfo.FabaoConfig.magicAttribute)
  68. {
  69. case 1:
  70. Icon_Attribute.icon_name = "dec_jin";
  71. break;
  72. case 4:
  73. Icon_Attribute.icon_name = "dec_mu";
  74. break;
  75. case 2:
  76. Icon_Attribute.icon_name = "dec_shui";
  77. break;
  78. case 8:
  79. Icon_Attribute.icon_name = "dec_huo";
  80. break;
  81. case 16:
  82. Icon_Attribute.icon_name = "dec_tu";
  83. break;
  84. case 0:
  85. Icon_Attribute.icon_name = "dec_fuzhu2";
  86. break;
  87. }
  88. cts.AddTask(CreatFaBaoSkillWidget(faBaoInfo));
  89. cts.AddTask(CreatFaBaoAttributeWidget(faBaoInfo));
  90. await cts.WaitAll();
  91. }
  92. }
  93. private async CTask CreatFaBaoSkillWidget(FaBaoInfo faBaoInfo)
  94. {
  95. foreach (var faBaoSkillWidget in faBaoSkillWidgets)
  96. {
  97. UIManager.Instance.DormancyGComponent(faBaoSkillWidget);
  98. }
  99. faBaoSkillWidgets.Clear();
  100. List<FabaoPowerupConfig> fabaoPowerupConfigs =
  101. ConfigComponent.Instance.GetAll<FabaoPowerupConfig>().ToList();
  102. var fanappower = fabaoPowerupConfigs.GroupBy(f => f.SkillLevel)
  103. .Select(g => new { config = g.OrderBy(f => f.ID).FirstOrDefault() }).ToList();
  104. foreach (var powerupConfigse in fanappower)
  105. {
  106. if (powerupConfigse.config.ID == 1)
  107. {
  108. continue;
  109. }
  110. AccountFileInfo.FaBaoData faBaoData = new AccountFileInfo.FaBaoData();
  111. faBaoData.id = currentFaBaoInfo.FaBaoData.id;
  112. faBaoData.level = powerupConfigse.config.ID;
  113. FaBaoInfo _faBaoInfo = new FaBaoInfo(faBaoData);
  114. FaBaoSkillWidget faBaoSkillWidget =
  115. await UIManager.Instance.CreateGComponent<FaBaoSkillWidget>(null, SkillContent);
  116. faBaoSkillWidget.CustomInit(currentFaBaoInfo, _faBaoInfo);
  117. faBaoSkillWidgets.Add(faBaoSkillWidget);
  118. }
  119. }
  120. private async CTask CreatFaBaoAttributeWidget(FaBaoInfo faBaoInfo)
  121. {
  122. string t = "";
  123. foreach (var keyValuePair in faBaoInfo.attriButedIC)
  124. {
  125. t =
  126. $"{GetAttributeName(keyValuePair.Key)} : {currentFaBaoInfo.attriButedIC[keyValuePair.Key].ToString()}\n";
  127. }
  128. Text_ShuXingJiaCheng.text = t;
  129. }
  130. private string GetAttributeName(int type)
  131. {
  132. switch (type)
  133. {
  134. case 1:
  135. return "生命";
  136. case 2:
  137. return "防御";
  138. case 3:
  139. return "攻击";
  140. }
  141. return "";
  142. }
  143. public async static CTask<FaBaoDetailsPanel> OpenPanel(ItemInfo faBaoInfo)
  144. {
  145. FaBaoDetailsPanel selectFaBaoPanel =
  146. await UIManager.Instance.LoadAndOpenPanel<FaBaoDetailsPanel>(null, UILayer.Top);
  147. selectFaBaoPanel.CustomInit(faBaoInfo);
  148. return selectFaBaoPanel;
  149. }
  150. public async override CTask Close()
  151. {
  152. foreach (var faBaoAttributeWidget in faBaoWidgets)
  153. {
  154. UIManager.Instance.DormancyGComponent(faBaoAttributeWidget);
  155. }
  156. faBaoWidgets.Clear();
  157. foreach (var faBaoSkillWidget in faBaoSkillWidgets)
  158. {
  159. UIManager.Instance.DormancyGComponent(faBaoSkillWidget);
  160. }
  161. faBaoSkillWidgets.Clear();
  162. UIManager.Instance.DormancyGComponent(currentFaBaoWidget);
  163. currentFaBaoWidget = null;
  164. currentFaBaoInfo = null;
  165. await base.Close();
  166. }
  167. }
  168. }