PartnerStarNestedCtrl.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 InitStarList()
  41. {
  42. if (_starIconList == null)
  43. {
  44. _starIconList = new List<GLoader>()
  45. {
  46. VM.Star1Loader,
  47. VM.Star2Loader,
  48. VM.Star3Loader,
  49. VM.Star4Loader,
  50. VM.Star5Loader,
  51. };
  52. }
  53. }
  54. private void ShowStarIcon(int count, int starLv)
  55. {
  56. VM.StarNum.selectedIndex = count;
  57. if (count > 0)
  58. {
  59. int colorIndex = PartnersService.Instance.GetStarStep(starLv);
  60. for (int i = 0; i < count; i++)
  61. {
  62. if (_starIconList[i] != null)
  63. {
  64. _starIconList[i].icon = AddressableDefine.PartnerStarIconName(colorIndex);
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }