|  |  |  | 
|---|
|  |  |  | [SerializeField] UIEffectPlayer fightEffect; | 
|---|
|  |  |  | [SerializeField] UIEffectPlayer openCloseAnim; | 
|---|
|  |  |  | [SerializeField] FillTween cdTween; | 
|---|
|  |  |  | [SerializeField] Text hammerText; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool isFirstOpen = true; //首次打开 | 
|---|
|  |  |  | public Text hammerText; | 
|---|
|  |  |  | bool isFirstOpen = true; //首次打开 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static event Action TabChangeEvent; | 
|---|
|  |  |  | protected override void InitComponent() | 
|---|
|  |  |  | 
|---|
|  |  |  | avatarCell.button.AddListener(() => { }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override void Refresh() | 
|---|
|  |  |  | void Display() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | Refresh(); | 
|---|
|  |  |  | Display(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void OnPreClose() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 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() | 
|---|
|  |  |  | void DisplayTopBar() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | topBar.SetActive(functionOrder == 0 || functionOrder == 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void SelectBottomTab(int index) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (index == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //挑战特殊显示逻辑 | 
|---|
|  |  |  | UIManager.Instance.OpenWindow<ChallengeTabWin>(); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TabChangeEvent?.Invoke(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果点击当前已选中的标签,不做处理 | 
|---|
|  |  |  | if (functionOrder == index && currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ClickAnimation(index); | 
|---|
|  |  |  | // 更新当前选中的标签索引 | 
|---|
|  |  |  | functionOrder = index; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DisplayTopBar(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 关闭当前打开的子界面 | 
|---|
|  |  |  | CloseCurrentSubUI(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 根据选中的标签打开对应的界面 | 
|---|
|  |  |  | OpenSubUIByTabIndex(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //战斗按钮动画 | 
|---|
|  |  |  | void ClickAnimation(int index) | 
|---|
|  |  |  | 
|---|
|  |  |  | hammerText.text = UIHelper.GetMoneyCnt(41).ToString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 底部标签按钮点击 | 
|---|
|  |  |  | /// </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") | 
|---|
|  |  |  | 
|---|
|  |  |  | SelectBottomTab(index); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void SelectBottomTab(int index) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (index == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //挑战特殊显示逻辑 | 
|---|
|  |  |  | UIManager.Instance.OpenWindow<ChallengeTabWin>(); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果点击当前已选中的标签,不做处理 | 
|---|
|  |  |  | if (functionOrder == index && currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TabChangeEvent?.Invoke(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ClickAnimation(index); | 
|---|
|  |  |  | // 更新当前选中的标签索引 | 
|---|
|  |  |  | functionOrder = index; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DisplayTopBar(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 关闭当前打开的子界面 | 
|---|
|  |  |  | CloseCurrentSubUI(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 根据选中的标签打开对应的界面 | 
|---|
|  |  |  | OpenSubUIByTabIndex(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 根据标签索引打开对应的子界面 | 
|---|
|  |  |  | 
|---|
|  |  |  | RefreshFightBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 外部调用 | 
|---|
|  |  |  | //外部调用点击功能 | 
|---|
|  |  |  | public void ClickFunc(int functionOrder) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | tabButtons[functionOrder].onClick.Invoke(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //恢复功能按钮状态 | 
|---|
|  |  |  | public void RestoreFuncBtn() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | tabButtons[functionOrder].SelectBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 外部关闭子界面 | 
|---|
|  |  |  | int lastWinOrder = -1; | 
|---|
|  |  |  | public void CloseSubUI() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lastWinOrder = functionOrder; | 
|---|
|  |  |  | currentSubUI.CloseWindow(); | 
|---|
|  |  |  | currentSubUI = null; | 
|---|
|  |  |  | functionOrder = -1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 外部恢复子界面 | 
|---|
|  |  |  | public void RestoreSubUI() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (lastWinOrder == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lastWinOrder = 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OnTabButtonClicked(lastWinOrder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | } | 
|---|