PartnerSbDetailNestedCtrl.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 FL.Data.Items;
  10. using XGame;
  11. using XGame.Database;
  12. using XGame.Framework.Database;
  13. using XGame.Framework.UI;
  14. namespace FL.FGUI
  15. {
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class PartnerSbDetailNestedCtrl : UIController<PartnerSbDetailNestedVM>
  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 id)
  36. {
  37. _sbId = id;
  38. if (_sbId == 0)
  39. {
  40. VM.IsEmpty.selectedIndex = 1;
  41. return;
  42. }
  43. else
  44. {
  45. VM.IsEmpty.selectedIndex = 0;
  46. }
  47. var table = PartnerTableRepo.Get(_sbId);
  48. if (table == null)
  49. {
  50. Log.Error($"圣兵表不存在,id:{_sbId}");
  51. return;
  52. }
  53. VM.NameLabel.text = table.Name;
  54. var attr = PartnersData.Instance.GetPartnerAttrByTableId(_sbId);
  55. var level = attr?.Level ?? 1;
  56. var star = attr?.RisingStarLv ?? 1;
  57. var upLevelTable = partnerStarUpTableRepo.GetPartnerStarTable(_sbId, star);
  58. if (upLevelTable == null)
  59. {
  60. Log.Error($"圣兵升星表不存在,id:{_sbId},level:{level}");
  61. return;
  62. }
  63. //
  64. VM.SpPbar.max = upLevelTable.StarUpCost;
  65. VM.SpPbar.value = ItemData.Instance.GetItemNum(upLevelTable.PetId);
  66. //
  67. ShowStar(star);
  68. //
  69. ShowSkillBaseInfo(table.Skill[0]);
  70. //
  71. ShowAttr(level);
  72. //
  73. VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
  74. VM.TypeLoader.url = AddressableDefine.SbTypeIcon(table.Type);
  75. //
  76. VM.AttrLabel.text = $"+{table.Own_attr[1]/100f}%";
  77. var item = new ItemBase();
  78. //item.Init(table, table.Id);
  79. //VM.ItemBase.Ctrl.ShowUI()
  80. }
  81. private void ShowStar(int star)
  82. {
  83. var starStep = PartnersService.Instance.GetStarStep(star);
  84. var starLv = PartnersService.Instance.GetStarLv(star);
  85. var list = new List<int>();
  86. for (int i = 0; i < starLv; i++)
  87. {
  88. list.Add(starStep);
  89. }
  90. VM.StarList.BindDatas(list);
  91. }
  92. private void ShowAttr(int level)
  93. {
  94. var lvTable = partnerLvUpTableRepo.GetPartnerLvUpTable(_sbId, level);
  95. if (lvTable == null)
  96. {
  97. Log.Error($"圣兵等级不存在,id:{_sbId},level:{level}");
  98. return;
  99. }
  100. var atkVal = lvTable.LvAttr[1];
  101. //var attributeInfo = AttrDescTableRepo.Get(attrType);
  102. string descAtk = atkVal > 0 ? TableUtils.ToRealDouble(atkVal).ToString("F1") : "0";
  103. VM.AtkValLabel.text = descAtk;
  104. var atkSpeed = lvTable.LvAttr[3];
  105. string descSpeed =
  106. atkSpeed > 0 ? TableUtils.ToRealDouble(atkSpeed).ToString("F1") : "0";
  107. VM.SpeedValLabel.text = descSpeed;
  108. //VM.ItemBase.Ctrl.ShowUI()
  109. }
  110. /// <summary>
  111. /// 基础技能描述
  112. /// </summary>
  113. /// <param name="skillId"></param>
  114. private void ShowSkillBaseInfo(int skillId)
  115. {
  116. var skillInfo = SkillTableRepo.Get(skillId);
  117. if (skillInfo == null)
  118. {
  119. Log.Error($"技能表不存在,id{skillId}");
  120. return;
  121. }
  122. VM.DescLabel.text = skillInfo.Desc;
  123. }
  124. }
  125. }