12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using UI.CommonGame;
- using UnityEngine;
- namespace GFGGame
- {
- public class BuyConfirmView : BaseWindow
- {
- private UI_BuyConfirmUI _ui;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_BuyConfirmUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_btnSure.onClick.Add(OnClickBtnSure);
- _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
- EventAgent.AddEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
- }
- protected override void OnShown()
- {
- base.OnShown();
- UpdateView();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
- EventAgent.RemoveEventListener(ConstMessage.CLOSE_SHOPPING_TIP, OnClickBtnCancel);
- }
- private void UpdateView()
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.costIdBuyFightTimes);
- _ui.m_txtMessage.text = string.Format("是否使用{0}{1}增加1次飞花令挑战次数? \n\u3000\u3000\u3000\u3000(开通福气卡可储存次数)", GlobalCfgArray.globalCfg.costNumBuyFightTimes, itemCfg.name);
- _ui.m_txtTips.text = string.Format("(今天已购买{0}/{1}次)", GlobalCfgArray.globalCfg.limitDailyBuyFightTimes - RoleDataManager.ArenaBuyFightTimes, GlobalCfgArray.globalCfg.limitDailyBuyFightTimes);
- }
- private void OnClickBtnSure()
- {
- int costId = GlobalCfgArray.globalCfg.costIdBuyFightTimes;
- long needNum = GlobalCfgArray.globalCfg.costNumBuyFightTimes;
- if (!ItemUtil.CheckItemEnough(costId, needNum))
- {
- long has = ItemDataManager.GetItemNum(costId);
- ItemUtil.BuyCurrency(costId, needNum - has);
- return;
- }
- // if (RoleDataManager.ArenaFightTimes >=RoleDataManager.ArenaMaxStorageNum)
- // {
- // PromptController.Instance.ShowFloatTextPrompt("已达到最大存储次数");
- // return;
- // }
- ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
- }
- private void OnClickBtnCancel()
- {
- this.Hide();
- }
- }
- }
|