From eac8aeed7cea1f7ac5e08a4e231281a6a77b522d Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 22 十月 2025 20:09:50 +0800
Subject: [PATCH] 143 演武场-客户端 只在“没有战斗”和“主线战斗道中”时弹结算界面

---
 Main/System/Battle/BattleManager.cs               |   16 ++++
 Main/System/Settlement/BattleSettlementManager.cs |   90 +++++++++++++++-------
 Main/System/Settlement/BattleFailWin.cs           |    7 -
 Main/System/Arena/ArenaBattleVictoryWin.cs        |    7 -
 Main/System/Arena/ArenaBattleFailWin.cs           |    8 -
 Main/System/Settlement/BattleVictoryWin.cs        |    7 -
 Main/Component/UI/Common/PopupWindowsProcessor.cs |   49 +++--------
 7 files changed, 103 insertions(+), 81 deletions(-)

diff --git a/Main/Component/UI/Common/PopupWindowsProcessor.cs b/Main/Component/UI/Common/PopupWindowsProcessor.cs
index 8e65e67..dd730d9 100644
--- a/Main/Component/UI/Common/PopupWindowsProcessor.cs
+++ b/Main/Component/UI/Common/PopupWindowsProcessor.cs
@@ -27,11 +27,12 @@
     /// </summary>
     /// <param name="name">绐楀彛鍚嶇О</param>
     /// <param name="functionId">鍔熻兘ID锛岀敤浜庢寚瀹氱獥鍙g殑鍏蜂綋鍔熻兘鎴栨樉绀烘ā寮�</param>
-    public void Add(string name, int functionId = 0)
+    public void Add(string name, bool isNeedHomeWin = true, int functionId = 0)
     {
         var popupWindow = new PopupWindow()
         {
             window = name,
+            isNeedHomeWin = isNeedHomeWin,
             functionId = functionId,
         };
 
@@ -41,6 +42,7 @@
         }
 
         popupWindowQueue.Add(popupWindow);
+        popupWindowQueue.Sort((x, y) => y.isNeedHomeWin.CompareTo(x.isNeedHomeWin));
     }
 
     /// <summary>
@@ -48,11 +50,12 @@
     /// </summary>
     /// <param name="name">绐楀彛鍚嶇О</param>
     /// <param name="functionId">鍔熻兘ID</param>
-    public void Remove(string name, int functionId = 0)
+    public void Remove(string name, bool isNeedHomeWin = true, int functionId = 0)
     {
         var popupWindow = new PopupWindow()
         {
             window = name,
+            isNeedHomeWin = isNeedHomeWin,
             functionId = functionId,
         };
 
@@ -97,10 +100,10 @@
         if (UIManager.Instance.IsOpened<LoadingWin>())
             return;
 
-        if (!UIManager.Instance.IsOpened<HomeWin>())
+        if (!UIManager.Instance.IsOpened<HomeWin>() && popupWindowQueue[0].isNeedHomeWin)
             return;
 
-        // 绗竴娆℃墦寮�HomeWin鏃惰褰曟椂闂�
+        // 杩涘叆娓告垙绗竴娆℃帹閫佸仛寤惰繜澶勭悊
         if (!homeWinFirstOpened)
         {
             firstTime = Time.realtimeSinceStartup;
@@ -110,6 +113,11 @@
         }
         // 绛夊緟x绉�
         if (Time.realtimeSinceStartup - firstTime < stayTime)
+            return;
+        
+        // 鍙湪鈥滄病鏈夋垬鏂椻�濆拰鈥滀富绾挎垬鏂椻�濇椂鍏佽寮圭獥
+        string activeBattleName = BattleManager.Instance.GetActiveBattleName();
+        if (activeBattleName != "" && activeBattleName != "StoryBattleField")
             return;
 
         if (UIManager.Instance.IsOpened(popupWindowQueue[0].window))
@@ -121,15 +129,12 @@
         if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(popupWindowQueue[0].window))
             return;
 
-
-
-        if (currentWindow.window != null)
+        if (currentWindow != null && currentWindow.window != null)
         {
             //鍒ゆ柇涓婁竴涓帹閫佹槸鍚﹀叧闂�
             UIBase ui = UIManager.Instance.GetUI(currentWindow.window);
             if (ui != null && ui.IsActive())
                 return;
-
         }
 
         currentWindow = popupWindowQueue[0];
