zhaoyang 3 年 前
コミット
d12ed65e0b

+ 1 - 1
GameClient/Assets/Game/CSShare

@@ -1 +1 @@
-Subproject commit e47a74a9267b94d80f3129e4c2af1953bb4f16dd
+Subproject commit 43d490981b31602f519872ecff5b1453dd0ee2b5

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

@@ -20,14 +20,14 @@ namespace GFGGame
         /// <param name="showTips">是否弹购买成功飘字,默认是</param>
         /// <param name="openSource">是否打开来源界面。默认否</param>
         /// <param name="count">兑换总量</param>
-        public static void Show(int itemId, int costId, int perCount, int perCostCount, int count, int buyType = ConstBuyType.TYPE_NORMAL, int shopType = 0, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
+        public static void Show(int itemId, int count, int buyType = ConstBuyType.TYPE_NORMAL, int shopType = 0, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
         {
             if (_buyCountView == null)
             {
                 _buyCountView = new BuyCountView();
             }
             _buyCountView.Reset();
-            _buyCountView.SetParams(itemId, costId, perCount, perCostCount, count, buyType, shopType, onSuccess, showTips, openSource, maxCount);
+            _buyCountView.SetParams(itemId, count, buyType, shopType, onSuccess, showTips, openSource, maxCount);
             _buyCountView.Show();
 
         }

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

@@ -7,13 +7,13 @@ namespace GFGGame
     {
         private static BuyTipsView _buyTipsView;
 
-        public static void Show(int itemId, int count, int costId, int costCount, Action onSuccess = null)
+        public static void Show(int itemId, int count, Action onSuccess = null)
         {
             if (_buyTipsView == null)
             {
                 _buyTipsView = new BuyTipsView();
             }
-            _buyTipsView.SetParams(itemId, count, costId, costCount, onSuccess);
+            _buyTipsView.SetParams(itemId, count, onSuccess);
             _buyTipsView.Show();
         }
 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Controller/ErrorCodeController.cs

@@ -42,7 +42,7 @@ namespace GFGGame
             }
             else if (ErrorCodeCfgArray.Instance.GetCfg(errorCode) != null)
             {
-                PromptController.Instance.ShowFloatTextPrompt("errorCode " + errorCode.ToString() + ErrorCodeCfgArray.Instance.GetCfg(errorCode));
+                PromptController.Instance.ShowFloatTextPrompt(errorCode.ToString() + ErrorCodeCfgArray.Instance.GetCfg(errorCode).tips);
                 ET.Log.Error("errorCode" + errorCode.ToString());
                 return true;
             }

+ 5 - 5
GameClient/Assets/Game/HotUpdate/Data/Cache/LuckyBoxBonusDataCache.cs

@@ -149,9 +149,9 @@ namespace GFGGame
             }
             else
             {
-                ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(itemId);
-                int costHasNum = ItemDataManager.GetItemNum(currencyRatioCfg.costId);
-                int costNeedNum = ItemUtil.GetCostItemCount(itemId, count - hasNum);
+
+                ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(itemId, ItemDataManager.GetItemExchangeTimes(itemId), count, out int costId, out int costNeedNum, out int buyNum);
+                int costHasNum = ItemDataManager.GetItemNum(costId);
                 if (costHasNum >= costNeedNum)
                 {
                     if (itemId == ConstItemID.GOLD)
@@ -160,12 +160,12 @@ namespace GFGGame
                     }
                     else
                     {
-                        BuyTipsController.Show(itemId, count - hasNum, currencyRatioCfg.costId, costNeedNum, onSuccess);
+                        BuyTipsController.Show(itemId, count - hasNum, onSuccess);
                     }
                 }
                 else
                 {
-                    ItemUtil.ExchangeItemById(currencyRatioCfg.costId, costNeedNum - costHasNum, true, null, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED, true);
+                    ItemUtil.ExchangeItemById(costId, costNeedNum - costHasNum, true, null, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED, true);
                 }
             }
         }

