SelectBreakthroughItemPanel.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Bag;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "SelectBreakthroughItemPanel")]
  10. public partial class SelectBreakthroughItemPanel : UIPanel
  11. {
  12. ItemConfig itemConfig;
  13. private Action callBack;
  14. private void Init()
  15. {
  16. }
  17. protected override void AddEvent()
  18. {
  19. }
  20. protected override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. Btn_Affirm.onClick.AddListener(() =>
  26. {
  27. this.callBack?.Invoke();
  28. EventManager.Instance.Dispatch(CustomEventType.RefenceBreakthrough, null);
  29. UIManager.Instance.HideUIUIPanel(this);
  30. });
  31. Btn_Cancel.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  32. }
  33. public void CustomInit(int itemId, Action callBack)
  34. {
  35. this.callBack = callBack;
  36. itemConfig = ConfigComponent.Instance.Get<ItemConfig>(itemId);
  37. Text_ItemName.text = LanguageManager.Instance.Text(itemConfig.itemName);
  38. Text_ItemDesc.text = LanguageManager.Instance.Text(itemConfig.itemDesc);
  39. Icon_ItemIcon.icon_name = itemConfig.icon;
  40. if (itemConfig.itemTag == 3)
  41. {
  42. Text_SucceedDesc.text = $"+{itemConfig.associateVlaue[2]}%";
  43. // Text_FailDesc.text = $"-{itemConfig.associateVlaue[3]}%";
  44. }
  45. else
  46. {
  47. Text_SucceedDesc.text = $"+{itemConfig.associateVlaue[2]}%";
  48. }
  49. if (PlayerManager.Instance.BagController.IsEnough(itemId, 1))
  50. {
  51. Btn_Affirm.gameObject.SetActive(true);
  52. Btn_Cancel.gameObject.SetActive(true);
  53. Text_NoEnough.gameObject.SetActive(false);
  54. }
  55. else
  56. {
  57. Btn_Affirm.gameObject.SetActive(false);
  58. Btn_Cancel.gameObject.SetActive(true);
  59. Text_NoEnough.gameObject.SetActive(true);
  60. }
  61. }
  62. public async static CTask<SelectBreakthroughItemPanel> OpenPanel(int itemId, Action callBack)
  63. {
  64. SelectBreakthroughItemPanel selectBreakthroughItemPanel = await UIManager.Instance.LoadAndOpenPanel<SelectBreakthroughItemPanel>(null);
  65. selectBreakthroughItemPanel.CustomInit(itemId, callBack);
  66. return selectBreakthroughItemPanel;
  67. }
  68. }
  69. }