PartnerEpiDetailInfoCtrl.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using System.Collections.Generic;
  9. using UnityEngine;
  10. using XGame;
  11. using XGame.Database;
  12. using XGame.Framework;
  13. using XGame.Framework.UI;
  14. namespace FL.FGUI
  15. {
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class PartnerEpiDetailInfoCtrl : UIController<PartnerEpiDetailInfoVM>
  21. {
  22. protected override void OnEnable(object intent)
  23. {
  24. id = (int)intent;
  25. AddUIListenres();
  26. UpView();
  27. }
  28. protected override void OnDisable()
  29. {
  30. RemoveUIListenres();
  31. }
  32. #region UI事件
  33. private void AddUIListenres()
  34. {
  35. VM.ShangZhenBtn.onClick.Add(OnClickShangZhenBtn);
  36. VM.GotoBtn.onClick.Add(OnClickGotoBtn);
  37. VM.RankUpBtn.onClick.Add(OnClickRankUpBtn);
  38. }
  39. private void RemoveUIListenres()
  40. {
  41. VM.ShangZhenBtn.onClick.Remove(OnClickShangZhenBtn);
  42. VM.GotoBtn.onClick.Remove(OnClickGotoBtn);
  43. VM.RankUpBtn.onClick.Remove(OnClickRankUpBtn);
  44. }
  45. private void OnClickShangZhenBtn(EventContext context) { }
  46. private void OnClickGotoBtn(EventContext context) { }
  47. private void OnClickRankUpBtn(EventContext context)
  48. {
  49. var info = EpigraphData.Instance.GetEpigraphInfo(id);
  50. if (info == null)
  51. return;
  52. var table = epigraphUpTableRepo.GetEpiragphUp(id, info.starLv);
  53. if (table == null)
  54. return;
  55. if (table.LevelUpCost > ItemData.Instance.GetItemNum(id))
  56. {
  57. EventSingle.Instance.Notify(EventDefine.ShowTips, StringDefine.epigraphUpUnenough);
  58. return;
  59. }
  60. EpigraphService.Instance.RequestEpiStarUp(id);
  61. }
  62. #endregion
  63. #region 属性
  64. private int id;
  65. #endregion
  66. #region 页面
  67. private void UpView()
  68. {
  69. UpDescInfo();
  70. UpProgressInfo();
  71. UpSkillList();
  72. }
  73. private void UpDescInfo()
  74. {
  75. var table = EpigraphTableRepo.Get(id);
  76. if (table == null)
  77. return;
  78. VM.EpiLabel.Ctrl.SetEpiIcon(id, true);
  79. var initSkillId = table.Skill[0];
  80. var skillTable = SkillTableRepo.Get(initSkillId);
  81. if (skillTable == null)
  82. return;
  83. VM.DescLabel.text = skillTable.Desc;
  84. VM.NameLabel.text = table.Name;
  85. var info = EpigraphData.Instance.GetEpigraphInfo(id);
  86. if (info != null)
  87. {
  88. VM.Up.selectedIndex = info.partnerId > 0 ? 1 : 0;
  89. int nextLv = info.starLv + 1;
  90. var nextUpTable = epigraphUpTableRepo.GetEpiragphUp(id, nextLv);
  91. VM.HaveState.selectedIndex = nextUpTable != null ? 1 : 2;
  92. }
  93. else
  94. {
  95. VM.HaveState.selectedIndex = 0;
  96. }
  97. if (table.Element > 0)
  98. {
  99. VM.AttrIcon.visible = true;
  100. VM.AttrIcon.url = AddressableDefine.PartnerElementType(((int)table.Element));
  101. }
  102. else
  103. {
  104. VM.AttrIcon.visible = false;
  105. }
  106. string str = "";
  107. for (int i = 0; i < table.Own_attr.Length; i += 2)
  108. {
  109. var attrTable = AttrDescTableRepo.Get(table.Own_attr[i]);
  110. if (attrTable == null)
  111. continue;
  112. var attrValue = table.Own_attr[i + 1];
  113. var val = attrValue > 0 ? TableUtils.ToRealDouble(attrValue).ToString("F2") : "0";
  114. if (i > 0)
  115. str += ",";
  116. str += $"{attrTable.ShowName}{val}%";
  117. }
  118. VM.AttrLabel.text = str;
  119. }
  120. private void UpProgressInfo()
  121. {
  122. var info = EpigraphData.Instance.GetEpigraphInfo(id);
  123. var curlv = info != null ? info.starLv : 0;
  124. var table = epigraphUpTableRepo.GetEpiragphUp(id, curlv);
  125. if (table != null)
  126. {
  127. VM.ChipPbar.max = table.LevelUpCost;
  128. VM.ChipPbar.value = 0;
  129. }
  130. }
  131. private void UpSkillList()
  132. {
  133. var list = new List<EpigraphSkillLimit>();
  134. var epiTable = EpigraphTableRepo.Get(id);
  135. if (epiTable == null)
  136. return;
  137. for (var i = 2; i < epiTable.Skill.Length; i = i + 2)
  138. {
  139. var skill = epiTable.Skill[i];
  140. var limit = epiTable.Skill[i + 1];
  141. var skillLimit = new EpigraphSkillLimit()
  142. {
  143. epiId = id,
  144. limitLv = limit,
  145. skillId = skill,
  146. };
  147. list.Add(skillLimit);
  148. }
  149. VM.EffectList.BindDatas(list);
  150. }
  151. #endregion
  152. }
  153. }