|
@@ -8,14 +8,7 @@ namespace GFGGame
|
|
|
{
|
|
|
private UI_BuyConfirmUI _ui;
|
|
|
|
|
|
- private int _itemId;
|
|
|
- private int _count;//本次购买次数
|
|
|
- private int _buyTimes = 0;//已购次数
|
|
|
|
|
|
-
|
|
|
- private Action _onSuccess;
|
|
|
- private int _maxTimes = 0;
|
|
|
- private string _message = "";
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
if (_ui != null)
|
|
@@ -23,7 +16,6 @@ namespace GFGGame
|
|
|
_ui.Dispose();
|
|
|
_ui = null;
|
|
|
}
|
|
|
- BuyConfirmController.Dispose();
|
|
|
base.Dispose();
|
|
|
}
|
|
|
|
|
@@ -39,89 +31,40 @@ namespace GFGGame
|
|
|
_ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
|
_ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
|
}
|
|
|
- public void SetParams(int itemId, int count, Action onSuccess, string message = "")
|
|
|
+ protected override void AddEventListener()
|
|
|
{
|
|
|
- _itemId = itemId;
|
|
|
- _count = count;
|
|
|
-
|
|
|
- _onSuccess = onSuccess;
|
|
|
- _message = message;
|
|
|
-
|
|
|
+ base.AddEventListener();
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
|
|
|
}
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
UpdateView();
|
|
|
}
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
|
|
|
+ }
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
- _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
|
|
|
-
|
|
|
- ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum, out int buyNum);
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
|
- ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
|
- _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.costIdBuyFightTimes);
|
|
|
|
|
|
- _ui.m_txtNum.text = "";
|
|
|
- _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
|
|
|
- if (_maxTimes != 0)
|
|
|
- {
|
|
|
- _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
|
|
|
- }
|
|
|
- if (_message != "")
|
|
|
- {
|
|
|
- _ui.m_txtNum.text = _message;
|
|
|
- }
|
|
|
+ _ui.m_txtMessage.text = string.Format("是否使用{0}{1}增加1次飞花令挑战次数?", GlobalCfgArray.globalCfg.costNumBuyFightTimes, itemCfg.name);
|
|
|
+ _ui.m_txtTips.text = string.Format("(今天已购买{0}/{1}次)", GlobalCfgArray.globalCfg.limitDailyBuyFightTimes - RoleDataManager.ArenaBuyFightTimes, GlobalCfgArray.globalCfg.limitDailyBuyFightTimes);
|
|
|
}
|
|
|
- private async void OnClickBtnSure()
|
|
|
+ private void OnClickBtnSure()
|
|
|
{
|
|
|
- if (_maxTimes > 0 && (_buyTimes + _count) > _maxTimes)
|
|
|
- {
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
|
|
|
- return;
|
|
|
- }
|
|
|
- ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum, out int buyNum);
|
|
|
-
|
|
|
- Debug.Log(costId + "数量:" + ItemDataManager.GetItemNum(costId));
|
|
|
- if (ItemDataManager.GetItemNum(costId) < coustNum)
|
|
|
+ if (ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.costIdBuyFightTimes) < GlobalCfgArray.globalCfg.costNumBuyFightTimes)
|
|
|
{
|
|
|
- ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
|
- if (_itemId == ConstItemID.DIAMOND_PURPLE)
|
|
|
- {
|
|
|
- PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- AlertUI.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认", (AlertWindow.AlertCallback)((object data) =>
|
|
|
- {
|
|
|
- long costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
|
|
|
- BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, null, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
|
|
|
- }));
|
|
|
- OnClickBtnCancel();
|
|
|
- }
|
|
|
-
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("消耗不足");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
|
|
|
-
|
|
|
- if (result)
|
|
|
- {
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
|
|
|
- if (_onSuccess != null)
|
|
|
- {
|
|
|
- _onSuccess();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.Hide();
|
|
|
+ ArenaSproxy.ReqBuyArenaFightTimes().Coroutine();
|
|
|
}
|
|
|
private void OnClickBtnCancel()
|
|
|
{
|
|
|
this.Hide();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|