PartnerSbBaseItemCtrl.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.QualityImg.icon = AddressableDefine.SbEmptyDi();
  37. VM.ShowOther.selectedIndex = 1;
  38. VM.PartnerImg.visible = false;
  39. VM.LevelTxt.visible = false;
  40. VM.ElementLoader.visible = false;
  41. return;
  42. }
  43. VM.PartnerImg.visible = true;
  44. VM.LevelTxt.visible = true;
  45. VM.ElementLoader.visible = true;
  46. var table = PartnerTableRepo.Get(sbId);
  47. XGame.Framework.Assert.IsNotNull(table, $"圣兵表不存在id:{sbId}");
  48. VM.ElementLoader.url = AddressableDefine.SbElementTypeRhombus((int)table.Element);
  49. VM.QualityImg.icon = AddressableDefine.SbPzDi((int)table.Quality);
  50. VM.PartnerImg.icon = table.Icon;
  51. VM.ShowOther.selectedIndex = showOther ? 0 : 1;
  52. var partnerData = PartnersData.Instance.GetPartnerAttrByTableId(sbId);
  53. VM.Have.selectedIndex = partnerData != null ? 0 : 1;
  54. if (partnerData != null)
  55. {
  56. var level = partnerData?.Level ?? 1;
  57. VM.LevelTxt.text = $"LV.{level}";
  58. if (showOther)
  59. {
  60. var starLv = partnerData?.RisingStarLv == null ? 1 : partnerData.RisingStarLv;
  61. ShowStar(starLv);
  62. var starTable = partnerStarUpTableRepo.GetPartnerStarTable(sbId, starLv);
  63. XGame.Framework.Assert.IsNotNull(
  64. starTable,
  65. $"圣兵升星表不存在,id:{sbId},starLv:{starLv}"
  66. );
  67. VM.SpPbar.max = starTable.StarUpCost;
  68. VM.SpPbar.value = ItemData.Instance.GetItemNum(starTable.PetId);
  69. }
  70. }
  71. }
  72. private void ShowStar(int starLv)
  73. {
  74. var curNum = PartnersService.Instance.GetStarLv(starLv);
  75. var curStep = PartnersService.Instance.GetStarStep(starLv);
  76. var list = new List<int>();
  77. for (int i = 0; i < curNum; i++)
  78. {
  79. list.Add(curStep);
  80. }
  81. VM.StarList.BindDatas(list);
  82. }
  83. }
  84. }