PartnerStarNestedCtrl.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerStarNestedCtrl : UIController<PartnerStarNestedVM>
  17. {
  18. private List<GLoader> _starIconList;
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres() { }
  29. private void RemoveUIListenres() { }
  30. #endregion
  31. public void ShowStarUI(int starLv)
  32. {
  33. InitStarList();
  34. int starNum = starLv == 0 ? 0 : starLv % PartnersData.MaxStarNum;
  35. if (starLv > 0 && starNum == 0)
  36. starNum = PartnersData.MaxStarNum;
  37. VM.StarNum.selectedIndex = starNum;
  38. ShowStarIcon(starNum, starLv);
  39. }
  40. private void ClearStar()
  41. {
  42. if (_starIconList != null)
  43. {
  44. _starIconList.Clear();
  45. _starIconList = null;
  46. }
  47. }
  48. private void InitStarList()
  49. {
  50. if (_starIconList == null)
  51. {
  52. _starIconList = new List<GLoader>()
  53. {
  54. VM.Star1Loader,
  55. VM.Star2Loader,
  56. VM.Star3Loader,
  57. VM.Star4Loader,
  58. VM.Star5Loader,
  59. };
  60. }
  61. }
  62. private void ShowStarIcon(int count, int starLv)
  63. {
  64. VM.StarNum.selectedIndex = count;
  65. if (count > 0)
  66. {
  67. int colorIndex = PartnersData.Instance.GetStarStep(starLv);
  68. for (int i = 0; i < count; i++)
  69. {
  70. if (_starIconList[i] != null)
  71. {
  72. _starIconList[i].icon = AddressableDefine.PartnerStarIconName(colorIndex);
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }