From 4dc1c86671e53f830f2ef9996d9dba0ada58099e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 21 十月 2025 23:55:13 +0800
Subject: [PATCH] 0312 整理战场和主界面的关系;增加获取当前激活的战场接口GetActiveBattleName
---
 /dev/null                                        |   11 -----
 Main/System/Battle/BattleConst.cs                |    9 ++++
 Main/System/Battle/BattleField/BattleRootNode.cs |    1 
 Main/System/Battle/BattleManager.cs              |   21 +++++++++-
 Main/System/Battle/BattleWin.cs                  |    6 +++
 Main/System/Main/MainWin.cs                      |   41 ++++----------------
 Main/System/ChallengeTab/ChallengeTabWin.cs      |    4 +-
 7 files changed, 45 insertions(+), 48 deletions(-)
diff --git a/Main/System/Battle/BattleConst.cs b/Main/System/Battle/BattleConst.cs
index 397a394..78a5d56 100644
--- a/Main/System/Battle/BattleConst.cs
+++ b/Main/System/Battle/BattleConst.cs
@@ -9,6 +9,15 @@
         typeof(BattleWin),
         typeof(StoryBossBattleWin),
         typeof(ArenaBattleWin),
+        typeof(BoneFieldBattleWin),
+    };
+
+    public static Dictionary<string, string> battleNameToWinName = new Dictionary<string, string>()
+    {
+        { "StoryBattleField", "BattleWin" },
+        { "StoryBossBattleField", "StoryBossBattleWin" },
+        { "ArenaBattleField", "ArenaBattleWin" },
+        { "BoneBattleField", "BoneFieldBattleWin" },
     };
 
     public const int BattleStartEffectID = 1001; // Example effect ID for battle start
diff --git a/Main/System/Battle/BattleField/BattleRootNode.cs b/Main/System/Battle/BattleField/BattleRootNode.cs
index 14d2f00..198a2da 100644
--- a/Main/System/Battle/BattleField/BattleRootNode.cs
+++ b/Main/System/Battle/BattleField/BattleRootNode.cs
@@ -56,6 +56,7 @@
 		if (imgBackground != null)
 		{
 			imgBackground.texture = texture;
+			imgBackground.raycastTarget = false;
 			// imgBackground.SetNativeSize();
 		}
 	}
diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 732c309..906f27b 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -30,7 +30,7 @@
 
     public Action<string, BattleField> onBattleFieldCreate;
 
-    public Action<string, BattleField> onBattleFieldDestroy;
+    public Action onBattleFieldDestroy;
 
     public bool isWaitServerStory = false;  //涓荤嚎绛夋湇鍔$鍥炴姤 0425
 
@@ -532,7 +532,7 @@
 
         GameObject.DestroyImmediate(battleField.battleRootNode.gameObject);
 
-        onBattleFieldDestroy?.Invoke(battleField.guid, battleField);
+        onBattleFieldDestroy?.Invoke();
 
     }
 
@@ -605,4 +605,21 @@
         }
         return false;
     }
+
+    // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅悕绉帮紝濡傛灉娌℃湁鍒欒繑鍥炵┖瀛楃涓�
+    public string GetActiveBattleName()
+    {
+        foreach (var kvp in battleFields)
+        {
+            BattleField battleField = kvp.Value;
+            if (battleField == null)
+                continue;
+
+            var battleName = battleField.ToString();
+            if (BattleConst.battleNameToWinName.ContainsKey(battleName)
+            && UIManager.Instance.IsOpened(BattleConst.battleNameToWinName[battleName]))
+                return battleName;
+        }
+        return "";
+    }
 }
\ No newline at end of file
diff --git a/Main/System/Battle/BattleWin.cs b/Main/System/Battle/BattleWin.cs
index 2fda744..317c3d3 100644
--- a/Main/System/Battle/BattleWin.cs
+++ b/Main/System/Battle/BattleWin.cs
@@ -6,6 +6,7 @@
 {
     // 缁勪欢寮曠敤
     public Transform mountPoint;
+    [SerializeField] Button fightBtn;
 
     private BattleRootNode battleRootNode = null;
 
@@ -22,6 +23,11 @@
         // 鍒濆鍖栫粍浠跺紩鐢� 缁戝畾鎸夐挳绛塙I缁勪欢浜嬩欢
 
         btnStop.AddListener(PauseGame);
+
+        fightBtn.AddListener(()=>
+        {
+            UIManager.Instance.GetUI<MainWin>()?.ClickFunc(0);
+        });
     }
 
     private void PauseGame()
