From 5cb359503badbf01cb90ea9e733fa3ec5c0832f2 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期一, 27 十月 2025 19:58:55 +0800
Subject: [PATCH] 143 演武场-客户端 ArenaBattleWin BoneFieldBattleWin StoryBossBattleWin 使用基类
---
Main/System/Battle/BoneFieldBattleWin.cs | 184 +++++----------------------------------------
1 files changed, 22 insertions(+), 162 deletions(-)
diff --git a/Main/System/Battle/BoneFieldBattleWin.cs b/Main/System/Battle/BoneFieldBattleWin.cs
index 344b5a4..e20cd7c 100644
--- a/Main/System/Battle/BoneFieldBattleWin.cs
+++ b/Main/System/Battle/BoneFieldBattleWin.cs
@@ -2,72 +2,20 @@
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();
- // 鍒濆鍖栫粍浠跺紩鐢� 缁戝畾鎸夐挳绛塙I缁勪欢浜嬩欢
- 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)
@@ -80,17 +28,11 @@
}
}
-
-
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)
{
@@ -110,45 +52,27 @@
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)
{
@@ -159,7 +83,7 @@
bossBattleObject = null;
}
- bossBattleObject = battleField.FindBoss();
+ bossBattleObject = boneField.FindBoss();
DisplaySkillWordsList(lineupConfig);
@@ -181,14 +105,8 @@
Debug.LogError("鎵句笉鍒癰oss");
}
- OnRoundChange(battleField.round, battleField.turnMax);
-
+ OnRoundChange(battleField.round, battleField.turnMax); // 纭繚鍥炲悎鏄剧ず琚皟鐢�
OnBuffChanged();
-
- totalDamageDisplayer.SetActive(false);
-
- skillTipsBlue.SetActive(false);
- skillTipsRed.SetActive(false);
}
private void OnBuffChanged()
@@ -211,76 +129,23 @@
}
- 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)
@@ -336,13 +201,8 @@
}
}
- private void OnRoundChange(int round, int maxRound)
- {
- txtBattleRound.text = string.Format("{0}/{1}", round, maxRound);
- }
bool IsOpenBattleChangeTab()
{
return FuncOpen.Instance.IsFuncOpen(ArenaManager.Instance.BattleChangeTabFuncId);
}
-
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0