PartnerPartnerBaseItemCtrl.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 PartnerPartnerBaseItemCtrl : UIController<PartnerPartnerBaseItemVM>
  19. {
  20. private List<GLoader> _starIconList;
  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. public void ShowUI(int id, bool showOther)
  34. {
  35. if (id <= 0)
  36. {
  37. VM.PartnerImg.visible = false;
  38. VM.QualityImg.icon = AddressableDefine.PartnerEmptyDi();
  39. VM.ShowOther.selectedIndex = 1;
  40. VM.LevelTxt.visible = false;
  41. return;
  42. }
  43. var table = PartnerTableRepo.Get(id);
  44. if (table == null)
  45. {
  46. Log.Error($"圣兵表不存在id:{id}");
  47. return;
  48. }
  49. VM.PartnerImg.visible = true;
  50. VM.QualityImg.icon = AddressableDefine.PartnerQualityFrame((int)table.Quality);
  51. VM.PartnerImg.icon = table.Icon;
  52. var partnerData = PartnersData.Instance.GetPartnerAttrByTableId(id);
  53. var level = partnerData?.Level ?? 0;
  54. bool bShowLevel = level > 0;
  55. VM.LevelTxt.visible = bShowLevel;
  56. if (bShowLevel)
  57. {
  58. VM.LevelTxt.text = $"LV.{level}";
  59. }
  60. VM.ShowOther.selectedIndex = showOther ? 0 : 1;
  61. if (showOther)
  62. {
  63. var starLv = partnerData?.RisingStarLv == null ? 1 : partnerData.RisingStarLv;
  64. VM.StarRating.Enable(null);
  65. VM.StarRating.Ctrl.ShowStarUI(starLv);
  66. var starTable = partnerStarUpTableRepo.GetPartnerStarTable(id, starLv);
  67. if (starTable == null)
  68. {
  69. Log.Error($"圣兵升星表不存在,id:{id},starLv:{starLv}");
  70. return;
  71. }
  72. VM.SpPbar.GetChild("icon").asLoader.url = AddressableDefine.PartnerSpProgressDi(
  73. (int)table.Quality
  74. );
  75. VM.SpPbar.max = starTable.StarUpCost;
  76. VM.SpPbar.value = ItemData.Instance.GetItemNum(starTable.PetId);
  77. }
  78. else
  79. {
  80. VM.StarRating.Disable();
  81. }
  82. }
  83. }
  84. }