PartnerMwDetailNoIconNestedCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 XGame;
  10. using XGame.Database;
  11. using XGame.Framework.UI;
  12. namespace FL.FGUI
  13. {
  14. /// <summary>
  15. /// UI逻辑处理类
  16. /// </summary>
  17. /// <typeparam name=""></typeparam>
  18. public partial class PartnerMwDetailNoIconNestedCtrl
  19. : UIController<PartnerMwDetailNoIconNestedVM>
  20. {
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. }
  29. #region UI事件
  30. private void AddUIListenres() { }
  31. private void RemoveUIListenres() { }
  32. #endregion
  33. private int _mwId;
  34. public void ShowUI(int mwId)
  35. {
  36. _mwId = mwId;
  37. var table = EpigraphTableRepo.Get(_mwId);
  38. XGame.Framework.Assert.IsNotNull(table, $"铭文表不存在,id:{_mwId}");
  39. var attr = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId);
  40. var star = attr?.StarLv ?? 1;
  41. VM.AttrLabel.text = $"+{table.Own_attr[1] / 100f}%";
  42. //
  43. ShowSkillBaseInfo(table.Skill[0]);
  44. //
  45. if (table.Element > 0)
  46. {
  47. VM.ElementLoader.visible = true;
  48. VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
  49. }
  50. else
  51. {
  52. VM.ElementLoader.visible = false;
  53. }
  54. ShowBuff(star);
  55. //
  56. var pos = PartnersData.Instance.UpSbPosMap.GetValueOrDefault(_mwId, -1);
  57. VM.IsUp.selectedIndex = pos < 0 ? 0 : 1;
  58. }
  59. /// <summary>
  60. /// 基础技能描述
  61. /// </summary>
  62. /// <param name="skillId"></param>
  63. private void ShowSkillBaseInfo(int skillId)
  64. {
  65. var skillInfo = SkillTableRepo.Get(skillId);
  66. XGame.Framework.Assert.IsNotNull(skillInfo, $"技能表不存在,id{skillId}");
  67. VM.DescLabel.text = skillInfo.Desc;
  68. }
  69. private void ShowBuff(int starLv)
  70. {
  71. var table = EpigraphTableRepo.Get(_mwId);
  72. XGame.Framework.Assert.IsNotNull(table, $"铭文表tableId {_mwId} 不存在");
  73. var starSkillIds = table?.Skill;
  74. var dataList = new List<PartnerSbDetailSkillListItemParam>();
  75. if (starSkillIds?.Length > 0)
  76. {
  77. for (int i = 2; i < starSkillIds.Length; i += 2)
  78. {
  79. var data = new PartnerSbDetailSkillListItemParam()
  80. {
  81. SkillId = starSkillIds[i],
  82. NeedStarLevel = starSkillIds[i + 1],
  83. CurStarLevel = starLv,
  84. };
  85. dataList.Add(data);
  86. }
  87. }
  88. VM.SkillList.BindDatas(dataList);
  89. }
  90. }
  91. }