Forráskód Böngészése

养护材料提示

zhaoyang 2 éve
szülő
commit
b6fa69e616

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

@@ -166,9 +166,14 @@ namespace GFGGame
             return itemData;
         }
 
-        public static Boolean CheckItemEnough(int itemId, int num)
+        public static Boolean CheckItemEnough(int itemId, long num, bool showTips = false)
         {
             long hasNum = ItemDataManager.GetItemNum(itemId);
+            if (hasNum < num && showTips)
+            {
+                ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+                PromptController.Instance.ShowFloatTextPrompt(string.Format("【{0}】 不足", itemCfg.name));
+            }
             return hasNum >= num;
         }
 

+ 11 - 2
GameClient/Assets/Game/HotUpdate/Views/ClothingFoster/ClothingFosterView.cs

@@ -119,11 +119,20 @@ namespace GFGGame
         }
         private async void OnClickBtnFoster()
         {
-            if (!_canFoster)
+            SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgsBysuitId(_suitId)[_index];
+
+            if (!ItemUtil.CheckItemEnough(cfg.costId, cfg.costNum))
             {
-                PromptController.Instance.ShowFloatTextPrompt("材料不足");
+                long has = ItemDataManager.GetItemNum(cfg.costId);
+                ItemUtil.BuyCurrency(cfg.costId, cfg.costNum - has);
                 return;
             }
+
+            for (int i = 0; i < cfg.materialsArr.Length; i++)
+            {
+                if (!ItemUtil.CheckItemEnough(cfg.materialsArr[i][0], cfg.materialsArr[i][1], true)) return;
+            }
+
             int result = await SuitFosterProxy.SendMaintainSuit(_suitId, _index + 1);
             if (result == ErrorCode.ERR_Success)
             {

+ 17 - 5
GameClient/Assets/Game/HotUpdate/Views/ClothingFoster/ClothingView.cs

@@ -377,11 +377,6 @@ namespace GFGGame
         private async void OnClickBtnRenew()
         {
 
-            if (!_canRenew)
-            {
-                PromptController.Instance.ShowFloatTextPrompt("材料不足");
-                return;
-            }
             SuitFosterData data = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId);
             SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
             if (data.maintainStep < cfg.renewOpenLv)
@@ -389,6 +384,23 @@ namespace GFGGame
                 PromptController.Instance.ShowFloatTextPrompt(string.Format("完成{0}开启焕新", SuitFosterDataManager.Instance.stepNames[cfg.renewOpenLv - 1]));
                 return;
             }
+
+            int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
+            SuitRenewCfg renewCfg = SuitRenewCfgArray.Instance.GetCfg(suitrarity);
+
+            if (!ItemUtil.CheckItemEnough(renewCfg.costId, renewCfg.costNum))
+            {
+                long has = ItemDataManager.GetItemNum(renewCfg.costId);
+                ItemUtil.BuyCurrency(renewCfg.costId, renewCfg.costNum - has);
+                return;
+            }
+
+            for (int i = 0; i < renewCfg.materialsArr.Length; i++)
+            {
+                if (!ItemUtil.CheckItemEnough(renewCfg.materialsArr[i][0], renewCfg.materialsArr[i][1], true)) return;
+            }
+
+
             int result = await SuitFosterProxy.SendMakeNewSuit(_suitId);
             if (result == ErrorCode.ERR_Success)
             {