+ 24 - 3
GameClient/Assets/Game/HotUpdate/Data/ItemDataManager.cs

@@ -11,6 +11,7 @@ namespace GFGGame
     public class ItemDataManager
     {
         private static Dictionary<int, ItemData> _dataDic = new Dictionary<int, ItemData>();
+        private static Dictionary<int, int> _itemExchangeDic = new Dictionary<int, int>();
         delegate object MemberGetDelegate(ItemCfg p);
 
         public static void Add(int itemID, int itemNum)
@@ -108,14 +109,34 @@ namespace GFGGame
 
         public static void InitServerDataItemAttribute(List<ItemAttributeProto> infos)
         {
-            foreach(var info in infos)
+            foreach (var info in infos)
             {
-                if(_dataDic.TryGetValue(info.ConfigId, out var itemData))
+                if (_dataDic.TryGetValue(info.ConfigId, out var itemData))
                 {
                     itemData.SetAttributes(info.Ks, info.Vs);
                 }
             }
         }
+        public static void InitItemExchange(int itemId, int exchangTimes)
+        {
+            if (_itemExchangeDic.ContainsKey(itemId))
+            {
+                _itemExchangeDic[itemId] = exchangTimes;
+            }
+            else
+            {
+                _itemExchangeDic.Add(itemId, exchangTimes);
+            }
+        }
+        //»ñÈ¡ÎïÆ·ÒѶһ»´ÎÊý
+        public static int GetItemExchangeTimes(int itemId)
+        {
+            if (_itemExchangeDic.ContainsKey(itemId) == false)
+            {
+                InitItemExchange(itemId, 0);
+            }
+            return _itemExchangeDic[itemId];
+        }
 
         public static void SetAttribute(int itemId, int key, int value)
         {
@@ -177,7 +198,7 @@ namespace GFGGame
 
         public static int GetScore(int itemId, int scoreType)
         {
-            if(_dataDic.TryGetValue(itemId, out var itemData))
+            if (_dataDic.TryGetValue(itemId, out var itemData))
             {
                 return itemData.GetScore(scoreType);
             }

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Data/ShopDataManager.cs

@@ -6,7 +6,7 @@ namespace GFGGame
 
         public void BuyItem(int itemId, int itemCount, int shopType, ShopCfg shopCfg)
         {
-            BuyItemConteoller.Show(itemId, shopCfg.costID, 1, shopCfg.costNum, itemCount, ConstBuyType.TYPE_SHOP, shopType, null, true, false, GameConst.MAX_COUNT_TO_BUY_ITEMS);
+            BuyItemConteoller.Show(itemId, itemCount, ConstBuyType.TYPE_SHOP, shopType, null, true, false, GameConst.MAX_COUNT_TO_BUY_ITEMS);
         }
     }
 }

+ 10 - 0
GameClient/Assets/Game/HotUpdate/ExcelConfig/Manager/ClothingShopCfgManager.cs

@@ -62,6 +62,16 @@ namespace GFGGame
             return null;
         }
 
