|  |  |  | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using UnityEngine; | 
|---|
|  |  |  | using UnityEngine.UI; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 游戏主界面 | 
|---|
|  |  |  | /// 游戏主界面底部功能按钮 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public class MainWin : UIBase | 
|---|
|  |  |  | public class MainWin : FunctionsBaseWin | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private GameObject windowBackground; | 
|---|
|  |  |  | //头像区 | 
|---|
|  |  |  | [SerializeField] GameObject topBar; | 
|---|
|  |  |  | [SerializeField] AvatarCell avatarCell; | 
|---|
|  |  |  | [SerializeField] Text playerNameText; | 
|---|
|  |  |  | [SerializeField] Text powerText; | 
|---|
|  |  |  | [SerializeField] OfficialTitleCell officialRankText; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 底部按钮组 | 
|---|
|  |  |  | private Button[] bottomTabButtons; | 
|---|
|  |  |  | //战斗按钮 | 
|---|
|  |  |  | [SerializeField] Image fightOtherWinBG; //切换其他界面的显示 | 
|---|
|  |  |  | [SerializeField] Image fightOtherWinWarnImg; //切换其他界面 如果是战斗中泛红提示 | 
|---|
|  |  |  | [SerializeField] GameObject fightBG; //战斗界面显示 | 
|---|
|  |  |  | [SerializeField] Image restImg; //休息状态 | 
|---|
|  |  |  | [SerializeField] GameObject fightGo; //战斗状态 | 
|---|
|  |  |  | [SerializeField] Image fightHeroImg; //战斗显示英雄 | 
|---|
|  |  |  | [SerializeField] ScaleTween fightHeroScale; //战斗显示英雄缩放 | 
|---|
|  |  |  | [SerializeField] UIEffectPlayer fightEffect; | 
|---|
|  |  |  | [SerializeField] UIEffectPlayer openCloseAnim; | 
|---|
|  |  |  | [SerializeField] FillTween cdTween; | 
|---|
|  |  |  | [SerializeField] Text hammerText; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bool isFirstOpen = true; //首次打开 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private GameObject[] bottomTabEffects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 当前选中的底部标签索引 | 
|---|
|  |  |  | private int currentTabIndex = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 当前打开的子界面 | 
|---|
|  |  |  | private UIBase currentSubUI; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 初始化组件 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public static event Action TabChangeEvent; | 
|---|
|  |  |  | protected override void InitComponent() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | base.InitComponent(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | windowBackground = _rectTransform.Find("RawImgBackground").gameObject; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bottomTabButtons = new Button[5]; | 
|---|
|  |  |  | for (int i = 1; i <= 5; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string buttonName = "Buttons/Button" + i; | 
|---|
|  |  |  | bottomTabButtons[i-1] = _rectTransform.Find(buttonName).GetComponent<Button>(); | 
|---|
|  |  |  | #if UNITY_EDITOR | 
|---|
|  |  |  | //测试代码 | 
|---|
|  |  |  | #endif | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 初始化UI组件事件 | 
|---|
|  |  |  | InitButtonEvents(); | 
|---|
|  |  |  | avatarCell.button.AddListener(() => { }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 初始化UI组件事件 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void InitButtonEvents() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 初始化底部按钮 | 
|---|
|  |  |  | for (int i = 0; i < bottomTabButtons.Length; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | int index = i; // 捕获索引 | 
|---|
|  |  |  | bottomTabButtons[i].onClick.AddListener(() => { | 
|---|
|  |  |  | OnBottomTabButtonClicked(index); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void OnOpen() | 
|---|
|  |  |  | void Display() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | base.OnOpen(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 默认选中第一个标签 | 
|---|
|  |  |  | SelectBottomTab(0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 刷新UI | 
|---|
|  |  |  | Refresh(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override void Refresh() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | UpdatePlayerInfo(); | 
|---|
|  |  |  | UpdateCurrency(); | 
|---|
|  |  |  | UpdatePlayerInfo(); | 
|---|
|  |  |  | RefreshFightBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void OnPreOpen() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh; | 
|---|
|  |  |  | AutoFightModel.Instance.OnFightEvent += OnSkillCast; | 
|---|
|  |  |  | base.OnPreOpen(); | 
|---|
|  |  |  | bottomTabEffects = new GameObject[bottomTabButtons.Length]; | 
|---|
|  |  |  | for (int i = 0; i < bottomTabButtons.Length; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bottomTabEffects[i] = PlayUIEffect(1004, bottomTabButtons[i].transform, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 刷新UI | 
|---|
|  |  |  | Display(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void OnPreClose() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; | 
|---|
|  |  |  | AutoFightModel.Instance.OnFightEvent -= OnSkillCast; | 
|---|
|  |  |  | base.OnPreClose(); | 
|---|
|  |  |  | foreach (var effectGO in bottomTabEffects) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DestroyImmediate(effectGO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bottomTabEffects = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void DisplayTopBar() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | topBar.SetActive(functionOrder == 0 || functionOrder == 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //战斗按钮动画 | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | private void UpdatePlayerInfo() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 从玩家数据中获取信息并更新UI | 
|---|
|  |  |  | // 例如: | 
|---|
|  |  |  | // playerNameText.text = PlayerData.Instance.Name; | 
|---|
|  |  |  | // playerLevelText.text = "Lv." + PlayerData.Instance.Level; | 
|---|
|  |  |  | // powerText.text = PlayerData.Instance.Power.ToString(); | 
|---|
|  |  |  | // expSlider.value = PlayerData.Instance.ExpRatio; | 
|---|
|  |  |  | avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)PlayerDatas.Instance.baseData.PlayerID, | 
|---|
|  |  |  | PlayerDatas.Instance.baseData.face, | 
|---|
|  |  |  | PlayerDatas.Instance.baseData.facePic)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | playerNameText.text = PlayerDatas.Instance.baseData.PlayerName; | 
|---|
|  |  |  | powerText.text = UIHelper.ReplaceLargeArtNum(PlayerDatas.Instance.baseData.FightPower); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | officialRankText.InitUI(PlayerDatas.Instance.baseData.realmLevel, PlayerDatas.Instance.baseData.TitleID); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void PlayerDataRefresh(PlayerDataType type) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | switch (type) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | case PlayerDataType.FightPower: | 
|---|
|  |  |  | powerText.text = UIHelper.ReplaceLargeArtNum(PlayerDatas.Instance.baseData.FightPower); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case PlayerDataType.RealmLevel: | 
|---|
|  |  |  | officialRankText.InitUI(PlayerDatas.Instance.baseData.realmLevel, PlayerDatas.Instance.baseData.TitleID); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case PlayerDataType.Face: | 
|---|
|  |  |  | case PlayerDataType.FacePic: | 
|---|
|  |  |  | avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)PlayerDatas.Instance.baseData.PlayerID, | 
|---|
|  |  |  | PlayerDatas.Instance.baseData.face, | 
|---|
|  |  |  | PlayerDatas.Instance.baseData.facePic)); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case PlayerDataType.default26: | 
|---|
|  |  |  | hammerText.text = UIHelper.GetMoneyCnt(41).ToString(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 更新货币信息 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void UpdateCurrency() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 从玩家数据中获取货币信息并更新UI | 
|---|
|  |  |  | // 例如: | 
|---|
|  |  |  | // goldText.text = PlayerData.Instance.Gold.ToString(); | 
|---|
|  |  |  | // diamondText.text = PlayerData.Instance.Diamond.ToString(); | 
|---|
|  |  |  | // energyText.text = PlayerData.Instance.Energy + "/" + PlayerData.Instance.MaxEnergy; | 
|---|
|  |  |  | hammerText.text = UIHelper.GetMoneyCnt(41).ToString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 底部标签按钮点击 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void OnBottomTabButtonClicked(int index) | 
|---|
|  |  |  | protected override void OnTabButtonClicked(int 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 选择底部标签 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void SelectBottomTab(int index) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected override void SelectBottomTab(int index) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (index == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //挑战特殊显示逻辑 | 
|---|
|  |  |  | UIManager.Instance.OpenWindow<ChallengeTabWin>(); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果点击当前已选中的标签,不做处理 | 
|---|
|  |  |  | if (currentTabIndex == index && currentSubUI != null) | 
|---|
|  |  |  | if (functionOrder == index && currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TabChangeEvent?.Invoke(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ClickAnimation(index); | 
|---|
|  |  |  | // 更新当前选中的标签索引 | 
|---|
|  |  |  | currentTabIndex = index; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新按钮状态 | 
|---|
|  |  |  | UpdateButtonsState(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | functionOrder = index; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DisplayTopBar(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 关闭当前打开的子界面 | 
|---|
|  |  |  | CloseCurrentSubUI(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 根据选中的标签打开对应的界面 | 
|---|
|  |  |  | OpenSubUIByTabIndex(index); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 更新按钮状态 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void UpdateButtonsState() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 遍历所有按钮,设置选中状态 | 
|---|
|  |  |  | for (int i = 0; i < bottomTabButtons.Length; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 这里可以根据是否选中设置按钮的视觉效果 | 
|---|
|  |  |  | // 例如:改变图片、颜色等 | 
|---|
|  |  |  | // bottomTabButtons[i].GetComponent<Image>().color = (i == currentTabIndex) ? Color.blue : Color.white; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 或者激活/禁用选中图标 | 
|---|
|  |  |  | bottomTabButtons[i].image.color = (i == currentTabIndex) ?  Color.white : Color.gray; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 关闭当前打开的子界面 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void CloseCurrentSubUI() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 关闭当前界面 | 
|---|
|  |  |  | currentSubUI.CloseWindow(); | 
|---|
|  |  |  | currentSubUI = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 根据选中的标签打开对应的界面 | 
|---|
|  |  |  | OpenSubUIByTabIndex(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 根据标签索引打开对应的子界面 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | private void OpenSubUIByTabIndex(int index) | 
|---|
|  |  |  | protected override void OpenSubUIByTabIndex() | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Debug.Log("打开子界面 : " + index); | 
|---|
|  |  |  | // 主城 阵容 同盟 福利 冒险 | 
|---|
|  |  |  | windowBackground.SetActive(index != 4); | 
|---|
|  |  |  | Debug.Log("打开子界面 : " + functionOrder); | 
|---|
|  |  |  | // 主城 内政 武将 挑战 公会 | 
|---|
|  |  |  | //根据索引打开不同的界面 | 
|---|
|  |  |  | switch (index) | 
|---|
|  |  |  | switch (functionOrder) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | case 0: | 
|---|
|  |  |  | // 例如:打开主页界面 | 
|---|
|  |  |  | // currentSubUI = UIManager.Instance.OpenUI<HomeUI>(); | 
|---|
|  |  |  | Debug.Log("打开主城界面"); | 
|---|
|  |  |  | // 打开主页界面 | 
|---|
|  |  |  | if (!UIManager.Instance.IsOpened<BattleWin>()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | BattleWin battleWin = UIManager.Instance.OpenWindow<BattleWin>(); | 
|---|
|  |  |  | battleWin.SetBattleField(BattleManager.Instance.storyBattleField); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>(); | 
|---|
|  |  |  | battleWin.SetBattleField(BattleManager.Instance.storyBattleField); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | currentSubUI = UIManager.Instance.OpenWindow<HomeWin>(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | // 例如:打开角色界面 | 
|---|
|  |  |  | // currentSubUI = UIManager.Instance.OpenUI<CharacterUI>(); | 
|---|
|  |  |  | Debug.Log("打开阵容界面"); | 
|---|
|  |  |  | currentSubUI = UIManager.Instance.OpenWindow<AffairBaseWin>(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | // 例如:打开背包界面 | 
|---|
|  |  |  | // currentSubUI = UIManager.Instance.OpenUI<BagUI>(); | 
|---|
|  |  |  | Debug.Log("打开同盟界面"); | 
|---|
|  |  |  | currentSubUI = UIManager.Instance.OpenWindow<HeroBaseWin>(0); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | // 例如:打开任务界面 | 
|---|
|  |  |  | // currentSubUI = UIManager.Instance.OpenUI<QuestUI>(); | 
|---|
|  |  |  | Debug.Log("打开福利界面"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | // case 3: | 
|---|
|  |  |  | //     挑战界面不跳转 | 
|---|
|  |  |  | //     Debug.Log("打开挑战界面"); | 
|---|
|  |  |  | //     break; | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | // 例如:打开设置界面 | 
|---|
|  |  |  | currentSubUI = UIManager.Instance.OpenWindow<PlaceWin>(); | 
|---|
|  |  |  | Debug.Log("打开冒险界面"); | 
|---|
|  |  |  | currentSubUI = UIManager.Instance.OpenWindow<GuildBaseWin>(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | Debug.LogWarning("未知的标签索引: " + index); | 
|---|
|  |  |  | Debug.LogWarning("未知的标签索引: " + functionOrder); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RefreshFightBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ///战斗按钮显示规则 | 
|---|
|  |  |  | /// 1.在主线战斗界面下: | 
|---|
|  |  |  | ///     1.1.休息状态的按钮 | 
|---|
|  |  |  | ///     1.2.战斗状态的按钮 :显示下一个要攻击的武将头像,按位置顺序推算显示头像;严谨情况下需判断下一个武将是否可攻击如被眩晕等 | 
|---|
|  |  |  | ///         有蒙版:默认显示播放其他战斗的状态,眩晕的状态等比较多(大多是蒙版显示的情况,根据实际看是否需要) | 
|---|
|  |  |  | ///         无蒙版:结束一个小通知的时候(B425)可以释放的去掉蒙版;有怒气的时候是否特殊表现(循环火特效?) | 
|---|
|  |  |  | ///         转圈:点击释放 播放特效且蒙版转圈,转圈结束后显示蒙版 -- 同时上方卡牌播放特效和转圈? | 
|---|
|  |  |  | /// 2.在非主线战斗界面下: | 
|---|
|  |  |  | ///     1. 休息显示关闭状态 无特效 | 
|---|
|  |  |  | ///     2. 战斗中,显示泛红特效 | 
|---|
|  |  |  | /// 上方卡牌 攻击时播放特效和转圈,有怒气的时候显示怒气特效? | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void RefreshFightBtn() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (functionOrder == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //主城界面 | 
|---|
|  |  |  | fightOtherWinBG.SetActive(false); | 
|---|
|  |  |  | fightOtherWinWarnImg.SetActive(false); | 
|---|
|  |  |  | fightBG.SetActive(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (BattleManager.Instance.storyBattleField != null && | 
|---|
|  |  |  | BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightGo.SetActive(false); | 
|---|
|  |  |  | restImg.SetActive(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightGo.SetActive(true); | 
|---|
|  |  |  | restImg.SetActive(false); | 
|---|
|  |  |  | RefreshFightIng(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //非主城界面 | 
|---|
|  |  |  | fightOtherWinBG.SetActive(true); | 
|---|
|  |  |  | fightBG.SetActive(false); | 
|---|
|  |  |  | if (BattleManager.Instance.storyBattleField != null && | 
|---|
|  |  |  | BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightOtherWinWarnImg.SetActive(false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightOtherWinWarnImg.SetActive(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void RefreshFightIng(bool isfighting = false) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (isfighting) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightEffect.Play(); | 
|---|
|  |  |  | cdTween.SetStartState(); | 
|---|
|  |  |  | cdTween.Play(() => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | AutoFightModel.Instance.fightingHeroSkinID = TeamManager.Instance.GetTeam(TeamType.Story).GetNextServerHero(AutoFightModel.Instance.heroGuid).SkinID; | 
|---|
|  |  |  | fightHeroImg.SetOrgSprite(HeroSkinConfig.Get(AutoFightModel.Instance.fightingHeroSkinID).SquareIcon, "HeroHead"); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | fightHeroScale.SetStartState(); | 
|---|
|  |  |  | fightHeroScale.Play(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | fightEffect.Stop(); | 
|---|
|  |  |  | cdTween.Stop(); | 
|---|
|  |  |  | cdTween.SetEndState(); | 
|---|
|  |  |  | fightHeroScale.Stop(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (AutoFightModel.Instance.fightingHeroSkinID == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | AutoFightModel.Instance.fightingHeroSkinID = TeamManager.Instance.GetTeam(TeamType.Story).GetNextServerHero(AutoFightModel.Instance.heroGuid).SkinID; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | fightHeroImg.SetOrgSprite(HeroSkinConfig.Get(AutoFightModel.Instance.fightingHeroSkinID).SquareIcon, "HeroHead"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void OnSkillCast(bool isfighting) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (functionOrder != 0) | 
|---|
|  |  |  | return; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (isfighting) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | RefreshFightIng(isfighting); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | RefreshFightBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 外部调用 | 
|---|
|  |  |  | //外部调用点击功能 | 
|---|
|  |  |  | public void ClickFunc(int functionOrder) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | tabButtons[functionOrder].onClick.Invoke(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //恢复功能按钮状态 | 
|---|
|  |  |  | public void RestoreFuncBtn() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (functionOrder == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (lastWinOrder == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lastWinOrder = 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | functionOrder = lastWinOrder; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tabButtons[functionOrder].SelectBtn(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 外部关闭子界面 | 
|---|
|  |  |  | int lastWinOrder = -1; | 
|---|
|  |  |  | public void CloseSubUI() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (currentSubUI != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lastWinOrder = functionOrder; | 
|---|
|  |  |  | currentSubUI.CloseWindow(); | 
|---|
|  |  |  | currentSubUI = null; | 
|---|
|  |  |  | functionOrder = -1; | 
|---|
|  |  |  | DisplayTopBar(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 外部恢复子界面 | 
|---|
|  |  |  | public void RestoreSubUI() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (lastWinOrder == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lastWinOrder = 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OnTabButtonClicked(lastWinOrder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | } | 
|---|