|
@@ -2,6 +2,7 @@ using UI.CommonGame;
|
|
|
using System;
|
|
|
using FairyGUI;
|
|
|
using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -40,7 +41,7 @@ namespace GFGGame
|
|
|
/// </summary>
|
|
|
private int _costNum;
|
|
|
/// <summary>
|
|
|
- /// 最大购买量
|
|
|
+ /// 最大购买次数
|
|
|
/// </summary>
|
|
|
private int _maxCanBuy;
|
|
|
// private int _perCount;
|
|
@@ -83,7 +84,7 @@ namespace GFGGame
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="buyId">购买物品对应的编号,非必须为物品Id</param>
|
|
|
- /// <param name="minBuyCount">最低兑换次数</param>
|
|
|
+ /// <param name="minBuyCount">最低兑换个数</param>
|
|
|
/// <param name="buyType">购买类型,对应ConstBuyType</param>
|
|
|
/// <param name="shopType">商店类型,仅buytype为TYPE_SHOP时有用</param>
|
|
|
/// <param name="onSuccess"></param>
|
|
@@ -112,8 +113,9 @@ namespace GFGGame
|
|
|
else if (buyType == ConstBuyType.TYPE_ITEM)
|
|
|
{
|
|
|
ItemExchangeCfg itemExchangeCfg = ItemExchangeCfgArray.Instance.GetCfg(buyId);
|
|
|
- int maxBuyCount = (int)Math.Floor((decimal)(ItemDataManager.GetItemNum(itemExchangeCfg.costId) / itemExchangeCfg.costNumArr[0]));
|
|
|
+ _count = (int)Math.Ceiling(Convert.ToDecimal(minBuyCount) / Convert.ToDecimal(itemExchangeCfg.num));
|
|
|
|
|
|
+ int maxBuyCount = (int)Math.Floor((decimal)(ItemDataManager.GetItemNum(itemExchangeCfg.costId) / itemExchangeCfg.costNumArr[0]));
|
|
|
_maxCanBuy = Math.Min(Math.Min(maxCount, maxBuyCount), itemExchangeCfg.maxLimit == 0 ? maxCount : itemExchangeCfg.maxLimit - ItemDataManager.GetItemExchangeTimes(buyId));
|
|
|
_itemId = buyId;
|
|
|
|
|
@@ -154,44 +156,7 @@ namespace GFGGame
|
|
|
SetBtnState();
|
|
|
}
|
|
|
|
|
|
- private void OnTouchPlusBegin()
|
|
|
- {
|
|
|
- _selectTimeCount = 0;
|
|
|
- _consumeSelectIndex = 1;
|
|
|
- Timers.inst.Add(_delay / 1000, 0, OnTimedEvent);
|
|
|
- }
|
|
|
- private void OnTouchMinusBegin()
|
|
|
- {
|
|
|
- _selectTimeCount = 0;
|
|
|
- _consumeSelectIndex = 0;
|
|
|
- Timers.inst.Add(_delay / 1000, 0, OnTimedEvent);
|
|
|
- }
|
|
|
- private void OnTimedEvent(object param)
|
|
|
- {
|
|
|
- _selectTimeCount += _delay;
|
|
|
|
|
|
- if (_selectTimeCount >= longpress)
|
|
|
- {
|
|
|
- if (_consumeSelectIndex == 0)
|
|
|
- {
|
|
|
- if (!CommonUtil.Instance.CheckPointIsOnComponent(_ui.m_btnMinus, CommonUtil.Instance.GetMouseV2Point()))
|
|
|
- {
|
|
|
- Timers.inst.Remove(OnTimedEvent);
|
|
|
- return;
|
|
|
- }
|
|
|
- this.OnClickBtnMinus();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CommonUtil.Instance.CheckPointIsOnComponent(_ui.m_btnPlus, CommonUtil.Instance.GetMouseV2Point()))
|
|
|
- {
|
|
|
- Timers.inst.Remove(OnTimedEvent);
|
|
|
- return;
|
|
|
- }
|
|
|
- this.OnClickBtnPlus();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
private void OnClickBtnAll()
|
|
|
{
|
|
|
_count = _maxCanBuy;
|
|
@@ -216,7 +181,7 @@ namespace GFGGame
|
|
|
{
|
|
|
string inputStr = _ui.m_txtCount.text.Trim();
|
|
|
|
|
|
- if (inputStr == null || int.Parse(inputStr) <= _minBuyCount)
|
|
|
+ if (_count <= _minBuyCount)
|
|
|
{
|
|
|
_ui.m_btnMinus.enabled = false;
|
|
|
}
|
|
@@ -226,7 +191,7 @@ namespace GFGGame
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (inputStr != null && (int.Parse(inputStr) >= _maxCanBuy))
|
|
|
+ if (_count >= _maxCanBuy)
|
|
|
{
|
|
|
_ui.m_btnPlus.enabled = false;
|
|
|
_ui.m_btnAll.enabled = false;
|
|
@@ -244,7 +209,7 @@ namespace GFGGame
|
|
|
int price = int.Parse(_ui.m_txtPrice.text.Trim());
|
|
|
|
|
|
|
|
|
- if (count > 0)
|
|
|
+ if (_count > 0)
|
|
|
{
|
|
|
if (price > ItemDataManager.GetItemNum(_costId))
|
|
|
{
|
|
@@ -271,10 +236,10 @@ namespace GFGGame
|
|
|
case ConstBuyType.TYPE_NORMAL:
|
|
|
break;
|
|
|
case ConstBuyType.TYPE_ITEM:
|
|
|
- result = await ItemExchangeSProxy.ItemExchange(_buyId, count);
|
|
|
+ result = await ItemExchangeSProxy.ItemExchange(_buyId, _count);
|
|
|
break;
|
|
|
case ConstBuyType.TYPE_SHOP:
|
|
|
- result = await ShopSProxy.ShopBuy(_shopType, _buyId, count);
|
|
|
+ result = await ShopSProxy.ShopBuy(_shopType, _buyId, _count);
|
|
|
break;
|
|
|
}
|
|
|
if (_onSuccess != null)
|
|
@@ -313,13 +278,52 @@ namespace GFGGame
|
|
|
}
|
|
|
else if (_buyType == ConstBuyType.TYPE_ITEM)
|
|
|
{
|
|
|
+ ItemExchangeCfg itemExchangeCfg = ItemExchangeCfgArray.Instance.GetCfg(_itemId);
|
|
|
+ int _exchangeCount = (int)Math.Ceiling(Convert.ToDecimal(count) / Convert.ToDecimal(itemExchangeCfg.num));
|
|
|
|
|
|
ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), count, out _costId, out _costNum, out _buyNum);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void OnTouchPlusBegin()
|
|
|
+ {
|
|
|
+ _selectTimeCount = 0;
|
|
|
+ _consumeSelectIndex = 1;
|
|
|
+ Timers.inst.Add(_delay / 1000, 0, OnTimedEvent);
|
|
|
+ }
|
|
|
+ private void OnTouchMinusBegin()
|
|
|
+ {
|
|
|
+ _selectTimeCount = 0;
|
|
|
+ _consumeSelectIndex = 0;
|
|
|
+ Timers.inst.Add(_delay / 1000, 0, OnTimedEvent);
|
|
|
+ }
|
|
|
+ private void OnTimedEvent(object param)
|
|
|
+ {
|
|
|
+ _selectTimeCount += _delay;
|
|
|
|
|
|
+ if (_selectTimeCount >= longpress)
|
|
|
+ {
|
|
|
+ if (_consumeSelectIndex == 0)
|
|
|
+ {
|
|
|
+ if (!CommonUtil.Instance.CheckPointIsOnComponent(_ui.m_btnMinus, CommonUtil.Instance.GetMouseV2Point()))
|
|
|
+ {
|
|
|
+ Timers.inst.Remove(OnTimedEvent);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.OnClickBtnMinus();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!CommonUtil.Instance.CheckPointIsOnComponent(_ui.m_btnPlus, CommonUtil.Instance.GetMouseV2Point()))
|
|
|
+ {
|
|
|
+ Timers.inst.Remove(OnTimedEvent);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.OnClickBtnPlus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
public void Reset()
|
|
|
{
|
|
|
_buyId = 0;
|