PartnerSbDetailNoIconNestedCtrl.cs 3.9 KB

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