yyl
9 天以前 b1f98c42a6b859b35c26e0722efb38a6e9c215be
Main/System/Main/MainWin.cs
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -24,17 +25,18 @@
    [SerializeField] Image fightHeroImg; //战斗显示英雄
    [SerializeField] ScaleTween fightHeroScale; //战斗显示英雄缩放
    [SerializeField] UIEffectPlayer fightEffect;
    [SerializeField] UIEffectPlayer openCloseAnim;
    [SerializeField] FillTween cdTween;
    public bool isFirstOpen = true; //首次打开
    public Text hammerText;
    public static event Action TabChangeEvent;
    protected override void InitComponent()
    {
        base.InitComponent();
        avatarCell.button.AddListener(() => { });
    }
    public override void Refresh()
@@ -42,12 +44,15 @@
        UpdateCurrency();
        UpdatePlayerInfo();
        RefreshFightBtn();
        DisplayTopBar();
    }
    protected override void OnPreOpen()
    {
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
        AutoFightModel.Instance.OnFightEvent += OnSkillCast;
        BattleManager.Instance.onBattleFieldCreate += OnBattleFieldCreate;
        BattleManager.Instance.onBattleFieldDestroy += OnBattleFieldDestroy;
        base.OnPreOpen();
        // 刷新UI
@@ -58,35 +63,92 @@
    {
        PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh;
        AutoFightModel.Instance.OnFightEvent -= OnSkillCast;
        BattleManager.Instance.onBattleFieldCreate -= OnBattleFieldCreate;
        BattleManager.Instance.onBattleFieldDestroy -= OnBattleFieldDestroy;
        base.OnPreClose();
    }
    private void OnBattleFieldCreate(string guid, BattleField battleField)
    {
        Refresh();
    }
    private void OnBattleFieldDestroy()
    {
        Refresh();
    }
    //外部调用点击功能
    public void ClickFunc(int functionOrder)
    {
        tabButtons[functionOrder].onClick.Invoke();
    }
    //恢复功能按钮状态
    public void RestoreFuncBtn()
    {
        tabButtons[functionOrder].SelectBtn();
    }
    public void DisplayTopBar()
    {
        topBar.SetActive(functionOrder == 0 || functionOrder == 2);
    }
    protected override void SelectBottomTab(int index)
    {
        if (index == 3)
        {
            //挑战特殊显示逻辑
            UIManager.Instance.OpenWindow<ChallengeTabWin>();
            return;
        }
        topBar.SetActive(index == 0 || index == 2);
        TabChangeEvent?.Invoke();
        // 如果点击当前已选中的标签,不做处理
        if (functionOrder == index && currentSubUI != null)
        {
            return;
        }
        ClickAnimation(index);
        // 更新当前选中的标签索引
        functionOrder = index;
        DisplayTopBar();
        // 关闭当前打开的子界面
        CloseCurrentSubUI();
        // 根据选中的标签打开对应的界面
        OpenSubUIByTabIndex();
    }
    //战斗按钮动画
    void ClickAnimation(int index)
    {
        if (isFirstOpen || (functionOrder != 0 && index == 0))
        {
            openCloseAnim.onComplete = () =>
            {
                openCloseAnim.SetEnabled(true);
            };
            openCloseAnim.PlayByArrIndex(1);
            isFirstOpen = false;
        }
        else if (functionOrder == 0 && index != 0)
        {
            openCloseAnim.onComplete = () =>
            {
                openCloseAnim.SetEnabled(true);
            };
            openCloseAnim.PlayByArrIndex(0);
        }
    }
    /// <summary>
@@ -143,6 +205,17 @@
    /// </summary>
    protected override void OnTabButtonClicked(int index)
    {
        int funcId = 32;
        bool isOtherBattleInProgress = BattleManager.Instance.IsOtherBattleInProgress();
        // 如果正在非主线战斗中,没满足解锁条件则不允许切换
        if (isOtherBattleInProgress && !FuncOpen.Instance.IsFuncOpen(funcId))
        {
            string tip = FuncOpen.Instance.GetErrorTip(funcId);
            SysNotifyMgr.Instance.ShowTip("SwitchOutOfBattle", tip);
            return;
        }
        if (index == 0)
        {
            if (currentSubUI != null && currentSubUI.name == "HomeWin")
@@ -151,6 +224,14 @@
                AutoFightModel.Instance.StartFight();
            }
        }
        else if (index == 4 && !PlayerDatas.Instance.fairyData.HasFairy)
        {
            //未加入公会不切换标签,打开申请界面
            UIManager.Instance.OpenWindow<GuildJoinWin>();
            return;
        }
        SelectBottomTab(index);
    }
@@ -179,18 +260,15 @@
                    battleWin.SetBattleField(BattleManager.Instance.storyBattleField);
                }
                currentSubUI = UIManager.Instance.OpenWindow<HomeWin>();
                Debug.Log("打开主城界面");
                break;
            case 1:
                currentSubUI = UIManager.Instance.OpenWindow<AffairBaseWin>();
                Debug.Log("打开内政界面");
                break;
            case 2:
                currentSubUI = UIManager.Instance.OpenWindow<HeroBaseWin>(0);
                Debug.Log("打开武将界面");
                break;
            // case 3:
            //     // currentSubUI = UIManager.Instance.OpenUI<QuestUI>();
            //     挑战界面不跳转
            //     Debug.Log("打开挑战界面");
            //     break;
            case 4:
@@ -224,6 +302,7 @@
        {
            //主城界面
            fightOtherWinBG.SetActive(false);
            fightOtherWinWarnImg.SetActive(false);
            fightBG.SetActive(true);
@@ -259,6 +338,7 @@
    }
    void RefreshFightIng(bool isfighting = false)
    {
        if (isfighting)