diff --git a/Main/System/ChallengeTab/ChallengeTabWin.cs b/Main/System/ChallengeTab/ChallengeTabWin.cs
index 6a302fb..bc04981 100644
--- a/Main/System/ChallengeTab/ChallengeTabWin.cs
+++ b/Main/System/ChallengeTab/ChallengeTabWin.cs
@@ -5,7 +5,7 @@
 {
     [SerializeField] ChallengeTabButton btnBoneField;
     [SerializeField] ChallengeTabButton btnArena;
-    public static Action OnCloseChallengeTabWin;
+    
     protected override void InitComponent()
     {
         base.InitComponent();
@@ -28,7 +28,7 @@
         TimeMgr.Instance.OnDayEvent -= OnDayEvent;
         FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
         PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
-        OnCloseChallengeTabWin?.Invoke();
+        UIManager.Instance.GetUI<MainWin>()?.RestoreFuncBtn();
     }
     private void OnDayEvent()
     {
diff --git a/Main/System/Main/MainWin.cs b/Main/System/Main/MainWin.cs
index 1ceda2d..76d15e1 100644
--- a/Main/System/Main/MainWin.cs
+++ b/Main/System/Main/MainWin.cs
@@ -27,7 +27,6 @@
     [SerializeField] UIEffectPlayer fightEffect;
     [SerializeField] UIEffectPlayer openCloseAnim;
     [SerializeField] FillTween cdTween;
-    int index = 0;
 
     public bool isFirstOpen = true; //棣栨鎵撳紑
     public Text hammerText;
@@ -45,14 +44,13 @@
         UpdateCurrency();
         UpdatePlayerInfo();
         RefreshFightBtn();
-        DisplayTopBar(index);
+        DisplayTopBar();
     }
 
     protected override void OnPreOpen()
     {
         PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
         AutoFightModel.Instance.OnFightEvent += OnSkillCast;
-        ChallengeTabWin.OnCloseChallengeTabWin += OnCloseChallengeTabWin;
         BattleManager.Instance.onBattleFieldCreate += OnBattleFieldCreate;
         BattleManager.Instance.onBattleFieldDestroy += OnBattleFieldDestroy;
         base.OnPreOpen();
@@ -65,7 +63,6 @@
     {
         PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh;
         AutoFightModel.Instance.OnFightEvent -= OnSkillCast;
-        ChallengeTabWin.OnCloseChallengeTabWin -= OnCloseChallengeTabWin;
         BattleManager.Instance.onBattleFieldCreate -= OnBattleFieldCreate;
         BattleManager.Instance.onBattleFieldDestroy -= OnBattleFieldDestroy;
         base.OnPreClose();
@@ -76,16 +73,11 @@
         Refresh();
     }
 
-    private void OnBattleFieldDestroy(string guid, BattleField battleField)
+    private void OnBattleFieldDestroy()
     {
         Refresh();
     }
 
-    private void OnCloseChallengeTabWin()
-    {
-        tabButtons[3].state = TitleBtnState.Normal;
-        tabButtons[3].UpdateButtonState();
-    }
 
     //澶栭儴璋冪敤鐐瑰嚮鍔熻兘
     public void ClickFunc(int functionOrder)
@@ -99,26 +91,9 @@
         tabButtons[functionOrder].SelectBtn();
     }
 
-    public void DisplayTopBar(int index)
+    public void DisplayTopBar()
     {
-        bool isOtherBattleInProgress = BattleManager.Instance.IsOtherBattleInProgress();
-        switch (index)
-        {
-            case 0:
-            case 2:
-                topBar.SetActive(true);
-                break;
-            case 1:
-            case 4:
-                topBar.SetActive(false);
-                break;
-            case 3:
-                topBar.SetActive(!isOtherBattleInProgress);
-                break;
-            default:
-                topBar.SetActive(true);
-                break;
-        }
+        topBar.SetActive(functionOrder == 0 || functionOrder == 2);
     }
 
     protected override void SelectBottomTab(int index)
@@ -131,7 +106,7 @@
         }
 
         TabChangeEvent?.Invoke();