+        public void GetMoneyIdAndNum(int buyId, int count, int shopType, out int costId, out int costNum, out int buyNum)
+        {
+            ShopCfg shopCfg = GetShopCfg(buyId, shopType);
+
+            costId = shopCfg.costID;
+            costNum = shopCfg.costNum * count;
+            buyNum = count;
+        }
+
+
         private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
         {
             arrayList.Sort((ShopCfg a, ShopCfg b) =>

+ 1 - 1
GameClient/Assets/Game/HotUpdate/ServerProxy/ItemExchangeSProxy.cs

@@ -12,7 +12,7 @@ namespace GFGGame
             {
                 if (response.Error == ErrorCode.ERR_Success)
                 {
-
+                    ItemDataManager.InitItemExchange(response.ItemId, response.times);
                     EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
                     return true;
                 }

+ 7 - 75
GameClient/Assets/Game/HotUpdate/Utils/ItemUtil.cs

@@ -14,7 +14,7 @@ namespace GFGGame
         /// <param name="showTxtBuyTips">是否显示购买提示</param>
         public static void ExchangeItemById(int itemId, int num, bool showTips = true, Action onSuccess = null, bool openSource = false, int maxCount = 9990, bool showTxtBuyTips = false, string prefix = "")
         {
-            ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(itemId);
+
             if (itemId == ConstItemID.GOLD)
             {
                 AddGold(num, onSuccess);
@@ -25,48 +25,16 @@ namespace GFGGame
             }
             else
             {
-                BuyItemConteoller.Show(itemId, currencyRatioCfg.costId, currencyRatioCfg.num, currencyRatioCfg.costNum, num, ConstBuyType.TYPE_ITEM, 0, onSuccess, showTips, openSource, maxCount);
+                BuyItemConteoller.Show(itemId, num, ConstBuyType.TYPE_ITEM, 0, onSuccess, showTips, openSource, maxCount);
                 BuyItemConteoller.showTxtBuyTips = showTxtBuyTips;
             }
         }
 
-        public static ItemExchangeCfg GetCurrencyRatioCfgById(int itemId)
-        {
-            ItemExchangeCfg[] currencyRatioCfgs = ItemExchangeCfgArray.Instance.GetCfgs(itemId);
-            if (currencyRatioCfgs.Length == 0)
-            {
-                UnityEngine.Debug.LogWarning(itemId + "在h货币换算.xlsx中没有配置");
-                return null;
-            }
-            ItemExchangeCfg currencyRatioCfg;
-            if (itemId == ConstItemID.POWER)
-            {
-                int powerBuyTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.PowerBuyTimes);
-                //体力购买次数不同,对应消耗配置不同
-                if (powerBuyTimes < currencyRatioCfgs.Length)
-                {
-                    currencyRatioCfg = currencyRatioCfgs[powerBuyTimes];
-                }
-                else
-                {
-                    currencyRatioCfg = currencyRatioCfgs[currencyRatioCfgs.Length - 1];
-                }
-            }
-            else
-            {
-                currencyRatioCfg = currencyRatioCfgs[currencyRatioCfgs.Length - 1];
-            }
-            return currencyRatioCfg;
-        }
-
         public static void AddPower(string prefix = "", Action onSuccess = null)
         {
-            ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(ConstItemID.POWER);
-            int count = GetCostItemCount(ConstItemID.POWER, currencyRatioCfg.num);
-            int powerBuyTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.PowerBuyTimes);
-            int lastBuyCount = currencyRatioCfg.maxLimit - powerBuyTimes;
-
-            string showTxt = string.Format("每5分钟回复1点体力\n今日剩余购买{0}/{1}次", lastBuyCount, currencyRatioCfg.maxLimit);
+            int maxLimit = ItemExchangeCfgArray.Instance.GetCfgs(ConstItemID.POWER)[0].maxLimit;
+            int lastBuyCount = maxLimit - ItemDataManager.GetItemExchangeTimes(ConstItemID.POWER);
+            string showTxt = string.Format("每5分钟回复1点体力\n今日剩余购买{0}/{1}次", lastBuyCount, maxLimit);
             BuyConfirmController.Show(ConstItemID.POWER, 1, () =>
             {
                 if (onSuccess != null)
@@ -78,12 +46,7 @@ namespace GFGGame
 
         public static void AddGold(int value = 0, Action onSuccess = null)
         {
-            // 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, 1, () =>
             {
                 if (onSuccess != null)
@@ -102,41 +65,10 @@ namespace GFGGame
         public static void AddDiamondRed(int value = 0, Action onSuccess = null)
         {
 
-            ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(ConstItemID.DIAMOND_RED);
-            BuyItemConteoller.Show(currencyRatioCfg.id, currencyRatioCfg.costId, currencyRatioCfg.num, currencyRatioCfg.costNum, value > 0 ? value : currencyRatioCfg.num, ConstBuyType.TYPE_ITEM, 0, onSuccess, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
+            ItemExchangeCfg currencyRatioCfg = ItemExchangeCfgArray.Instance.GetCfgs(ConstItemID.DIAMOND_RED)[0];// GetCurrencyRatioCfgById(ConstItemID.DIAMOND_RED);
+            BuyItemConteoller.Show(currencyRatioCfg.id, value > 0 ? value : currencyRatioCfg.num, ConstBuyType.TYPE_ITEM, 0, onSuccess, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
             BuyItemConteoller.showTxtBuyTips = true;
         }
-        /// <summary>
-        /// 根据物品id和需求量获取兑换消耗品的消耗量
-        /// </summary>
-        public static int GetCostItemCount(int itemId, int count)
-        {
-            ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(itemId);
-            if (currencyRatioCfg != null)
-            {
-                return (int)Math.Ceiling((decimal)count / currencyRatioCfg.num * currencyRatioCfg.costNum);
-
-            }
-            else
-            {
-                return 0;
-            }
-        }
-        /// <summary>
-        /// 根据物品id和兑换消耗品的消耗量获取物品兑换量
-        /// </summary>
-        public static int GetItemExChangeCount(int itemId, int costCount)
-        {
-            ItemExchangeCfg currencyRatioCfg = GetCurrencyRatioCfgById(itemId);
-            if (currencyRatioCfg != null)
-            {
-                return (int)Math.Floor((decimal)costCount / currencyRatioCfg.costNum * currencyRatioCfg.num);
-            }
-            else
-            {
-                return 0;
-            }
-        }
 
         /// <summary>
         /// 添加物品,会消耗物品

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/Common/Controller/ValueBarController.cs

@@ -50,8 +50,8 @@ namespace GFGGame
             {
                 int luckyBoxId = LuckyBoxBonusDataCache.currentBoxId;
                 LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
-                ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(luckyBoxCfg.costID);
-                ItemUtil.ExchangeItemById(luckyBoxCfg.costID, (int)(currencyRatioCfg != null ? currencyRatioCfg.num : 20), true);
+
+                ItemUtil.ExchangeItemById(luckyBoxCfg.costID, 10, true);
 
             }));
         }

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

@@ -1,5 +1,6 @@
 using System;
 using UI.CommonGame;
+using UnityEngine;
 
 namespace GFGGame
 {
@@ -38,7 +39,6 @@ namespace GFGGame
             _itemId = itemId;
             _count = count;
 
-
             _onSuccess = onSuccess;
             _message = message;
 
@@ -50,9 +50,9 @@ namespace GFGGame
         }
         private void UpdateView()
         {
-            _buyTimes = 0;
+            _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
 
-            ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _buyTimes + _count, out int costId, out int coustNum, out int buyNum);
+            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);
@@ -75,22 +75,23 @@ namespace GFGGame
                 PromptController.Instance.ShowFloatTextPrompt("购买次数不足!");
                 return;
             }
-            ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _buyTimes + _count, out int costId, out int coustNum, out int buyNum);
+            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)
             {
                 ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
                 if (_itemId == ConstItemID.GOLD)
                 {
-                    PromptController.Instance.ShowFloatTextPrompt("鲛绡不足,请前往商城选购");
+                    PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
+
                 }
                 else
                 {
                     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);
+                        BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, 0, null, true, true, GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
                     }));
                     OnClickBtnCancel();
                 }

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

