BuyConfirmView.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. EventAgent.AddEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. UpdateView();
  39. }
  40. protected override void RemoveEventListener()
  41. {
  42. base.RemoveEventListener();
  43. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
  44. EventAgent.RemoveEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
  45. }
  46. private void UpdateView()
  47. {
  48. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.costIdBuyFightTimes);
  49. _ui.m_txtMessage.text = string.Format("是否使用{0}{1}增加1次飞花令挑战次数? \n\u3000\u3000\u3000\u3000(开通福气卡可储存次数)", GlobalCfgArray.globalCfg.costNumBuyFightTimes, itemCfg.name);
  50. _ui.m_txtTips.text = string.Format("(今天已购买{0}/{1}次)", GlobalCfgArray.globalCfg.limitDailyBuyFightTimes - RoleDataManager.ArenaBuyFightTimes, GlobalCfgArray.globalCfg.limitDailyBuyFightTimes);
  51. }
  52. private void OnClickBtnSure()
  53. {
  54. int costId = GlobalCfgArray.globalCfg.costIdBuyFightTimes;
  55. long needNum = GlobalCfgArray.globalCfg.costNumBuyFightTimes;
  56. if (!ItemUtil.CheckItemEnough(costId, needNum))
  57. {
  58. long has = ItemDataManager.GetItemNum(costId);
  59. ItemUtil.BuyCurrency(costId, needNum - has);
  60. return;
  61. }
  62. // if (RoleDataManager.ArenaFightTimes >=RoleDataManager.ArenaMaxStorageNum)
  63. // {
  64. // PromptController.Instance.ShowFloatTextPrompt("已达到最大存储次数");
  65. // return;
  66. // }
  67. ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
  68. }
  69. private void OnClickBtnCancel()
  70. {
  71. this.Hide();
  72. }
  73. }
  74. }