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