BuyConfirmView.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using cfg.GfgCfg;
  3. using UI.CommonGame;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class BuyConfirmView : BaseWindow
  8. {
  9. private UI_BuyConfirmUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. _ui = UI_BuyConfirmUI.Create();
  23. this.viewCom = _ui.target;
  24. this.viewCom.Center();
  25. this.modal = true;
  26. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  27. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  28. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  29. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
  34. EventAgent.AddEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. UpdateView();
  40. }
  41. protected override void RemoveEventListener()
  42. {
  43. base.RemoveEventListener();
  44. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
  45. EventAgent.RemoveEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
  46. }
  47. private void UpdateView()
  48. {
  49. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault( CommonDataManager.Tables.TblGlobalCfg.CostIdBuyFightTimes);
  50. _ui.m_txtMessage.text = string.Format("是否使用{0}{1}增加1次飞花令挑战次数? \n\u3000\u3000\u3000\u3000(开通福气卡可储存次数)", CommonDataManager.Tables.TblGlobalCfg.CostNumBuyFightTimes, itemCfg.Name);
  51. _ui.m_txtTips.text = string.Format("(今天已购买{0}/{1}次)", CommonDataManager.Tables.TblGlobalCfg.LimitDailyBuyFightTimes - RoleDataManager.ArenaBuyFightTimes, CommonDataManager.Tables.TblGlobalCfg.LimitDailyBuyFightTimes);
  52. }
  53. private void OnClickBtnSure()
  54. {
  55. int costId = CommonDataManager.Tables.TblGlobalCfg.CostIdBuyFightTimes;
  56. long needNum = CommonDataManager.Tables.TblGlobalCfg.CostNumBuyFightTimes;
  57. if (!ItemUtil.CheckItemEnough(costId, needNum))
  58. {
  59. long has = ItemDataManager.GetItemNum(costId);
  60. ItemUtil.BuyCurrency(costId, needNum - has);
  61. return;
  62. }
  63. // if (RoleDataManager.ArenaFightTimes >=RoleDataManager.ArenaMaxStorageNum)
  64. // {
  65. // PromptController.Instance.ShowFloatTextPrompt("已达到最大存储次数");
  66. // return;
  67. // }
  68. ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
  69. }
  70. private void OnClickBtnCancel()
  71. {
  72. this.Hide();
  73. }
  74. }
  75. }