BuyConfirmView.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using UI.CommonGame;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class BuyConfirmView : BaseWindow
  7. {
  8. private UI_BuyConfirmUI _ui;
  9. public override void Dispose()
  10. {
  11. if (_ui != null)
  12. {
  13. _ui.Dispose();
  14. _ui = null;
  15. }
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. _ui = UI_BuyConfirmUI.Create();
  22. this.viewCom = _ui.target;
  23. this.viewCom.Center();
  24. this.modal = true;
  25. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  26. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  27. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  28. }
  29. protected override void AddEventListener()
  30. {
  31. base.AddEventListener();
  32. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. UpdateView();
  38. }
  39. protected override void RemoveEventListener()
  40. {
  41. base.RemoveEventListener();
  42. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
  43. }
  44. private void UpdateView()
  45. {
  46. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.costIdBuyFightTimes);
  47. _ui.m_txtMessage.text = string.Format("是否使用{0}{1}增加1次飞花令挑战次数?", GlobalCfgArray.globalCfg.costNumBuyFightTimes, itemCfg.name);
  48. _ui.m_txtTips.text = string.Format("(今天已购买{0}/{1}次)", GlobalCfgArray.globalCfg.limitDailyBuyFightTimes - RoleDataManager.ArenaBuyFightTimes, GlobalCfgArray.globalCfg.limitDailyBuyFightTimes);
  49. }
  50. private void OnClickBtnSure()
  51. {
  52. if (ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.costIdBuyFightTimes) < GlobalCfgArray.globalCfg.costNumBuyFightTimes)
  53. {
  54. PromptController.Instance.ShowFloatTextPrompt("消耗不足");
  55. return;
  56. }
  57. if (RoleDataManager.ArenaFightTimes >= GlobalCfgArray.globalCfg.fightTimesLimit)
  58. {
  59. PromptController.Instance.ShowFloatTextPrompt("已达到最大存储次数");
  60. return;
  61. }
  62. ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
  63. }
  64. private void OnClickBtnCancel()
  65. {
  66. this.Hide();
  67. }
  68. }
  69. }