PartnerSbDetailNestedCtrl.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.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 PartnerSbDetailNestedCtrl : UIController<PartnerSbDetailNestedVM>
  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 _id;
  34. public void ShowUI(int id)
  35. {
  36. _id = id;
  37. if (_id == 0)
  38. {
  39. VM.IsEmpty.selectedIndex = 1;
  40. return;
  41. }
  42. else
  43. {
  44. VM.IsEmpty.selectedIndex = 0;
  45. }
  46. var table = PartnerTableRepo.Get(_id);
  47. if (table == null)
  48. {
  49. Log.Error($"圣兵表不存在,id:{_id}");
  50. return;
  51. }
  52. var attr = PartnersData.Instance.GetPartnerAttrByTableId(_id);
  53. var level = attr?.Level ?? 1;
  54. var star = attr?.RisingStarLv ?? 1;
  55. var upLevelTable = partnerStarUpTableRepo.GetPartnerStarTable(_id, star);
  56. if (upLevelTable == null)
  57. {
  58. Log.Error($"圣兵升星表不存在,id:{_id},level:{level}");
  59. return;
  60. }
  61. //
  62. VM.SpPbar.max = upLevelTable.StarUpCost;
  63. VM.SpPbar.value = ItemData.Instance.GetItemNum(upLevelTable.PetId);
  64. //
  65. var starStep = PartnersService.Instance.GetStarStep(star);
  66. var starLv = PartnersService.Instance.GetStarLv(star);
  67. var list = new List<int>();
  68. for (int i = 0; i < starLv; i++)
  69. {
  70. list.Add(starStep);
  71. }
  72. VM.StarList.BindDatas(list);
  73. //
  74. VM.NameLabel.text = table.Name;
  75. ShowSkillBaseInfo(table.Skill[0]);
  76. //
  77. var lvTable = partnerLvUpTableRepo.GetPartnerLvUpTable(_id, level);
  78. if (lvTable == null)
  79. {
  80. Log.Error($"圣兵等级不存在,id:{_id},level:{level}");
  81. return;
  82. }
  83. var atkVal = lvTable.LvAttr[1];
  84. //var attributeInfo = AttrDescTableRepo.Get(attrType);
  85. string descAtk = atkVal > 0 ? TableUtils.ToRealDouble(atkVal).ToString("F1") : "0";
  86. VM.AtkValLabel.text = descAtk;
  87. var atkSpeed = lvTable.LvAttr[3];
  88. string descSpeed =
  89. atkSpeed > 0 ? TableUtils.ToRealDouble(atkSpeed).ToString("F1") : "0";
  90. VM.SpeedValLabel.text = descSpeed;
  91. //
  92. //VM.ItemBase.Ctrl.ShowUI()
  93. VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
  94. VM.TypeLoader.url = AddressableDefine.SbTypeIcon(table.Type);
  95. }
  96. /// <summary>
  97. /// 基础技能描述
  98. /// </summary>
  99. /// <param name="skillId"></param>
  100. private void ShowSkillBaseInfo(int skillId)
  101. {
  102. var skillInfo = SkillTableRepo.Get(skillId);
  103. if (skillInfo == null)
  104. {
  105. Log.Error($"技能表不存在,id{skillId}");
  106. return;
  107. }
  108. VM.DescLabel.text = skillInfo.Desc;
  109. }
  110. }
  111. }