PartnerSbLevelUpBtnCtrl.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FL.Data;
  7. using XGame;
  8. using XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerSbLevelUpBtnCtrl : UIController<PartnerSbLevelUpBtnVM>
  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. private void RemoveUIListenres() { }
  29. #endregion
  30. public void ShowUI(int sbId)
  31. {
  32. var attr = PartnersData.Instance.GetPartnerAttrByTableId(sbId);
  33. var level = attr?.Level ?? 1;
  34. var upLevelTable = partnerLvUpTableRepo.GetPartnerLvUpTable(sbId, level);
  35. if (upLevelTable == null)
  36. {
  37. Log.Error($"圣兵升级表不存在,id:{sbId},level:{level}");
  38. return;
  39. }
  40. VM.CostLabel.Ctrl.SetData(upLevelTable.LevelUpCost[0], upLevelTable.LevelUpCost[1]);
  41. var num = ItemData.Instance.GetItemNum(upLevelTable.LevelUpCost[0]);
  42. VM.Grayed.selectedIndex = num >= upLevelTable.LevelUpCost[1] ? 0 : 1;
  43. }
  44. }
  45. }