From 3bd7f56906e31e8fe0072108c9d4652707b51de8 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 21 十月 2025 17:59:00 +0800
Subject: [PATCH] 125 战斗 战斗UI
---
Main/System/Battle/StoryBossBattleWin.cs | 127 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 123 insertions(+), 4 deletions(-)
diff --git a/Main/System/Battle/StoryBossBattleWin.cs b/Main/System/Battle/StoryBossBattleWin.cs
index 1c3db8a..6e54f4b 100644
--- a/Main/System/Battle/StoryBossBattleWin.cs
+++ b/Main/System/Battle/StoryBossBattleWin.cs
@@ -1,4 +1,5 @@
锘縰sing System;
+using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -11,7 +12,7 @@
private BattleRootNode battleRootNode = null;
- private BattleField battleField;
+ private StoryBossBattleField battleField;
[SerializeField]
private Button btnSpeed;
@@ -39,6 +40,10 @@
public Text txtBattleRound;
public TotalDamageDisplayer totalDamageDisplayer;
+
+ private BattleObject bossBattleObject = null;
+
+ [SerializeField] public List<BattleBuffCell> buffCells;
// 鐢熷懡鍛ㄦ湡
protected override void InitComponent()
@@ -84,15 +89,20 @@
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>();
@@ -102,13 +112,67 @@
{
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("鎵句笉鍒癰oss");
+ }
+
+ 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()
@@ -134,7 +198,7 @@
base.CompleteClose();
}
- public void SetBattleField(BattleField _battleField)
+ public void SetBattleField(StoryBossBattleField _battleField)
{
battleField = _battleField;
if (battleRootNode != null)
@@ -160,6 +224,61 @@
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鎻忚堪/褰撳墠韬笂鎵�鏈塨uff
+ });
+ }
+ else
+ {
+ buffCells[i].SetActive(false);
+ }
+ }
+ }
}
--
Gitblit v1.8.0