From 8f1e4dc19a0664e6a8ee4fdad2065efb5c16d053 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 31 十月 2025 16:08:09 +0800
Subject: [PATCH] 0312 购买物品 拥有数量如果是能自动转换货币的显示货币值否则显示物品数量;物品图标下标显示购买的总数量;强制刷新武将界面的排版

---
 Main/System/Store/BuyItemWin.cs    |   18 +++++++++++++++---
 Main/System/HeroUI/HeroTrainWin.cs |   25 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/Main/System/HeroUI/HeroTrainWin.cs b/Main/System/HeroUI/HeroTrainWin.cs
index 11d1c80..fe2b66f 100644
--- a/Main/System/HeroUI/HeroTrainWin.cs
+++ b/Main/System/HeroUI/HeroTrainWin.cs
@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Linq;
+using Cysharp.Threading.Tasks;
 using UnityEngine;
 using UnityEngine.UI;
 
@@ -196,6 +197,7 @@
         Display();
     }
 
+
     protected override void OnPreClose()
     {
         PackManager.Instance.RefreshItemLockEvent -= RefreshItemLockEvent;
@@ -253,8 +255,31 @@
         RefreshRedImg();
 
         HeroUIManager.Instance.RemoveNewHero(hero.heroId);
+        ForceRefreshLayout();
     }
 
+    /// <summary>
+    /// 寮哄埗鍒锋柊Layout锛岃В鍐冲祵濂桳ayout鍜孋ontentSizeFitter鐨勯噸鍙犻棶棰�
+    /// </summary>
+    async UniTask ForceRefreshLayout()
+    {
+        await UniTask.DelayFrame(2);
+        // 鍒锋柊鎵�鏈塋ayout缁勪欢
+        var layouts = allAttrScroll.GetComponentsInChildren<LayoutGroup>(true);
+        foreach (var layout in layouts)
+        {
+            LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>());
+        }
+        await UniTask.DelayFrame(2);
+        // 鍒锋柊鎵�鏈塋ayout缁勪欢
+        foreach (var layout in layouts)
+        {
+            LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>());
+        }
+
+    }
+
+
     void RefreshItemLockEvent(PackType type, string guid, bool lockState)
     {
         if (type != PackType.Hero)
diff --git a/Main/System/Store/BuyItemWin.cs b/Main/System/Store/BuyItemWin.cs
index 649f0d0..c4c99b9 100644
--- a/Main/System/Store/BuyItemWin.cs
+++ b/Main/System/Store/BuyItemWin.cs
@@ -37,10 +37,10 @@
         var shopConfig = StoreConfig.Get(StoreModel.Instance.buyShopID);
         var itemID = shopConfig.ItemID;
         var itemCount = shopConfig.ItemCnt;
-        itemCell.Init(new ItemCellModel(itemID, false, itemCount));
+        itemCell.Init(new ItemCellModel(itemID, false, itemCount*useCnt));
         var itemConfig = ItemConfig.Get(itemID);
         nameText.text = itemConfig.ItemName;
-        countText.text = Language.Get("storename12", PackManager.Instance.GetItemCountByID(PackType.Item, itemID));
+        countText.text = Language.Get("storename12", GetItemCount(itemID));
         descText.text = itemConfig.Description;
 
         var buyCnt = StoreModel.Instance.GetShopLimitBuyCount(StoreModel.Instance.buyShopID);
@@ -59,7 +59,7 @@
     {
         var shopConfig = StoreConfig.Get(StoreModel.Instance.buyShopID);
         useCnt = value;
-        itemCell.countText.text = value.ToString();
+        itemCell.countText.text = UIHelper.ReplaceLargeNum(value*shopConfig.ItemCnt);
 
         string limitStr = "";
         if (shopConfig.LimitCnt == 0)
@@ -93,4 +93,16 @@
         CloseWindow();
         StoreModel.Instance.SendBuyShopItem(StoreConfig.Get(StoreModel.Instance.buyShopID), useCnt);
     }
+
+    //濡傛灉鐗╁搧鏄嚜鍔ㄨ浆鎹㈣揣甯佺被鍨嬬殑锛屽垯杩斿洖璐у竵鏁伴噺锛屽惁鍒欒繑鍥炵墿鍝佹暟閲�
+    long GetItemCount(int id)
+    {
+        var config = ItemConfig.Get(id);
+        if (config.Effect1 == 264)
+        {
+            return UIHelper.GetMoneyCnt(config.EffectValueB1);
+        }
+
+        return PackManager.Instance.GetItemCountByID(PackType.Item, id);
+    }
 }

--
Gitblit v1.8.0