| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class BoneFieldBattleWin : UIBase |
| | | public class BoneFieldBattleWin : BaseBattleWin |
| | | { |
| | | [SerializeField] Transform transButtons; |
| | | public Transform mountPoint; |
| | | private BattleRootNode battleRootNode = null; |
| | | private BoneBattleField 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; |
| | | public SkillTips skillTipsRed; |
| | | public SkillTips skillTipsBlue; |
| | | [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; |
| | | |
| | | // 生命周期 |
| | | 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(); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | base.OnPreOpen(); |
| | | MainWin.TabChangeEvent += OnTabChangeEvent; |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | EventBroadcast.Instance.AddListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken); |
| | | EventBroadcast.Instance.AddListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnCastSkill); |
| | | BattleManager.Instance.storyBattleField.IsPause = true; |
| | | bool isOpenBattleChangeTab = IsOpenBattleChangeTab(); |
| | | transButtons.localPosition = new Vector3(0, isOpenBattleChangeTab ? 130 : 0, 0); |
| | | if (isOpenBattleChangeTab) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | |
| | | MainWin.TabChangeEvent -= OnTabChangeEvent; |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | EventBroadcast.Instance.RemoveListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken); |
| | | EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnCastSkill); |
| | | UIManager.Instance.CloseWindow<BattleHUDWin>(); |
| | | BattleManager.Instance.storyBattleField.IsPause = false; |
| | | bool isOpenBattleChangeTab = IsOpenBattleChangeTab(); |
| | | if (isOpenBattleChangeTab) |
| | | { |
| | |
| | | bossBattleObject = null; |
| | | } |
| | | |
| | | if (battleField != null) |
| | | { |
| | | battleField.OnRoundChange -= OnRoundChange; |
| | | battleField = null; |
| | | } |
| | | } |
| | | |
| | | private void OnTabChangeEvent() |
| | | { |
| | | UIManager.Instance.CloseWindow<BoneFieldBattleWin>(); |
| | | } |
| | | |
| | | private void OnCastSkill(string guid, SkillConfig skillConfig, TeamHero teamHero) |
| | | |
| | | protected override void OnCreateBattleField(string guid, BattleField field) |
| | | { |
| | | if (battleField == null) |
| | | return; |
| | | |
| | | if (battleField.guid != guid) |
| | | return; |
| | | |
| | | BattleObject battleObject = battleField.battleObjMgr.GetBattleObject(teamHero.ObjID); |
| | | bool isRed = battleObject.Camp == BattleCamp.Red; |
| | | SkillTips tips = isRed ? skillTipsRed : skillTipsBlue; |
| | | tips.PlayMotion(battleField, isRed, teamHero, skillConfig); |
| | | } |
| | | |
| | | private void OnCreateBattleField(string arg1, BattleField field) |
| | | { |
| | | if (field.GetType() == battleField.GetType()) |
| | | if (field is BoneBattleField) |
| | | { |
| | | SetBattleField(field as BoneBattleField); |
| | | SetBattleField(field); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void Display() |
| | | protected override void RefreshSpecific() |
| | | { |
| | | BoneBattleField boneField = battleField as BoneBattleField; |
| | | if (boneField == null) return; |
| | | |
| | | NPCLineupConfig lineupConfig = battleField.GetBossLineupConfig(); |
| | | NPCLineupConfig lineupConfig = boneField.GetBossLineupConfig(); |
| | | |
| | | if (bossBattleObject != null) |
| | | { |
| | |
| | | bossBattleObject = null; |
| | | } |
| | | |
| | | bossBattleObject = battleField.FindBoss(); |
| | | bossBattleObject = boneField.FindBoss(); |
| | | |
| | | DisplaySkillWordsList(lineupConfig); |
| | | |
| | |
| | | Debug.LogError("找不到boss"); |
| | | } |
| | | |
| | | OnRoundChange(battleField.round, battleField.turnMax); |
| | | |
| | | OnRoundChange(battleField.round, battleField.turnMax); // 确保回合显示被调用 |
| | | OnBuffChanged(); |
| | | |
| | | totalDamageDisplayer.SetActive(false); |
| | | |
| | | skillTipsBlue.SetActive(false); |
| | | skillTipsRed.SetActive(false); |
| | | } |
| | | |
| | | private void OnBuffChanged() |
| | |
| | | } |
| | | |
| | | |
| | | private void OnDamageTaken(BattleDmgInfo info) |
| | | protected override void OnDamageTaken(BattleDmgInfo info) |
| | | { |
| | | if (info.battleFieldGuid != battleField.guid) |
| | | base.OnDamageTaken(info); |
| | | |
| | | if (battleField == null || info.battleFieldGuid != battleField.guid) |
| | | return; |
| | | |
| | | if (info.hurtObj.ObjID == bossBattleObject.ObjID) |
| | | if (bossBattleObject != null && info.hurtObj.ObjID == bossBattleObject.ObjID) |
| | | { |
| | | // Update the boss's health bar |
| | | RefreshHP(); |
| | | } |
| | | |
| | | totalDamageDisplayer.SetDamage(info); |
| | | } |
| | | |
| | | 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() |
| | | { |
| | | base.NextFrameAfterOpen(); |
| | | } |
| | | |
| | | protected override void CompleteClose() |
| | | { |
| | | base.CompleteClose(); |
| | | } |
| | | |
| | | public void SetBattleField(BoneBattleField _battleField) |
| | | { |
| | | if (battleField != null) |
| | | { |
| | | battleField.OnRoundChange -= OnRoundChange; |
| | | battleField = null; |
| | | } |
| | | |
| | | battleField = _battleField; |
| | | if (battleRootNode != null) |
| | | { |
| | | battleRootNode.transform.localPosition = Vector3.zero; |
| | | battleRootNode.transform.SetParent(Launch.Instance.transform); |
| | | } |
| | | |
| | | 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); |
| | | Display(); |
| | | battleField.OnRoundChange += OnRoundChange; |
| | | textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString(); |
| | | } |
| | | |
| | | public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig) |
| | |
| | | } |
| | | } |
| | | |
| | | private void OnRoundChange(int round, int maxRound) |
| | | { |
| | | txtBattleRound.text = string.Format("{0}/{1}", round, maxRound); |
| | | } |
| | | bool IsOpenBattleChangeTab() |
| | | { |
| | | return FuncOpen.Instance.IsFuncOpen(ArenaManager.Instance.BattleChangeTabFuncId); |
| | | } |
| | | |
| | | } |
| | | } |