PartnerSbDetailNoIconNestedCtrl.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using System.Collections.Generic;
  7. using FairyGUI;
  8. using FL.Data;
  9. using log4net.Core;
  10. using XGame;
  11. using XGame.Database;
  12. using XGame.Framework.UI;
  13. namespace FL.FGUI
  14. {
  15. /// <summary>
  16. /// UI逻辑处理类
  17. /// </summary>
  18. /// <typeparam name=""></typeparam>
  19. public partial class PartnerSbDetailNoIconNestedCtrl
  20. : UIController<PartnerSbDetailNoIconNestedVM>
  21. {
  22. protected override void OnEnable(object intent)
  23. {
  24. AddUIListenres();
  25. }
  26. protected override void OnDisable()
  27. {
  28. RemoveUIListenres();
  29. }
  30. #region UI事件
  31. private void AddUIListenres() { }
  32. private void RemoveUIListenres() { }
  33. #endregion
  34. private int _sbId;
  35. public void ShowUI(int sbId)
  36. {
  37. _sbId = sbId;
  38. var table = PartnerTableRepo.Get(_sbId);
  39. if (table == null)
  40. {
  41. Log.Error($"圣兵表不存在,id:{_sbId}");
  42. return;
  43. }
  44. var attr = PartnersData.Instance.GetPartnerAttrByTableId(_sbId);
  45. var level = attr?.Level ?? 1;
  46. var star = attr?.RisingStarLv ?? 1;
  47. VM.AttrLabel.text = $"+{table.Own_attr[1]/100f}%";
  48. //
  49. ShowSkillBaseInfo(table.Skill[0]);
  50. //
  51. ShowAttr(level);
  52. //
  53. VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
  54. VM.TypeLoader.url = AddressableDefine.SbTypeIcon(table.Type);
  55. ShowBuff(star);
  56. //
  57. var pos = PartnersData.Instance.GetPartnerUpPosById(_sbId);
  58. VM.IsUp.selectedIndex = pos < 0 ? 0 : 1;
  59. }
  60. private void ShowAttr(int level)
  61. {
  62. var lvTable = partnerLvUpTableRepo.GetPartnerLvUpTable(_sbId, level);
  63. if (lvTable == null)
  64. {
  65. Log.Error($"圣兵等级不存在,id:{_sbId},level:{level}");
  66. return;
  67. }
  68. var atkVal = lvTable.LvAttr[1];
  69. //var attributeInfo = AttrDescTableRepo.Get(attrType);
  70. string descAtk = atkVal > 0 ? TableUtils.ToRealDouble(atkVal).ToString("F1") : "0";
  71. VM.AtkValLabel.text = descAtk;
  72. var atkSpeed = lvTable.LvAttr[3];
  73. string descSpeed =
  74. atkSpeed > 0 ? TableUtils.ToRealDouble(atkSpeed).ToString("F1") : "0";
  75. VM.SpeedValLabel.text = descSpeed;
  76. //VM.ItemBase.Ctrl.ShowUI()
  77. }
  78. /// <summary>
  79. /// 基础技能描述
  80. /// </summary>
  81. /// <param name="skillId"></param>
  82. private void ShowSkillBaseInfo(int skillId)
  83. {
  84. var skillInfo = SkillTableRepo.Get(skillId);
  85. if (skillInfo == null)
  86. {
  87. Log.Error($"技能表不存在,id{skillId}");
  88. return;
  89. }
  90. VM.DescLabel.text = skillInfo.Desc;
  91. }
  92. private void ShowBuff(int starLv)
  93. {
  94. var table = PartnerTableRepo.Get(_sbId);
  95. if (table == null)
  96. {
  97. Log.Error($"圣兵tableId {_sbId} 不存在");
  98. return;
  99. }
  100. var starSkillIds = table?.Skill;
  101. var dataList = new List<PartnerSbDetailSkillListItemParam>();
  102. if (starSkillIds?.Length > 0)
  103. {
  104. for (int i = 2; i < starSkillIds.Length; i += 2)
  105. {
  106. var data = new PartnerSbDetailSkillListItemParam()
  107. {
  108. SkillId = starSkillIds[i],
  109. NeedStarLevel = starSkillIds[i + 1],
  110. CurStarLevel = starLv,
  111. };
  112. dataList.Add(data);
  113. }
  114. }
  115. VM.SkillList.BindDatas(dataList);
  116. }
  117. }
  118. }