소스 검색

物品兑换

zhaoyang 3 년 전
부모
커밋
cd57938441

+ 1 - 1
GameClient/Assets/Game/CSShare

@@ -1 +1 @@
-Subproject commit 2d147924ec65a6eae6137bc96c60814f90302cd4
+Subproject commit e47a74a9267b94d80f3129e4c2af1953bb4f16dd

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Controller/BuyConfirmController.cs

@@ -7,13 +7,13 @@ namespace GFGGame
     {
         private static BuyConfirmView _buyConfirmView;
 
-        public static void Show(int itemId, int count, int costId, int costCount, Action onSuccess, int times = 0, int maxTimes = 0, string message = "")
+        public static void Show(int itemId, int count, int buyTimes, Action onSuccess, int times = 0, int maxTimes = 0, string message = "")
         {
             if (_buyConfirmView == null)
             {
                 _buyConfirmView = new BuyConfirmView();
             }
-            _buyConfirmView.SetParams(itemId, count, costId, costCount, onSuccess, times, maxTimes, message);
+            _buyConfirmView.SetParams(itemId, count, buyTimes, onSuccess, times, maxTimes, message);
             _buyConfirmView.Show();
         }
 

+ 6 - 4
GameClient/Assets/Game/HotUpdate/Utils/ItemUtil.cs

@@ -66,9 +66,9 @@ namespace GFGGame
             int lastBuyCount = currencyRatioCfg.maxLimit - powerBuyTimes;
 
             string showTxt = string.Format("每5分钟回复1点体力\n今日剩余购买{0}/{1}次", lastBuyCount, currencyRatioCfg.maxLimit);
-            BuyConfirmController.Show(ConstItemID.POWER, currencyRatioCfg.num, currencyRatioCfg.costId, currencyRatioCfg.costNum, () =>
+            BuyConfirmController.Show(ConstItemID.POWER, 1, powerBuyTimes, () =>
             {
-                NumericHelper.RequestAddAttributePoint(GameGlobal.zoneScene, NumericType.PowerBuyTimes).Coroutine();
+                // NumericHelper.RequestAddAttributePoint(GameGlobal.zoneScene, NumericType.PowerBuyTimes).Coroutine();
                 if (onSuccess != null)
                 {
                     onSuccess();
@@ -82,10 +82,12 @@ namespace GFGGame
             ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(ConstItemID.GOLD);
             int count = value > 0 ? value : currencyRatioCfg.num;
             int costCount = GetCostItemCount(ConstItemID.GOLD, count);
+            int goldBuyTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.GoldBuyTimes);
+
             int lastBuyCount = currencyRatioCfg.maxLimit - GameGlobal.myNumericComponent.GetAsInt(NumericType.GoldBuyTimes);
-            BuyConfirmController.Show(ConstItemID.GOLD, count, currencyRatioCfg.costId, costCount, () =>
+            BuyConfirmController.Show(ConstItemID.GOLD, 1, goldBuyTimes, () =>
             {
-                NumericHelper.RequestAddAttributePoint(GameGlobal.zoneScene, NumericType.GoldBuyTimes).Coroutine();
+                // NumericHelper.RequestAddAttributePoint(GameGlobal.zoneScene, NumericType.GoldBuyTimes).Coroutine();
                 if (onSuccess != null)
                 {
                     onSuccess();

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

@@ -8,9 +8,10 @@ namespace GFGGame
         private UI_BuyConfirmUI _ui;
 
         private int _itemId;
-        private int _costId;
-        private int _count;
-        private int _costCount;
+        private int _count;//本次购买次数
+        private int _buyTimes;//已购次数
+
+
         private Action _onSuccess;
         private int _times = 0;
         private int _maxTimes = 0;
@@ -32,12 +33,11 @@ namespace GFGGame
             _ui.m_btnSure.onClick.Add(OnClickBtnSure);
             _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
         }
-        public void SetParams(int itemId, int count, int costId, int costCount, Action onSuccess, int times = 0, int maxTimes = 0, string message = "")
+        public void SetParams(int itemId, int count, int buyTimes, Action onSuccess, int times = 0, int maxTimes = 0, string message = "")
         {
             _itemId = itemId;
             _count = count;
-            _costId = costId;
-            _costCount = costCount;
+            _buyTimes = buyTimes;
             _times = times;
             _maxTimes = maxTimes;
             _onSuccess = onSuccess;
@@ -51,9 +51,10 @@ namespace GFGGame
         }
         private void UpdateView()
         {
+            ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _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}", _costCount, costCfg.name, _count, itemCfg.name);
+            ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
+            _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
             _ui.m_txtNum.text = "";
             if (_message != "")
             {
@@ -61,20 +62,22 @@ namespace GFGGame
             }
             else if (_maxTimes != 0)
             {
-                _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _times, _maxTimes);
+                _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _buyTimes, _maxTimes);
             }
 
         }
-        private void OnClickBtnSure()
+        private async void OnClickBtnSure()
         {
-            if (_times <= 0 && _maxTimes != 0)
+            if ((_buyTimes + _count) <= 0 && _maxTimes != 0)
             {
                 PromptController.Instance.ShowFloatTextPrompt("购买次数不足!");
                 return;
             }
-            if (ItemDataManager.GetItemNum(_costId) < _costCount)
+            ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _buyTimes + _count, out int costId, out int coustNum, out int buyNum);
+
+            if (ItemDataManager.GetItemNum(costId) < coustNum)
             {
-                ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(_costId);
+                ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
                 if (_itemId == ConstItemID.GOLD)
                 {
                     PromptController.Instance.ShowFloatTextPrompt("鲛绡不足,请前往商城选购");
@@ -85,21 +88,18 @@ namespace GFGGame
                     // PromptController.Instance.ShowFloatTextPrompt(costCfg.name + "不足!");
                     Alert.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认", (AlertWindow.AlertCallback)((object data) =>
                                        {
-                                           int costNeedCount = _costCount - 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();
                 }
 
                 return;
             }
-            ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(_itemId);
 
-            // int count = (int)Math.Ceiling((decimal)_costCount / currencyRatioCfg.costNum * currencyRatioCfg.num);
-            int count = ItemUtil.GetItemExChangeCount(_itemId, _costCount);
-            ItemUtil.AddItemUseCost(_itemId, count, _costId, _costCount);
-            if (_onSuccess != null)
+            bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _buyTimes);
+            if (result && _onSuccess != null)
             {
                 _onSuccess();
             }