0312 整理战场和主界面的关系;增加获取当前激活的战场接口GetActiveBattleName
6个文件已修改
3个文件已删除
163 ■■■■ 已修改文件
Main/System/Battle/BattleConst.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleField/BattleRootNode.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleManager.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleWin.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/ChallengeTab/ChallengeTabWin.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/MainWin.cs 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Place.meta 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Place/PlaceWin.cs 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Place/PlaceWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
Main/System/Battle/BattleField/BattleRootNode.cs
@@ -56,6 +56,7 @@
        if (imgBackground != null)
        {
            imgBackground.texture = texture;
            imgBackground.raycastTarget = false;
            // imgBackground.SetNativeSize();
        }
    }
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;
    }
    // 获取当前正在显示的战斗场景名称,如果没有则返回空字符串
    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 "";
    }
}
Main/System/Battle/BattleWin.cs
@@ -6,6 +6,7 @@
{
    // 组件引用
    public Transform mountPoint;
    [SerializeField] Button fightBtn;
    private BattleRootNode battleRootNode = null;
@@ -22,6 +23,11 @@
        // 初始化组件引用 绑定按钮等UI组件事件
        btnStop.AddListener(PauseGame);
        fightBtn.AddListener(()=>
        {
            UIManager.Instance.GetUI<MainWin>()?.ClickFunc(0);
        });
    }
    private void PauseGame()
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()
    {
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();
        // 如果正在非主线战斗中,没满足解锁条件则不允许切换
@@ -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);
    }
Main/System/Place.meta
File was deleted
Main/System/Place/PlaceWin.cs
File was deleted
Main/System/Place/PlaceWin.cs.meta
File was deleted