-
+        
         // 濡傛灉鐐瑰嚮褰撳墠宸查�変腑鐨勬爣绛撅紝涓嶅仛澶勭悊
         if (functionOrder == index && currentSubUI != null)
         {
@@ -141,6 +116,8 @@
         ClickAnimation(index);
         // 鏇存柊褰撳墠閫変腑鐨勬爣绛剧储寮�
         functionOrder = index;
+
+        DisplayTopBar();
 
         // 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
         CloseCurrentSubUI();
@@ -228,7 +205,6 @@
     /// </summary>
     protected override void OnTabButtonClicked(int index)
     {
-        this.index = index;
         int funcId = 32;
         bool isOtherBattleInProgress = BattleManager.Instance.IsOtherBattleInProgress();
         // 濡傛灉姝e湪闈炰富绾挎垬鏂椾腑锛屾病婊¤冻瑙i攣鏉′欢鍒欎笉鍏佽鍒囨崲
@@ -236,7 +212,6 @@
         {
             string tip = FuncOpen.Instance.GetErrorTip(funcId);
             SysNotifyMgr.Instance.ShowTip("SwitchOutOfBattle", tip);
-            tabButtons[functionOrder].SelectBtn();
             return;
         }
 
@@ -256,7 +231,7 @@
             return;
         }
 
-        DisplayTopBar(index);
+        
         SelectBottomTab(index);
     }
 
diff --git a/Main/System/Place.meta b/Main/System/Place.meta
deleted file mode 100644
index 29907a9..0000000
--- a/Main/System/Place.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 2a75dbf92ff839445b4bf6be823add40
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 
diff --git a/Main/System/Place/PlaceWin.cs b/Main/System/Place/PlaceWin.cs
deleted file mode 100644
index 9e0caff..0000000
--- a/Main/System/Place/PlaceWin.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-/// <summary>
-/// 鍦烘櫙鐣岄潰
-/// </summary>
-public class PlaceWin : UIBase
-{
-    protected Button btnExplore;
-
-    // protected 
-
-    /// <summary>
-    /// 鍒濆鍖栫粍浠�
-    /// </summary>
-    protected override void InitComponent()
-    {
-        base.InitComponent();
-        
-        // 鍦ㄨ繖閲屽垵濮嬪寲缁勪欢
-        btnExplore = transform.Find("BtnExplore").GetComponent<Button>();
-        btnExplore.onClick.AddListener(OnExploreClick);
-    }
-    
-    
-    /// <summary>
-    /// 绐楀彛鎵撳紑鏃惰皟鐢�
-    /// </summary>
-    protected override void OnOpen()
-    {
-        base.OnOpen();
-        
-        // 绐楀彛鎵撳紑鏃剁殑閫昏緫
-        
-    }
-    
-    /// <summary>
-    /// 绐楀彛鍏抽棴鏃惰皟鐢�
-    /// </summary>
-    protected override void OnClose()
-    {
-        base.OnClose();
-        
-        // 绐楀彛鍏抽棴鏃剁殑閫昏緫
-        
-    }
-    
-    /// <summary>
-    /// 鍒锋柊鐣岄潰
-    /// </summary>
-    public override void Refresh()
-    {
-        // 鍒锋柊鐣岄潰鐨勯�昏緫
-    }
-
-    private void OnExploreClick()
-    {
-        // UIManager.Instance.OpenUI<ExploreWin>();
-    }
-}
diff --git a/Main/System/Place/PlaceWin.cs.meta b/Main/System/Place/PlaceWin.cs.meta
deleted file mode 100644
index ad66f43..0000000
--- a/Main/System/Place/PlaceWin.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 846b941e24d55594fac435ba7031cfa9
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 
--
Gitblit v1.8.0