CommonComCostNestedCtrl.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 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 CommonComCostNestedCtrl : UIController<CommonComCostNestedVM>
  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. public void ShowUI(int itemId, long count)
  35. {
  36. var itemInfo = ItemTableRepo.Get(itemId);
  37. if (itemInfo != null) VM.CostIcon.icon = itemInfo?.Icon;
  38. VM.CostLabel.text = count.FormatNumber();
  39. }
  40. public void ShowCostUI(int costId, long costVal, long count = 0)
  41. {
  42. var costItemInfo = ItemTableRepo.Get(costId);
  43. if (costItemInfo != null) VM.CostIcon.icon = costItemInfo?.Icon;
  44. if (count == 0) count = ItemData.Instance.GetItemNum(costId);
  45. var countStr = count < costVal ? $"[color=#f74b4b]{count.FormatNumber()}[/color]" : $"[color=#1ef369]{count.FormatNumber()}[/color]";
  46. VM.CostLabel.text = $"{countStr}/{costVal.FormatNumber()}";
  47. }
  48. }
  49. }