@@ -144,7 +149,7 @@
     /// 寮圭獥缁撴瀯浣擄紝鐢ㄤ簬琛ㄧず涓�涓緟澶勭悊鐨勫脊绐楄姹�
     /// 鍖呭惈绐楀彛鍚嶇О鍜屽姛鑳絀D锛岄�氳繃杩欎袱涓瓧娈靛彲浠ュ敮涓�鏍囪瘑涓�涓脊绐楄姹�
     /// </summary>
-    public struct PopupWindow
+    public class PopupWindow
     {
         // 绐楀彛鍚嶇О
         public string window;
@@ -152,31 +157,7 @@
         // 鍔熻兘ID锛岀敤浜庢寚瀹氱獥鍙g殑鍏蜂綋鍔熻兘鎴栨樉绀烘ā寮�
         public int functionId;
 
-        public static bool operator ==(PopupWindow lhs, PopupWindow rhs)
-        {
-            return lhs.window == rhs.window && lhs.functionId == rhs.functionId;
-        }
-
-        public static bool operator !=(PopupWindow lhs, PopupWindow rhs)
-        {
-            return lhs.window != rhs.window || lhs.functionId != rhs.functionId;
-        }
-
-        // 娣诲姞GetHashCode鍜孍quals鏂规硶浠ョ‘淇濈粨鏋勪綋鍙互姝g‘姣旇緝
-        public override bool Equals(object obj)
-        {
-            if (obj is PopupWindow)
-            {
-                PopupWindow other = (PopupWindow)obj;
-                return this.window == other.window && this.functionId == other.functionId;
-            }
-            return false;
-        }
-
-        public override int GetHashCode()
-        {
-            return window.GetHashCode() ^ functionId.GetHashCode();
-        }
+        public bool isNeedHomeWin;
     }
 
 }
\ No newline at end of file
diff --git a/Main/System/Arena/ArenaBattleFailWin.cs b/Main/System/Arena/ArenaBattleFailWin.cs
index 1018955..ef08868 100644
--- a/Main/System/Arena/ArenaBattleFailWin.cs
+++ b/Main/System/Arena/ArenaBattleFailWin.cs
@@ -15,8 +15,7 @@
      [SerializeField] TextEx txtFuncName;
     [SerializeField] ScrollerController scroller;
     JsonData jsonData;
-    string guid;
-
+    string battleName = "ArenaBattleField";
     protected override void InitComponent()
     {
 
@@ -25,8 +24,7 @@
     protected override void OnPreOpen()
     {
         scroller.OnRefreshCell += OnRefreshCell;
-        guid = BattleSettlementManager.Instance.notifyGuid;
-        jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid);
+        jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName);
         if (jsonData == null)
         {
             DelayCloseWindow().Forget();
@@ -39,7 +37,7 @@
     protected override void OnPreClose()
     {
         scroller.OnRefreshCell -= OnRefreshCell;
-        BattleSettlementManager.Instance.WinShowOver(guid);
+        BattleSettlementManager.Instance.WinShowOver(battleName);
     }
 
     // B4 20 鍥炲悎鍒舵垬鏂楃姸鎬� #tagMCTurnFightState  閫氱敤鐨勭粨绠楃姸鎬� State 4-缁撶畻濂栧姳
diff --git a/Main/System/Arena/ArenaBattleVictoryWin.cs b/Main/System/Arena/ArenaBattleVictoryWin.cs
index d16965a..664e23e 100644
--- a/Main/System/Arena/ArenaBattleVictoryWin.cs
+++ b/Main/System/Arena/ArenaBattleVictoryWin.cs
@@ -79,12 +79,11 @@
     [SerializeField] TextEx txtFuncName;
     [SerializeField] ScrollerController scroller;
     JsonData jsonData;
-    string guid;
+    string battleName = "ArenaBattleField";
     protected override void OnPreOpen()
     {
         scroller.OnRefreshCell += OnRefreshCell;
-        guid = BattleSettlementManager.Instance.notifyGuid;
-        jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid);
+        jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName);
         if (jsonData == null)
         {
             DelayCloseWindow().Forget();
@@ -98,7 +97,7 @@
     protected override void OnPreClose()
     {
         scroller.OnRefreshCell -= OnRefreshCell;
-        BattleSettlementManager.Instance.WinShowOver(guid);
+        BattleSettlementManager.Instance.WinShowOver(battleName);
     }
     // B4 20 鍥炲悎鍒舵垬鏂楃姸鎬� #tagMCTurnFightState  閫氱敤鐨勭粨绠楃姸鎬� State 4-缁撶畻濂栧姳
     // Msg 涓澶栦俊鎭�
diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 39b6c02..699bbee 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -602,4 +602,20 @@
         }
         return "";
     }
