浏览代码

物品兑换

zhaoyang 3 年之前
父节点
当前提交
b75e43bfea

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/CommonGame/BuyConfirmView.cs

@@ -61,7 +61,7 @@ namespace GFGGame
             _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
             if (_maxTimes != 0)
             {
-                _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _buyTimes, _maxTimes);
+                _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
             }
             if (_message != "")
             {
@@ -70,7 +70,7 @@ namespace GFGGame
         }
         private async void OnClickBtnSure()
         {
-            if ((_buyTimes + _count) <= 0 && _maxTimes != 0)
+            if (_maxTimes > 0 && (_buyTimes + _count) >= _maxTimes)
             {
                 PromptController.Instance.ShowFloatTextPrompt("购买次数不足!");
                 return;

+ 10 - 10
GameClient/Assets/Game/HotUpdate/Views/CommonGame/BuyCountView.cs

@@ -41,7 +41,7 @@ namespace GFGGame
         /// </summary>
         private int _costNum;
         /// <summary>
-        /// 最大购买
+        /// 最大购买次数
         /// </summary>
         private int _maxCanBuy;
         // private int _perCount;
@@ -113,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;
 
@@ -165,8 +166,7 @@ namespace GFGGame
         {
             if (_count < _maxCanBuy)
             {
-                ItemExchangeCfg itemExchangeCfg = ItemExchangeCfgArray.Instance.GetCfg(_itemId);
-                _count += itemExchangeCfg != null ? itemExchangeCfg.num : 1;
+                _count += 1;
             }
             UpdateCost();
         }
@@ -181,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;
             }
@@ -191,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;
@@ -209,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))
                 {
@@ -236,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)
@@ -281,7 +281,7 @@ namespace GFGGame
                 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), _exchangeCount, out _costId, out _costNum, out _buyNum);
+                ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), count, out _costId, out _costNum, out _buyNum);
 
             }
         }