@@ -15,12 +15,37 @@ namespace GFGGame
         private float _delay = 300;
         private float longpress = 900;//大于900毫秒才算长按
 
+        /// <summary>
+        /// 购买物品编号
+        /// </summary>
         private int _buyId;
-        private int _costId;
-        private int _perCount;
-        private int _perCostCount;
+        /// <summary>
+        /// 最低购买次数
+        /// </summary>
+        private int _minBuyCount;
+        /// <summary>
+        /// 当前购买次数
+        /// </summary>
         private int _count;
-        private int _maxCount;
+        /// <summary>
+        /// 购买消耗Id
+        /// </summary>
+        private int _costId;//购买消耗Id
+        /// <summary>
+        /// 购买物品数量
+        /// </summary>
+        private int _buyNum;
+        /// <summary>
+        /// 购买物品消耗数量
+        /// </summary>
+        private int _costNum;
+        /// <summary>
+        /// 最大购买量
+        /// </summary>
+        private int _maxCanBuy;
+        // private int _perCount;
+        // private int _perCostCount;
+        // private int _maxCount;
         private bool _openSource;
         private bool _showTips;
         private int _buyType;
@@ -53,73 +78,80 @@ namespace GFGGame
             _ui.m_btnSure.onClick.Add(OnClickBtnSure);
             _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
         }