+
+    // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅�,濡傛灉娌℃湁鍒欒繑鍥瀗ull
+    public BattleField GetActiveBattleFieldByName(string battleName)
+    {
+        foreach (var kvp in battleFields)
+        {
+            BattleField battleField = kvp.Value;
+            if (battleField == null)
+                continue;
+
+            var name = battleField.ToString();
+            if (name == battleName)
+                return battleField;
+        }
+        return null;
+    }
 }
\ No newline at end of file
diff --git a/Main/System/Settlement/BattleFailWin.cs b/Main/System/Settlement/BattleFailWin.cs
index 3b7cad3..4671a92 100644
--- a/Main/System/Settlement/BattleFailWin.cs
+++ b/Main/System/Settlement/BattleFailWin.cs
@@ -11,9 +11,7 @@
 
     [SerializeField] Button tipEquipBtn;
     [SerializeField] Button tipHeroPosBtn;
-
-    string guid;
-
+    string battleName = "ArenaBattleField";
     protected override void InitComponent()
     {
         tipEquipBtn.AddListener(() =>
@@ -30,13 +28,12 @@
 
     protected override void OnPreOpen()
     {
-        guid = BattleSettlementManager.Instance.notifyGuid;
     }
 
 
     protected override void OnPreClose()
     {
-        BattleSettlementManager.Instance.WinShowOver(guid);
+        BattleSettlementManager.Instance.WinShowOver(battleName);
     }
 
 }
\ No newline at end of file
diff --git a/Main/System/Settlement/BattleSettlementManager.cs b/Main/System/Settlement/BattleSettlementManager.cs
index ff81d76..0e2f583 100644
--- a/Main/System/Settlement/BattleSettlementManager.cs
+++ b/Main/System/Settlement/BattleSettlementManager.cs
@@ -1,13 +1,15 @@
 锘�
 
 using System.Collections.Generic;
+using System.Linq;
 using LitJson;
 
 public partial class BattleSettlementManager : GameSystemManager<BattleSettlementManager>
 {
-    //缁撶畻鍚庨渶娓呴櫎
+    //缁撶畻鍚庨渶娓呴櫎 <battleName,JsonData>
     Dictionary<string, JsonData> battleSettlementDic = new Dictionary<string, JsonData>();
-    public string notifyGuid = string.Empty;
+
+    // public string notifyGuid = string.Empty;
 
     public override void Init()
     {
@@ -23,31 +25,32 @@
     }
 
 
-
     public void OnBeforePlayerDataInitialize()
     {
         battleSettlementDic.Clear();
     }
 
-
-    //"Msg":{"itemInfo":[{"ItemID":5,"Count":2},{"ItemID":3,"Count":40}],"winFaction":1,"statInfo":{"1":{"1":{"1":{"NPCID":0,"DefHurt":727,"CureHP":0,"AtkHurt":1891,"ObjID":1,"HeroID":530004},"3":{"NPCID":0,"DefHurt":483,"CureHP":1511,"AtkHurt":782,"ObjID":6,"HeroID":520001},"2":{"NPCID":0,"DefHurt":953,"CureHP":0,"AtkHurt":1712,"ObjID":5,"HeroID":510003}}},"2":{"1":{"1":{"NPCID":10101091,"DefHurt":638,"CureHP":0,"AtkHurt":140,"ObjID":2,"HeroID":610001},"3":{"NPCID":10101092,"DefHurt":625,"CureHP":0,"AtkHurt":126,"ObjID":3,"HeroID":610001},"5":{"NPCID":10101093,"DefHurt":3122,"CureHP":0,"AtkHurt":1897,"ObjID":4,"HeroID":510003}}}}}
-    public void OnSettlement(string _guid, JsonData _data)
+    public void AddPop(string battleName, int result)
     {
-        if (string.Empty == _guid)
-            return;
-
-        battleSettlementDic[_guid] = _data;
-        notifyGuid = _guid;
-        if (_data.ContainsKey("winFaction"))
+        bool isWin = result == 1;
+        switch (battleName)
         {
-            var result = (int)_data["winFaction"];
+            case "ArenaBattleField":
+                PopupWindowsProcessor.Instance.Add(isWin ? "ArenaBattleVictoryWin" : "ArenaBattleFailWin", false);
+                break;
+            default:
+                PopupWindowsProcessor.Instance.Add(isWin ? "BattleVictoryWin" : "BattleFailWin", false);
+                break;
+        }
+    }
 
-            var battle = BattleManager.Instance.GetBattleField(_guid);
-            if (battle == null)
-                return;
-            if (battle is ArenaBattleField)
-            {
-                if (result == 1)
+    public void ShowResultWin(string battleName, int result)
+    {
+        bool isWin = result == 1;
+        switch (battleName)
+        {
+            case "ArenaBattleField":
+                if (isWin)
                 {
                     UIManager.Instance.OpenWindow<ArenaBattleVictoryWin>();
                 }
@@ -55,10 +58,9 @@
                 {
                     UIManager.Instance.OpenWindow<ArenaBattleFailWin>();
                 }
-            }
-            else
-            {
-                if (result == 1)
+                break;
+            default:
+                if (isWin)
                 {
                     UIManager.Instance.OpenWindow<BattleVictoryWin>();
                 }
@@ -66,25 +68,55 @@
                 {
                     UIManager.Instance.OpenWindow<BattleFailWin>();
                 }
-            }
+                break;
         }
     }
 
-    public void WinShowOver(string _guid)
+    //"Msg":{"itemInfo":[{"ItemID":5,"Count":2},{"ItemID":3,"Count":40}],"winFaction":1,"statInfo":{"1":{"1":{"1":{"NPCID":0,"DefHurt":727,"CureHP":0,"AtkHurt":1891,"ObjID":1,"HeroID":530004},"3":{"NPCID":0,"DefHurt":483,"CureHP":1511,"AtkHurt":782,"ObjID":6,"HeroID":520001},"2":{"NPCID":0,"DefHurt":953,"CureHP":0,"AtkHurt":1712,"ObjID":5,"HeroID":510003}}},"2":{"1":{"1":{"NPCID":10101091,"DefHurt":638,"CureHP":0,"AtkHurt":140,"ObjID":2,"HeroID":610001},"3":{"NPCID":10101092,"DefHurt":625,"CureHP":0,"AtkHurt":126,"ObjID":3,"HeroID":610001},"5":{"NPCID":10101093,"DefHurt":3122,"CureHP":0,"AtkHurt":1897,"ObjID":4,"HeroID":510003}}}}}
+    public void OnSettlement(string _guid, JsonData _data)
     {
-        battleSettlementDic.Remove(_guid);
+        if (string.Empty == _guid)
+            return;
         var battle = BattleManager.Instance.GetBattleField(_guid);
+        if (battle == null)
+            return;
+        var battleName = battle.ToString();
+        battleSettlementDic[battleName] = _data;
+
+        string activeBattleName = BattleManager.Instance.GetActiveBattleName();
+
+        if (_data.ContainsKey("winFaction"))
+        {
+            var result = (int)_data["winFaction"];
+            if (battleName == activeBattleName)
+            {
+                //鑷繁鍦烘櫙缁撶畻
+                ShowResultWin(battleName, result);
+            }
+            else
+            {
+                AddPop(battleName, result);
+            }
+
+        }
+    }
+
+    public void WinShowOver(string battleName)
+    {
+        battleSettlementDic.Remove(battleName);
+
+        var battle = BattleManager.Instance.GetActiveBattleFieldByName(battleName);
         if (battle != null)
             battle.WhaleFall();
     }
 
-    public JsonData GetBattleSettlement(string _guid)
+    public JsonData GetBattleSettlement(string battleName)
     {
-        if (!battleSettlementDic.ContainsKey(_guid))
+        if (!battleSettlementDic.ContainsKey(battleName))
         {
             return null;
         }
-        return battleSettlementDic[_guid];
+        return battleSettlementDic[battleName];
     }
 }
 
diff --git a/Main/System/Settlement/BattleVictoryWin.cs b/Main/System/Settlement/BattleVictoryWin.cs
index 80dce9b..9cf7e25 100644
--- a/Main/System/Settlement/BattleVictoryWin.cs
+++ b/Main/System/Settlement/BattleVictoryWin.cs
@@ -75,10 +75,9 @@
 
     [SerializeField] ScrollerController scroller;
 
-    string guid;
+    string battleName = "StoryBossBattleField";
     protected override void OnPreOpen()
     {
-        guid = BattleSettlementManager.Instance.notifyGuid;
         scroller.OnRefreshCell += OnRefreshCell;
         CreateScroller();
     }
@@ -87,13 +86,13 @@
     protected override void OnPreClose()
     {
         scroller.OnRefreshCell -= OnRefreshCell;
-        BattleSettlementManager.Instance.WinShowOver(guid);
+        BattleSettlementManager.Instance.WinShowOver(battleName);
     }
 
     List<Item> showItems = new List<Item>();
     void CreateScroller()
     {
-        var jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid);
+        var jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName);
         if (jsonData == null)
         {
             DelayCloseWindow().Forget();

--
Gitblit v1.8.0