PartnerSbBaseItemCtrl.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 PartnerSbBaseItemCtrl : UIController<PartnerSbBaseItemVM>
  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. public void ShowUI(int sbId, bool showOther)
  33. {
  34. if (sbId <= 0)
  35. {
  36. VM.PartnerImg.visible = false;
  37. VM.QualityImg.icon = AddressableDefine.SbEmptyDi();
  38. VM.ShowOther.selectedIndex = 1;
  39. VM.LevelTxt.visible = false;
  40. return;
  41. }
  42. var table = PartnerTableRepo.Get(sbId);
  43. if (table == null)
  44. {
  45. Log.Error($"圣兵表不存在id:{sbId}");
  46. return;
  47. }
  48. VM.PartnerImg.visible = true;
  49. VM.ElementLoader.url = AddressableDefine.SbElementType((int)table.Element);
  50. VM.QualityImg.icon = AddressableDefine.SbPzDi((int)table.Quality);
  51. VM.PartnerImg.icon = table.Icon;
  52. var partnerData = PartnersData.Instance.GetPartnerAttrByTableId(sbId);
  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. var curNum = PartnersService.Instance.GetStarLv(starLv);
  65. var curStep = PartnersService.Instance.GetStarStep(starLv);
  66. var list = new List<int>();
  67. for (int i = 0; i < curNum; i++)
  68. {
  69. list.Add(curStep);
  70. }
  71. VM.StarList.BindDatas(list);
  72. var starTable = partnerStarUpTableRepo.GetPartnerStarTable(sbId, starLv);
  73. if (starTable == null)
  74. {
  75. Log.Error($"圣兵升星表不存在,id:{sbId},starLv:{starLv}");
  76. return;
  77. }
  78. VM.SpPbar.max = starTable.StarUpCost;
  79. VM.SpPbar.value = ItemData.Instance.GetItemNum(starTable.PetId);
  80. }
  81. }
  82. }
  83. }