+
         /// <summary>
         /// 
         /// </summary>
         /// <param name="buyId">购买物品对应的编号,非必须为物品Id</param>
-        /// <param name="costId">消耗品id</param>
-        /// <param name="perCount">单位兑换数量</param>
-        /// <param name="perCostCount">单位消耗数量</param>
-        /// <param name="onSuccess">购买完成回调</param>
+        /// <param name="minBuyCount">最低兑换次数</param>
+        /// <param name="buyType">购买类型,对应ConstBuyType</param>
+        /// <param name="shopType">商店类型,仅buytype为TYPE_SHOP时有用</param>
+        /// <param name="onSuccess"></param>
         /// <param name="showTips">是否弹购买成功飘字,默认是</param>
         /// <param name="openSource">是否打开来源界面。默认否</param>
-        /// <param name="count">兑换总量</param>
-        public void SetParams(int buyId, int costId, int perCount, int perCostCount, int count, int buyType, int shopType = 0, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
+        /// <param name="maxCount"></param>
+        public void SetParams(int buyId, int minBuyCount, int buyType, int shopType = 0, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
         {
-            if (buyType == ConstBuyType.TYPE_SHOP)
-            {
-                _itemId = ClothingShopCfgManager.Instance.GetShopCfg(buyId, shopType).itemID;
-            }
-            else
-            {
-                _itemId = buyId;
-            }
             _buyId = buyId;
-            _costId = costId;
-            _perCount = perCount;
-            _perCostCount = perCostCount;
-            _count = count;
+            _itemId = buyId;
+            _minBuyCount = minBuyCount;
+            _count = _minBuyCount;
             _onSuccess = onSuccess;
-            _maxCount = maxCount;
             _openSource = openSource;
             _showTips = showTips;
             _buyType = buyType;
             _shopType = shopType;
+            if (buyType == ConstBuyType.TYPE_SHOP)
+            {
+                ShopCfg shopCfg = ClothingShopCfgManager.Instance.GetShopCfg(buyId, shopType);
+                int maxBuyCount = (int)Math.Floor((decimal)(ItemDataManager.GetItemNum(shopCfg.costID) / shopCfg.costNum));
+                _maxCanBuy = Math.Min(maxCount, maxBuyCount);
+                _itemId = shopCfg.itemID;
+
+            }
+            else if (buyType == ConstBuyType.TYPE_ITEM)
+            {
+                ItemExchangeCfg itemExchangeCfg = ItemExchangeCfgArray.Instance.GetCfgs(buyId)[0];
+                int maxBuyCount = (int)Math.Floor((decimal)(ItemDataManager.GetItemNum(itemExchangeCfg.costId) / itemExchangeCfg.costNum));
+
+                _maxCanBuy = Math.Min(Math.Min(maxCount, maxBuyCount), itemExchangeCfg.maxLimit - ItemDataManager.GetItemExchangeTimes(buyId));
+                _itemId = buyId;
+
+            }
+            GetMoneyIdAndNum(minBuyCount, out _costId, out _costNum, out _buyNum);
+
+
         }
         protected override void OnShown()
         {
             base.OnShown();
-            _ui.m_txtCount.text = "" + _count;
+            _ui.m_txtCount.text = "" + _minBuyCount;
             UpdateView();
         }
         private void UpdateView()
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
             _ui.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
-            string itemName = itemCfg.name;
-            _ui.m_txtName.text = itemName;
+            _ui.m_txtName.text = itemCfg.name;
+            _ui.m_rarity.visible = false;
+
             if (ItemUtilCS.IsDressUpItem(_itemId))
             {
                 _ui.m_rarity.visible = true;
                 RarityIconController.UpdateRarityIcon(_ui.m_rarity, _itemId, false);
             }
-            else
-            {
-                _ui.m_rarity.visible = false;
-            }
-            ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(_costId);
-            _ui.m_iconPrice.url = "ui://CommonGame/" + costItemCfg.res;
 
-            _ui.m_txtBuyTips.text = string.Format("消耗{0}{1},可兑换{2}{3}", _perCostCount, costItemCfg.name, _perCount, itemCfg.name);
+            ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(_costId);
+            _ui.m_iconPrice.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
             _ui.m_txtBuyTips.visible = false;
+
             UpdateCost();
         }
         private void UpdateCost()
         {
-            int count = int.Parse(_ui.m_txtCount.text.Trim());
-
-            int price = (int)Math.Ceiling((decimal)count / _perCount) * _perCostCount;
-            _ui.m_txtPrice.text = "" + price;
+            GetMoneyIdAndNum(_count, out _costId, out _costNum, out _buyNum);
+            _ui.m_txtCount.text = _count.ToString();
+            _ui.m_txtPrice.text = _costNum.ToString();
             SetBtnState();
         }
 
@@ -137,7 +169,7 @@ namespace GFGGame
         }
         private void OnTimedEvent(object param)
         {
-            _selectTimeCount += _delay; //_timer.Interval;
+            _selectTimeCount += _delay;
 
             if (_selectTimeCount >= longpress)
             {
@@ -163,48 +195,29 @@ namespace GFGGame
         }
         private void OnClickBtnAll()
         {
-            int costHasNum = ItemDataManager.GetItemNum(_costId);
-            int value = (int)Math.Floor((decimal)(costHasNum / _perCostCount * _perCount));
-            // int value = ItemUtil.ItemExChangeCount(_itemId, costHasNum);
-            value = Math.Min(_maxCount, value);
-
-            _ui.m_txtCount.text = value.ToString();
+            _count = _maxCanBuy;
             UpdateCost();
         }
         private void OnClickBtnPlus()
         {
-            string inputStr = _ui.m_txtCount.text.Trim();
-            int value = _count;
-            if (inputStr.Length > 0)
-            {
-                value = int.Parse(inputStr);
-            }
-            if (value < _maxCount)
+            if (_count < _maxCanBuy)
             {
-                value += _perCount;
+                _count += 1;
             }
-            _ui.m_txtCount.text = "" + value;
             UpdateCost();
         }
 
         private void OnClickBtnMinus()
         {
-            string inputStr = _ui.m_txtCount.text.Trim();
-            int value = _count;
-            if (inputStr.Length > 0)
-            {
-                value = int.Parse(inputStr);
-            }
-            value -= _perCount;
-            value = Math.Max(_count, value);
-            _ui.m_txtCount.text = "" + value;
+            _count -= 1;
+            _count = Math.Max(_minBuyCount, _count);
             UpdateCost();
         }
         private void SetBtnState()
         {
             string inputStr = _ui.m_txtCount.text.Trim();
 
-            if (inputStr == null || int.Parse(inputStr) <= _count)
+            if (inputStr == null || int.Parse(inputStr) <= _minBuyCount)
             {
                 _ui.m_btnMinus.enabled = false;
             }
@@ -213,10 +226,8 @@ namespace GFGGame
                 _ui.m_btnMinus.enabled = true;
 
             }
-            int costHasNum = ItemDataManager.GetItemNum(_costId);
-            int maxCanBuy = (int)Math.Floor((decimal)(costHasNum / _perCostCount * _perCount));
-            // int maxCanBuy = ItemUtil.ItemExChangeCount(_itemId, costHasNum);
-            if (inputStr != null && (int.Parse(inputStr) >= maxCanBuy))
+
+            if (inputStr != null && (int.Parse(inputStr) >= _maxCanBuy))
             {
                 _ui.m_btnPlus.enabled = false;
                 _ui.m_btnAll.enabled = false;
@@ -254,10 +265,8 @@ namespace GFGGame
                 }
                 else
                 {
-                    int buyCount = price / _perCostCount * _perCount;
-                    // ItemUtil.AddItemUseCost(_itemId, buyCount, _costId, price);
+
                     bool result = false;
-                    // result
                     switch (_buyType)
                     {
                         case ConstBuyType.TYPE_NORMAL:
@@ -292,17 +301,38 @@ namespace GFGGame
             this.Hide();
         }
 
+        private void GetMoneyIdAndNum(int count, out int _costId, out int _costNum, out int _buyNum)
+        {
+            _costId = 0;
+            _costNum = 0;
+            _buyNum = 0;
+            if (_buyType == ConstBuyType.TYPE_SHOP)
+            {
+
+                ClothingShopCfgManager.Instance.GetMoneyIdAndNum(_buyId, count, _shopType, out _costId, out _costNum, out _buyNum);
 
+            }
+            else if (_buyType == ConstBuyType.TYPE_ITEM)
+            {
+
+                ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), count, out _costId, out _costNum, out _buyNum);
+
+            }
+            // else
+            // {
+
+            // }
+        }
 
 
         public void Reset()
         {
             _buyId = 0;
             _costId = 0;
-            _perCount = 0;
-            _perCostCount = 0;
-            _count = 0;
-            _maxCount = 0;
+            // _perCount = 0;
+            // _perCostCount = 0;
+            _minBuyCount = 0;
+            // _maxCount = 0;
         }
         protected override void OnHide()
         {

+ 15 - 15
GameClient/Assets/Game/HotUpdate/Views/CommonGame/BuyTipsView.cs

@@ -31,12 +31,12 @@ 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 = null)
+        public void SetParams(int itemId, int count, Action onSuccess = null)
         {
             _itemId = itemId;
             _count = count;
-            _costId = costId;
-            _costCount = costCount;
+            // _costId = costId;
+            // _costCount = costCount;
             _onSuccess = onSuccess;
         }
         protected override void OnShown()
