| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | |
| | | [SerializeField] Image fightHeroImg; //战斗显示英雄 |
| | | [SerializeField] ScaleTween fightHeroScale; //战斗显示英雄缩放 |
| | | [SerializeField] UIEffectPlayer fightEffect; |
| | | [SerializeField] UIEffectPlayer openCloseAnim; |
| | | [SerializeField] FillTween cdTween; |
| | | int index = 0; |
| | | |
| | | |
| | | 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() |
| | |
| | | UpdateCurrency(); |
| | | UpdatePlayerInfo(); |
| | | RefreshFightBtn(); |
| | | DisplayTopBar(index); |
| | | } |
| | | |
| | | 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(); |
| | | |
| | | // 刷新UI |
| | |
| | | { |
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; |
| | | AutoFightModel.Instance.OnFightEvent -= OnSkillCast; |
| | | ChallengeTabWin.OnCloseChallengeTabWin -= OnCloseChallengeTabWin; |
| | | BattleManager.Instance.onBattleFieldCreate -= OnBattleFieldCreate; |
| | | BattleManager.Instance.onBattleFieldDestroy -= OnBattleFieldDestroy; |
| | | base.OnPreClose(); |
| | | } |
| | | |
| | | private void OnBattleFieldCreate(string guid, BattleField battleField) |
| | | { |
| | | Refresh(); |
| | | } |
| | | |
| | | private void OnBattleFieldDestroy(string guid, BattleField battleField) |
| | | { |
| | | Refresh(); |
| | | } |
| | | |
| | | private void OnCloseChallengeTabWin() |
| | | { |
| | | tabButtons[3].state = TitleBtnState.Normal; |
| | | tabButtons[3].UpdateButtonState(); |
| | | } |
| | | |
| | | //外部调用点击功能 |
| | | public void ClickFunc(int functionOrder) |
| | | { |
| | | tabButtons[functionOrder].onClick.Invoke(); |
| | | } |
| | | |
| | | //恢复功能按钮状态 |
| | | public void RestoreFuncBtn() |
| | | { |
| | | tabButtons[functionOrder].SelectBtn(); |
| | | } |
| | | |
| | | public void DisplayTopBar(int index) |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | protected override void SelectBottomTab(int index) |
| | | { |
| | | bool isOtherBattleInProgress = BattleManager.Instance.IsOtherBattleInProgress(); |
| | | if (isOtherBattleInProgress) |
| | | { |
| | | // 如果正在非主线战斗中,没满足解锁条件则不允许切换 |
| | | } |
| | | DisplayTopBar(index); |
| | | |
| | | if (index == 3) |
| | | { |
| | | //挑战特殊显示逻辑 |
| | | UIManager.Instance.OpenWindow<ChallengeTabWin>(); |
| | | return; |
| | | } |
| | | |
| | | topBar.SetActive(index == 0 || index == 2); |
| | | |
| | | |
| | | // 如果点击当前已选中的标签,不做处理 |
| | | if (functionOrder == index && currentSubUI != null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | ClickAnimation(index); |
| | | // 更新当前选中的标签索引 |
| | | functionOrder = index; |
| | | |
| | |
| | | |
| | | // 根据选中的标签打开对应的界面 |
| | | OpenSubUIByTabIndex(); |
| | | |
| | | TabChangeEvent?.Invoke(); |
| | | } |
| | | |
| | | //战斗按钮动画 |
| | | 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> |
| | |
| | | /// </summary> |
| | | protected override void OnTabButtonClicked(int index) |
| | | { |
| | | this.index = index; |
| | | |
| | | |
| | | if (index == 0) |
| | | { |
| | | if (currentSubUI != null && currentSubUI.name == "HomeWin") |
| | |
| | | //手动自动一起处理 |
| | | AutoFightModel.Instance.StartFight(); |
| | | } |
| | | } |
| | | else if (index == 4 && !PlayerDatas.Instance.fairyData.HasFairy) |
| | | { |
| | | //未加入公会不切换标签,打开申请界面 |
| | | UIManager.Instance.OpenWindow<GuildJoinWin>(); |
| | | return; |
| | | } |
| | | SelectBottomTab(index); |
| | | } |
| | |
| | | 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: |
| | |
| | | { |
| | | //主城界面 |
| | | fightOtherWinBG.SetActive(false); |
| | | fightOtherWinWarnImg.SetActive(false); |
| | | fightBG.SetActive(true); |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | void RefreshFightIng(bool isfighting = false) |
| | | { |
| | | if (isfighting) |