BuyConfirmView.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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次飞花令挑战次数? \n\u3000\u3000\u3000\u3000(开通璇玑卡可储存次数)", 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. int costId = GlobalCfgArray.globalCfg.costIdBuyFightTimes;
  53. long needNum = GlobalCfgArray.globalCfg.costNumBuyFightTimes;
  54. if (!ItemUtil.CheckItemEnough(costId, needNum))
  55. {
  56. long has = ItemDataManager.GetItemNum(costId);
  57. ItemUtil.BuyCurrency(costId, needNum - has);
  58. return;
  59. }
  60. // if (RoleDataManager.ArenaFightTimes >=RoleDataManager.ArenaMaxStorageNum)
  61. // {
  62. // PromptController.Instance.ShowFloatTextPrompt("已达到最大存储次数");
  63. // return;
  64. // }
  65. ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
  66. }
  67. private void OnClickBtnCancel()
  68. {
  69. this.Hide();
  70. }
  71. }
  72. }