PartnerStarCenterItemCtrl.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using System.Collections.Generic;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerStarCenterItemCtrl : UIController<PartnerStarCenterItemVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. }
  22. protected override void OnDisable()
  23. {
  24. RemoveUIListenres();
  25. }
  26. #region UI事件
  27. private void AddUIListenres()
  28. {
  29. }
  30. private void RemoveUIListenres()
  31. {
  32. }
  33. #endregion
  34. private List<GLoader> _starIconList;
  35. public void ShowStarUI(int starLv)
  36. {
  37. InitStarList();
  38. int starNum = starLv == 0 ? 0 : starLv % PartnersData.MaxStarNum;
  39. if (starLv > 0 && starNum == 0)
  40. starNum = PartnersData.MaxStarNum;
  41. VM.StarNum.selectedIndex = starNum;
  42. ShowStarIcon(starNum, starLv);
  43. }
  44. private void ClearStar()
  45. {
  46. if (_starIconList != null)
  47. {
  48. _starIconList.Clear();
  49. _starIconList = null;
  50. }
  51. }
  52. private void InitStarList()
  53. {
  54. if (_starIconList == null)
  55. {
  56. _starIconList = new List<GLoader>()
  57. {
  58. VM.Star1Loader,
  59. VM.Star2Loader,
  60. VM.Star3Loader,
  61. VM.Star4Loader,
  62. VM.Star5Loader,
  63. };
  64. }
  65. }
  66. private void ShowStarIcon(int count, int starLv)
  67. {
  68. VM.StarNum.selectedIndex = count;
  69. if (count > 0)
  70. {
  71. int colorIndex = PartnersService.Instance.GetStarStep(starLv);
  72. for (int i = 0; i < count; i++)
  73. {
  74. if (_starIconList[i] != null)
  75. {
  76. _starIconList[i].icon = AddressableDefine.PartnerStarIconName(colorIndex);
  77. }
  78. }
  79. }
  80. }
  81. }
  82. }