PartnerMwDetailNestedCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.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 PartnerMwDetailNestedCtrl : UIController<PartnerMwDetailNestedVM>
  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 _mwId;
  33. public void ShowUI(int id)
  34. {
  35. _mwId = id;
  36. if (_mwId == 0)
  37. {
  38. VM.MwBaseItem.Disable();
  39. VM.IsEmpty.selectedIndex = 1;
  40. return;
  41. }
  42. VM.MwBaseItem.Enable(null);
  43. VM.IsEmpty.selectedIndex = 0;
  44. var table = EpigraphTableRepo.Get(_mwId);
  45. XGame.Framework.Assert.IsNotNull(table, $"铭文表不存在,id:{_mwId}");
  46. VM.NameLabel.text = table.Name;
  47. var attr = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId);
  48. var star = attr?.StarLv ?? 1;
  49. var upStarTable = epigraphUpTableRepo.GetEpiragphUp(_mwId, star);
  50. VM.SpPbar.max = upStarTable.LevelUpCost;
  51. VM.SpPbar.value = ItemData.Instance.GetItemNum(upStarTable.PetId);
  52. //
  53. ShowStar(star);
  54. //
  55. ShowSkillBaseInfo(table.Skill[0]);
  56. //
  57. if (table.Element > 0)
  58. {
  59. VM.ElementLoader.visible = true;
  60. VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
  61. }
  62. else
  63. {
  64. VM.ElementLoader.visible = false;
  65. }
  66. //
  67. VM.AttrLabel.text = $"+{table.Own_attr[1] / 100f}%";
  68. VM.MwBaseItem.Ctrl.SetEpiIcon(_mwId);
  69. }
  70. private void ShowStar(int star)
  71. {
  72. var starStep = PartnersService.Instance.GetStarStep(star);
  73. var starLv = PartnersService.Instance.GetStarLv(star);
  74. var list = new List<int>();
  75. for (int i = 0; i < starLv; i++)
  76. {
  77. list.Add(starStep);
  78. }
  79. VM.StarList.BindDatas(list);
  80. }
  81. /// <summary>
  82. /// 基础技能描述
  83. /// </summary>
  84. /// <param name="skillId"></param>
  85. private void ShowSkillBaseInfo(int skillId)
  86. {
  87. var skillInfo = SkillTableRepo.Get(skillId);
  88. XGame.Framework.Assert.IsNotNull(skillInfo, $"技能表不存在,id{skillId}");
  89. VM.DescLabel.text = skillInfo.Desc;
  90. }
  91. }
  92. }