diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs b/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs index 7b160bb684..8a3e9d53e7 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_InventoryUI.cs @@ -43,9 +43,11 @@ namespace BrewMonster.Scripts.Managers [SerializeField] private List moneyTextsLegacy = new List(); [SerializeField] private List moneyTextsTMP = new List(); - [Header("Cash UI (assign any text fields to mirror cash amount)")] - [SerializeField] private List cashTextsLegacy = new List(); - [SerializeField] private List cashTextsTMP = new List(); + [Header("Character UI (assign in Inspector)")] + [SerializeField] private UnityEngine.UI.Text characterNameTextLegacy; + [SerializeField] private TMPro.TextMeshProUGUI characterNameTextTMP; + [SerializeField] private UnityEngine.UI.Text characterLevelTextLegacy; + [SerializeField] private TMPro.TextMeshProUGUI characterLevelTextTMP; private float lastRefreshTime; @@ -53,8 +55,6 @@ namespace BrewMonster.Scripts.Managers private static bool s_hasPendingMoney; private static ulong s_pendingMoneyAmount; private static ulong s_pendingMoneyMaxAmount; - private static bool s_hasPendingCash; - private static int s_pendingCashAmount; // Flags to prevent log spam for extended description warnings // 防止扩展描述警告日志刷屏的标志 @@ -128,6 +128,7 @@ namespace BrewMonster.Scripts.Managers { // Ensure cached values are pushed when the UI is enabled ApplyPendingCurrency(); + UpdateCharacterInfo(); ShowDetailPanel(false); } @@ -207,6 +208,7 @@ namespace BrewMonster.Scripts.Managers view.RenderPackage(inventoryPackButtons, invItems, PKG_INVENTORY, OnInventoryButtonClicked, GetDisplayTextForItem); view.RenderPackage(equipmentPackButtons, eqpItems, PKG_EQUIPMENT, OnInventoryButtonClicked, GetDisplayTextForItem); view.RenderPackage(fashionPackButtons, fshItems, PKG_FASHION, OnInventoryButtonClicked, GetDisplayTextForItem); + UpdateCharacterInfo(); } /// @@ -238,31 +240,26 @@ namespace BrewMonster.Scripts.Managers } } - /// - /// Update all configured cash text components with the current boutique cash amount. - /// Call this when PLAYER_CASH arrives. - /// - public void UpdateCash(int amount) + private void UpdateCharacterInfo() { - s_pendingCashAmount = amount; - s_hasPendingCash = true; - string text = amount.ToString(); - if (cashTextsLegacy != null) + var host = CECGameRun.Instance?.GetHostPlayer(); + string characterName = string.Empty; + string characterLevel = string.Empty; + + if (host != null) { - for (int i = 0; i < cashTextsLegacy.Count; i++) - { - var t = cashTextsLegacy[i]; - if (t != null) t.text = text; - } - } - if (cashTextsTMP != null) - { - for (int i = 0; i < cashTextsTMP.Count; i++) - { - var t = cashTextsTMP[i]; - if (t != null) t.text = text; - } + characterName = host.GetName() ?? string.Empty; + characterLevel = host.GetBasicProps().iLevel.ToString(); } + + if (characterNameTextLegacy != null) + characterNameTextLegacy.text = characterName; + if (characterNameTextTMP != null) + characterNameTextTMP.text = characterName; + if (characterLevelTextLegacy != null) + characterLevelTextLegacy.text = characterLevel; + if (characterLevelTextTMP != null) + characterLevelTextTMP.text = characterLevel; } // Public static entry points to cache values when UI is unavailable @@ -287,36 +284,12 @@ namespace BrewMonster.Scripts.Managers } } - public static void CacheCash(int amount) - { - s_pendingCashAmount = amount; - s_hasPendingCash = true; - // If an instance exists (even inactive), push immediately so the value is ready - var all = Resources.FindObjectsOfTypeAll(); - if (all != null) - { - for (int i = 0; i < all.Length; i++) - { - var ui = all[i]; - if (ui != null && ui.gameObject.scene.IsValid()) - { - ui.ApplyPendingCurrency(); - break; - } - } - } - } - private void ApplyPendingCurrency() { if (s_hasPendingMoney) { UpdateMoney(s_pendingMoneyAmount, s_pendingMoneyMaxAmount); } - if (s_hasPendingCash) - { - UpdateCash(s_pendingCashAmount); - } } private void OnInventoryButtonClicked(byte package, int slot) diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index b57b9b3d3a..8d394ace3e 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1003,6 +1003,19 @@ namespace CSNetwork break; case CommandID.PLAYER_CASH: { + if (pDataBuf != null) + { + try + { + var cashData = GPDataTypeHelper.FromBytes(pDataBuf); + int cashAmount = cashData.cash_amount; + PostToUnityContext(() => ShopUIManager.CacheCash(cashAmount)); + } + catch (Exception ex) + { + } + } + EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_IVTRINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, iHostID); break; diff --git a/Assets/PerfectWorld/Scripts/UI/ShopItemPanel.cs b/Assets/PerfectWorld/Scripts/UI/ShopItemPanel.cs index 6e4b377cca..8ddc14a964 100644 --- a/Assets/PerfectWorld/Scripts/UI/ShopItemPanel.cs +++ b/Assets/PerfectWorld/Scripts/UI/ShopItemPanel.cs @@ -51,7 +51,14 @@ public class ShopItemPanel : MonoBehaviour { if (itemData.buy[i].price > 0) { - bestPrice = itemData.buy[i].price; + if (itemData.buy[i].price / 100 == 0 && itemData.buy[i].price != 0) + { + gameObject.GetComponent