@@ -46,29 +46,29 @@ namespace GFGGame
         }
         private void UpdateView()
         {
+            ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, ItemDataManager.GetItemExchangeTimes(_itemId), _count, out _costId, out _costCount, out int buyNum);
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
             _ui.m_txtNeed.text = string.Format("还需要购买{0}个", _count);
             _ui.m_loaNeed.url = ResPathUtil.GetCommonGameResPath(itemCfg.res);
             ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(_costId);
             _ui.m_txtCost.text = string.Format("是否花费{0}{1}购买?", _costCount, costCfg.name);
         }
-        private void OnClickBtnSure()
+        private async void OnClickBtnSure()
         {
-            ItemExchangeCfg currencyRatioCfg = ItemUtil.GetCurrencyRatioCfgById(_itemId);
 
-            int count = ItemUtil.GetItemExChangeCount(_itemId, _costCount);
-            ItemUtil.AddItemUseCost(_itemId, count, _costId, _costCount);
-
-            if (_onSuccess != null)
+            bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
+            if (result)
             {
-                _onSuccess();
+                ItemData itemData = new ItemData();
+                itemData.id = _itemId;
+                itemData.num = _count;
+                ViewManager.Show<RewardView>(itemData);
+                if (_onSuccess != null)
+                {
+                    _onSuccess();
+                }
             }
 
-            ItemData itemData = new ItemData();
-            itemData.id = _itemId;
-            itemData.num = count;
-            ViewManager.Show<RewardView>(new List<ItemData> { itemData });
-
             this.Hide();
         }
         private void OnClickBtnCancel()