| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | private BattleRootNode battleRootNode = null; |
| | | |
| | | |
| | | private BattleField battleField; |
| | | private StoryBossBattleField battleField; |
| | | |
| | | [SerializeField] |
| | | private Button btnSpeed; |
| | |
| | | public Text txtBattleRound; |
| | | |
| | | public TotalDamageDisplayer totalDamageDisplayer; |
| | | |
| | | private BattleObject bossBattleObject = null; |
| | | |
| | | [SerializeField] public List<BattleBuffCell> buffCells; |
| | | |
| | | // 生命周期 |
| | | protected override void InitComponent() |
| | |
| | | base.OnPreOpen(); |
| | | // SetBattleField(BattleManager.Instance.storyBattleField); |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | EventBroadcast.Instance.AddListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken); |
| | | |
| | | UIManager.Instance.CloseWindow<MainWin>(); |
| | | } |
| | | |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | UIManager.Instance.CloseWindow<BattleHUDWin>(); |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | EventBroadcast.Instance.RemoveListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken); |
| | | |
| | | UIManager.Instance.CloseWindow<BattleHUDWin>(); |
| | | |
| | | if (!UIManager.Instance.IsOpened<MainWin>()) |
| | | UIManager.Instance.OpenWindow<MainWin>(); |
| | |
| | | { |
| | | if (field.GetType() == battleField.GetType()) |
| | | { |
| | | SetBattleField(field); |
| | | SetBattleField(field as StoryBossBattleField); |
| | | } |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | | { |
| | | base.OnOpen(); |
| | | } |
| | | |
| | | public override void Refresh() |
| | | { |
| | | base.Refresh(); |
| | | |
| | | // bossLifeBar.SetBaseInfo(battleField); |
| | | |
| | | // skillWordCells; |
| | | |
| | | NPCLineupConfig lineupConfig = battleField.GetBossLineupConfig(); |
| | | |
| | | bossBattleObject = battleField.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); |
| | | } |
| | | else |
| | | { |
| | | bossHeadCell.SetTeamHero(null); |
| | | txtBossName.text = string.Empty; |
| | | bossLifeBar.SetBaseInfo(2, 2, 2); |
| | | Debug.LogError("找不到boss"); |
| | | } |
| | | |
| | | txtBattleRound.text = string.Format("{0}/{1}", battleField.round, battleField.turnMax); |
| | | } |
| | | |
| | | private void RefreshHP() |
| | | { |
| | | if (null != bossBattleObject) |
| | | { |
| | | TeamHero teamHero = bossBattleObject.teamHero; |
| | | bossLifeBar.Show((ulong)teamHero.curHp, (ulong)teamHero.maxHp); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void OnDamageTaken(BattleDmgInfo info) |
| | | { |
| | | if (info.hurtObj.ObjID == bossBattleObject.ObjID) |
| | | { |
| | | // Update the boss's health bar |
| | | RefreshHP(); |
| | | } |
| | | |
| | | totalDamageDisplayer.SetDamage(info); |
| | | } |
| | | |
| | | protected override void OnClose() |
| | |
| | | base.CompleteClose(); |
| | | } |
| | | |
| | | public void SetBattleField(BattleField _battleField) |
| | | public void SetBattleField(StoryBossBattleField _battleField) |
| | | { |
| | | battleField = _battleField; |
| | | if (battleRootNode != null) |
| | |
| | | battleField.UpdateCanvas(canvas); |
| | | buttonsAdjuster.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder); |
| | | |
| | | Refresh(); |
| | | |
| | | textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString(); |
| | | } |
| | | |
| | | public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig) |
| | | { |
| | | if (skillWordCells.IsNullOrEmpty()) |
| | | return; |
| | | |
| | | if (null == lineUPConfig) |
| | | return; |
| | | |
| | | for (int i = 0; i < skillWordCells.Length; i++) |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |