|
@@ -9,7 +9,7 @@ namespace GFGGame
|
|
|
|
|
|
private int _itemId;
|
|
private int _itemId;
|
|
private int _count;//本次购买次数
|
|
private int _count;//本次购买次数
|
|
- private int _buyTimes;//已购次数
|
|
|
|
|
|
+ private int _buyTimes = 0;//已购次数
|
|
|
|
|
|
|
|
|
|
private Action _onSuccess;
|
|
private Action _onSuccess;
|
|
@@ -33,13 +33,12 @@ namespace GFGGame
|
|
_ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
_ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
_ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
_ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
}
|
|
}
|
|
- public void SetParams(int itemId, int count, int buyTimes, Action onSuccess, int times = 0, int maxTimes = 0, string message = "")
|
|
|
|
|
|
+ public void SetParams(int itemId, int count, Action onSuccess, string message = "")
|
|
{
|
|
{
|
|
_itemId = itemId;
|
|
_itemId = itemId;
|
|
_count = count;
|
|
_count = count;
|
|
- _buyTimes = buyTimes;
|
|
|
|
- _times = times;
|
|
|
|
- _maxTimes = maxTimes;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
_onSuccess = onSuccess;
|
|
_onSuccess = onSuccess;
|
|
_message = message;
|
|
_message = message;
|
|
|
|
|
|
@@ -51,20 +50,23 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void UpdateView()
|
|
private void UpdateView()
|
|
{
|
|
{
|
|
|
|
+ _buyTimes = 0;
|
|
|
|
+
|
|
ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _buyTimes + _count, out int costId, out int coustNum, out int buyNum);
|
|
ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _buyTimes + _count, out int costId, out int coustNum, out int buyNum);
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
_ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
|
|
_ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
|
|
|
|
+
|
|
_ui.m_txtNum.text = "";
|
|
_ui.m_txtNum.text = "";
|
|
- if (_message != "")
|
|
|
|
|
|
+ _maxTimes = ItemExchangeCfgArray.Instance.GetCfgs(_itemId)[0].maxLimit;
|
|
|
|
+ if (_maxTimes != 0)
|
|
{
|
|
{
|
|
- _ui.m_txtNum.text = _message;
|
|
|
|
|
|
+ _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _buyTimes, _maxTimes);
|
|
}
|
|
}
|
|
- else if (_maxTimes != 0)
|
|
|
|
|
|
+ if (_message != "")
|
|
{
|
|
{
|
|
- _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _buyTimes, _maxTimes);
|
|
|
|
|
|
+ _ui.m_txtNum.text = _message;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
private async void OnClickBtnSure()
|
|
private async void OnClickBtnSure()
|
|
{
|
|
{
|
|
@@ -84,26 +86,28 @@ namespace GFGGame
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
-
|
|
|
|
- // PromptController.Instance.ShowFloatTextPrompt(costCfg.name + "不足!");
|
|
|
|
Alert.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认", (AlertWindow.AlertCallback)((object data) =>
|
|
Alert.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认", (AlertWindow.AlertCallback)((object data) =>
|
|
- {
|
|
|
|
- int costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
|
|
|
|
- ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(costId);
|
|
|
|
- BuyItemConteoller.Show(costId, (int)currencyRatioCfg.costId, (int)currencyRatioCfg.num, (int)currencyRatioCfg.costNum, costNeedCount, ConstBuyType.TYPE_ITEM, 0, null, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
|
|
|
|
- }));
|
|
|
|
|
|
+ {
|
|
|
|
+ int costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
|
|
|
|
+ ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(costId);
|
|
|
|
+ BuyItemConteoller.Show(costId, (int)currencyRatioCfg.costId, (int)currencyRatioCfg.num, (int)currencyRatioCfg.costNum, costNeedCount, ConstBuyType.TYPE_ITEM, 0, null, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
|
|
|
|
+ }));
|
|
OnClickBtnCancel();
|
|
OnClickBtnCancel();
|
|
}
|
|
}
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _buyTimes);
|
|
|
|
- if (result && _onSuccess != null)
|
|
|
|
|
|
+ bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
|
|
|
|
+
|
|
|
|
+ if (result)
|
|
{
|
|
{
|
|
- _onSuccess();
|
|
|
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("购买成功!", MessageType.SUCCESS);
|
|
|
|
+ if (_onSuccess != null)
|
|
|
|
+ {
|
|
|
|
+ _onSuccess();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- PromptController.Instance.ShowFloatTextPrompt("购买成功!", MessageType.SUCCESS);
|
|
|
|
|
|
|
|
this.Hide();
|
|
this.Hide();
|
|
}
|
|
}
|