PartnerSbDetailSkillListItemCtrl.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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;
  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 PartnerSbDetailSkillListItemCtrl
  19. : UIController<PartnerSbDetailSkillListItemVM>
  20. {
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. }
  29. #region UI事件
  30. private void AddUIListenres() { }
  31. private void RemoveUIListenres() { }
  32. #endregion
  33. public void OnRefresh(int index, PartnerSbDetailSkillListItemParam data)
  34. {
  35. ShowUI(data.SkillId, data.NeedStarLevel, data.CurStarLevel);
  36. }
  37. public void ShowUI(int skillId, int needStarLevel, int curStarLv)
  38. {
  39. ShowSkillDesc(skillId);
  40. VM.Unlock.selectedIndex = (needStarLevel > curStarLv) ? 0 : 1;
  41. ShowStarIcon(needStarLevel);
  42. }
  43. private void ShowSkillDesc(int skillId)
  44. {
  45. var skillInfo = SkillTableRepo.Get(skillId);
  46. if (skillInfo == null)
  47. {
  48. Log.Error($"技能表不存在,id:{skillId}");
  49. return;
  50. }
  51. VM.DescLabel.text = skillInfo.Desc;
  52. }
  53. private void ShowStarIcon(int star)
  54. {
  55. var starStep = PartnersService.Instance.GetStarStep(star);
  56. var starLv = PartnersService.Instance.GetStarLv(star);
  57. var list = new List<int>();
  58. for (int i = 0; i < starLv; i++)
  59. {
  60. list.Add(starStep);
  61. }
  62. VM.StarList.BindDatas(list);
  63. }
  64. }
  65. }