| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class BoneFieldBattleWin : UIBase |
| | | public class BoneFieldBattleWin : BaseBattleWin |
| | | { |
| | | |
| | | // 组件引用 |
| | | public Transform mountPoint; |
| | | |
| | | private BattleRootNode battleRootNode = null; |
| | | |
| | | |
| | | private BattleField battleField; |
| | | |
| | | [SerializeField] |
| | | private Button btnSpeed; |
| | | |
| | | [SerializeField] |
| | | private Text textSpeed; |
| | | |
| | | [SerializeField] |
| | | private Button btnPass; |
| | | |
| | | [SerializeField] |
| | | private Button btnPause; |
| | | |
| | | public BossLifeBar bossLifeBar; |
| | | |
| | | |
| | | public SkillWordCell[] skillWordCells; |
| | | |
| | | public BossHeadCell bossHeadCell; |
| | | |
| | | public Text txtBossName; |
| | | |
| | | public Text txtBattleRound; |
| | | |
| | | public TotalDamageDisplayer totalDamageDisplayer; |
| | | |
| | | // 生命周期 |
| | | protected override void InitComponent() |
| | | { |
| | | base.InitComponent(); |
| | | // 初始化组件引用 绑定按钮等UI组件事件 |
| | | |
| | | btnSpeed.AddListener(ChangeSpeed); |
| | | |
| | | btnPass.AddListener(OnClickPass); |
| | | |
| | | btnPause.AddListener(OnClickPause); |
| | | } |
| | | |
| | | private void OnClickPause() |
| | | { |
| | | if (null == battleField) |
| | | return; |
| | | |
| | | battleField.IsPause = !battleField.IsPause; |
| | | } |
| | | |
| | | private void OnClickPass() |
| | | { |
| | | if (null == battleField) |
| | | return; |
| | | |
| | | battleField.ForceFinish(); |
| | | } |
| | | |
| | | private void ChangeSpeed() |
| | | { |
| | | if (null == battleField) |
| | | return; |
| | | |
| | | BattleManager.Instance.speedIndex = (BattleManager.Instance.speedIndex + 1) % BattleManager.Instance.speedGear.Length; |
| | | battleField.SetSpeedRatio(BattleManager.Instance.speedGear[BattleManager.Instance.speedIndex]); |
| | | textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString(); |
| | | } |
| | | [SerializeField] Transform transButtons; |
| | | [SerializeField] public BossLifeBar bossLifeBar; |
| | | [SerializeField] public SkillWordCell[] skillWordCells; |
| | | [SerializeField] public BossHeadCell bossHeadCell; |
| | | [SerializeField] public Text txtBossName; |
| | | private BattleObject bossBattleObject = null; |
| | | [SerializeField] public List<BattleBuffCell> buffCells; |
| | | [SerializeField] HeroCountryComponent myCountry; |
| | | [SerializeField] HeroCountryComponent enemyCountry; |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | base.OnPreOpen(); |
| | | // SetBattleField(BattleManager.Instance.storyBattleField); |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | |
| | | UIManager.Instance.CloseWindow<MainWin>(); |
| | | MainWin.TabChangeEvent += OnTabChangeEvent; |
| | | bool isOpenBattleChangeTab = IsOpenBattleChangeTab(); |
| | | transButtons.localPosition = new Vector3(0, isOpenBattleChangeTab ? 130 : 0, 0); |
| | | if (isOpenBattleChangeTab) |
| | | { |
| | | UIManager.Instance.GetUI<MainWin>()?.CloseSubUI(); |
| | | } |
| | | else |
| | | { |
| | | UIManager.Instance.CloseWindow<MainWin>(); |
| | | } |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | UIManager.Instance.CloseWindow<BattleHUDWin>(); |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | |
| | | if (!UIManager.Instance.IsOpened<MainWin>()) |
| | | MainWin.TabChangeEvent -= OnTabChangeEvent; |
| | | bool isOpenBattleChangeTab = IsOpenBattleChangeTab(); |
| | | if (isOpenBattleChangeTab) |
| | | { |
| | | UIManager.Instance.GetUI<MainWin>()?.RestoreSubUI(); |
| | | } |
| | | else |
| | | { |
| | | UIManager.Instance.OpenWindow<MainWin>(); |
| | | } |
| | | |
| | | if (bossBattleObject != null) |
| | | { |
| | | if (bossBattleObject.buffMgr != null) |
| | | { |
| | | bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged; |
| | | } |
| | | bossBattleObject = null; |
| | | } |
| | | |
| | | } |
| | | |
| | | private void OnCreateBattleField(string arg1, BattleField field) |
| | | private void OnTabChangeEvent() |
| | | { |
| | | if (field.GetType() == battleField.GetType()) |
| | | UIManager.Instance.CloseWindow<BoneFieldBattleWin>(); |
| | | } |
| | | |
| | | protected override void OnCreateBattleField(string guid, BattleField field) |
| | | { |
| | | if (field is BoneBattleField) |
| | | { |
| | | SetBattleField(field); |
| | | } |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | protected override void RefreshSpecific() |
| | | { |
| | | base.OnOpen(); |
| | | BoneBattleField boneField = battleField as BoneBattleField; |
| | | if (boneField == null) return; |
| | | |
| | | NPCLineupConfig lineupConfig = boneField.GetBossLineupConfig(); |
| | | |
| | | if (bossBattleObject != null) |
| | | { |
| | | if (bossBattleObject.buffMgr != null) |
| | | { |
| | | bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged; |
| | | } |
| | | bossBattleObject = null; |
| | | } |
| | | |
| | | bossBattleObject = boneField.FindBoss(); |
| | | |
| | | DisplaySkillWordsList(lineupConfig); |
| | | |
| | | if (null != bossBattleObject) |
| | | { |
| | | TeamHero teamHero = bossBattleObject.teamHero; |
| | | bossHeadCell.SetTeamHero(teamHero); |
| | | txtBossName.text = teamHero.name; |
| | | NPCConfig npcConfig = NPCConfig.Get(teamHero.NPCID); |
| | | bossLifeBar.SetBaseInfo(Mathf.Max(1, npcConfig.LifeBarCount), (ulong)teamHero.curHp, (ulong)teamHero.maxHp); |
| | | bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged; |
| | | bossBattleObject.buffMgr.onBuffChanged += OnBuffChanged; |
| | | } |
| | | else |
| | | { |
| | | bossHeadCell.SetTeamHero(null); |
| | | txtBossName.text = string.Empty; |
| | | bossLifeBar.SetBaseInfo(2, 2, 2); |
| | | Debug.LogError("找不到boss"); |
| | | } |
| | | |
| | | OnRoundChange(battleField.round, battleField.turnMax); // 确保回合显示被调用 |
| | | OnBuffChanged(); |
| | | |
| | | // 获取我方(红方)队伍数据 |
| | | List<BattleObject> myTeam = battleField.battleObjMgr.GetBattleObjList(BattleCamp.Red); |
| | | // 获取敌方(蓝方)队伍数据 |
| | | List<BattleObject> enemyTeam = battleField.battleObjMgr.GetBattleObjList(BattleCamp.Blue); |
| | | |
| | | myCountry.RefreshOnTeamCountry(GetTeamHeroList(myTeam), true); |
| | | enemyCountry.RefreshOnTeamCountry(GetTeamHeroList(enemyTeam), true); |
| | | } |
| | | |
| | | private void OnBuffChanged() |
| | | { |
| | | var buffList = new List<HB428_tagSCBuffRefresh>(); |
| | | if (null != bossBattleObject) |
| | | { |
| | | buffList = bossBattleObject.buffMgr.GetBuffList(); |
| | | } |
| | | RefreshBuff(buffList); |
| | | } |
| | | |
| | | private void RefreshHP() |
| | | { |
| | | if (null != bossBattleObject) |
| | | { |
| | | TeamHero teamHero = bossBattleObject.teamHero; |
| | | bossLifeBar.Show((ulong)teamHero.curHp, (ulong)teamHero.maxHp); |
| | | } |
| | | } |
| | | |
| | | |
| | | protected override void OnDamageTaken(BattleDmgInfo info) |
| | | { |
| | | base.OnDamageTaken(info); |
| | | |
| | | if (battleField == null || info.battleFieldGuid != battleField.guid) |
| | | return; |
| | | |
| | | if (bossBattleObject != null && info.hurtObj.ObjID == bossBattleObject.ObjID) |
| | | { |
| | | RefreshHP(); |
| | | } |
| | | |
| | | } |
| | | |
| | | protected override void OnClose() |
| | | { |
| | | base.OnClose(); |
| | | |
| | | if (battleRootNode != null) |
| | | { |
| | | battleRootNode.transform.SetParent(Launch.Instance.transform); |
| | | battleRootNode.transform.localPosition = new Vector3(-10000, -10000, 0); |
| | | } |
| | | |
| | | battleField = null; |
| | | } |
| | | |
| | | protected override void NextFrameAfterOpen() |
| | | public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig) |
| | | { |
| | | base.NextFrameAfterOpen(); |
| | | } |
| | | if (skillWordCells.IsNullOrEmpty()) |
| | | return; |
| | | |
| | | protected override void CompleteClose() |
| | | { |
| | | base.CompleteClose(); |
| | | } |
| | | if (null == lineUPConfig) |
| | | return; |
| | | |
| | | public void SetBattleField(BattleField _battleField) |
| | | { |
| | | battleField = _battleField; |
| | | if (battleRootNode != null) |
| | | for (int i = 0; i < skillWordCells.Length; i++) |
| | | { |
| | | battleRootNode.transform.localPosition = Vector3.zero; |
| | | battleRootNode.transform.SetParent(Launch.Instance.transform); |
| | | if (i < lineUPConfig.SkillIDExList.Length) |
| | | { |
| | | skillWordCells[i].SetActive(true); |
| | | int skillID = lineUPConfig.SkillIDExList[i]; |
| | | skillWordCells[i].Init(skillID, () => |
| | | { |
| | | SmallTipWin.showText = Language.Get("SmallTipFomat", SkillConfig.Get(skillID)?.SkillName, SkillConfig.Get(skillID)?.Description); |
| | | SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition); |
| | | SmallTipWin.isDownShow = true; |
| | | UIManager.Instance.OpenWindow<SmallTipWin>(); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | skillWordCells[i].SetActive(false); |
| | | } |
| | | } |
| | | |
| | | battleRootNode = battleField.battleRootNode; |
| | | |
| | | battleRootNode.transform.SetParent(mountPoint); |
| | | battleRootNode.transform.localPosition = Vector3.zero; |
| | | battleRootNode.transform.localScale = Vector3.one; |
| | | |
| | | BattleHUDWin ui = UIManager.Instance.GetUI<BattleHUDWin>(); |
| | | |
| | | if (null == ui) |
| | | { |
| | | ui = UIManager.Instance.OpenWindow<BattleHUDWin>(); |
| | | } |
| | | |
| | | ui.SetBattleField(battleField); |
| | | battleField.UpdateCanvas(canvas); |
| | | |
| | | textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString(); |
| | | } |
| | | } |
| | | |
| | | public void RefreshBuff(List<HB428_tagSCBuffRefresh> datas) |
| | | { |
| | | if (buffCells.IsNullOrEmpty()) |
| | | return; |
| | | |
| | | |
| | | for (int i = 0; i < buffCells.Count; i++) |
| | | { |
| | | if (i < datas.Count) |
| | | { |
| | | buffCells[i].SetActive(true); |
| | | HB428_tagSCBuffRefresh buffData = datas[i]; |
| | | buffCells[i].Init(buffData, () => |
| | | { |
| | | // 点击buff图标 显示buff描述/当前身上所有buff |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | buffCells[i].SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | bool IsOpenBattleChangeTab() |
| | | { |
| | | return FuncOpen.Instance.IsFuncOpen(ArenaManager.Instance.BattleChangeTabFuncId); |
| | | } |
| | | |
| | | List<TeamHero> GetTeamHeroList(List<BattleObject> teams) |
| | | { |
| | | List<TeamHero> teamHeroes = new List<TeamHero>(); |
| | | if (teams.IsNullOrEmpty()) |
| | | return teamHeroes; |
| | | foreach (var item in teams) |
| | | { |
| | | teamHeroes.Add(item.teamHero); |
| | | } |
| | | return teamHeroes; |
| | | |
| | | } |
| | | } |