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/UIComp/TotalDamageDisplayer.cs | 78 +++++++++++++++++++++++++++++++++++---
1 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/Main/System/Battle/UIComp/TotalDamageDisplayer.cs b/Main/System/Battle/UIComp/TotalDamageDisplayer.cs
index 41df9e1..1ed0fe3 100644
--- a/Main/System/Battle/UIComp/TotalDamageDisplayer.cs
+++ b/Main/System/Battle/UIComp/TotalDamageDisplayer.cs
@@ -1,32 +1,96 @@
using System.Collections;
-using System.Collections.Generic;
+using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
+using System.Threading;
public class TotalDamageDisplayer : MonoBehaviour
{
public Image damageBackground;
-
public Text textDamage;
-
public Text textTotalDesc; //鎬讳激瀹虫垨鑰呮�绘不鐤�
- public void SetDamage(bool isEnd, BattleDmgInfo dmgInfo)
+ public UniTask task = default;
+
+ private Coroutine hideCoroutine;
+ private int hideVersion = 0;
+
+ public void SetDamage(BattleDmgInfo dmgInfo)
{
+ // 鍏堢粺涓�鍋滄骞舵竻鐞嗘鍓嶇殑闅愯棌鍗忕▼锛堝鏋滄湁锛�
+ ClearHideCoroutine();
+
+ if (!gameObject.activeInHierarchy)
+ gameObject.SetActive(true);
+
if (dmgInfo == null)
- {
return;
- }
if (dmgInfo.IsType(DamageType.Recovery))
{
-
+ // 淇濇寔鍘熸湁澶勭悊閫昏緫浣嶇疆
}
else if (dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsType(DamageType.Realdamage))
{
+ // 淇濇寔鍘熸湁澶勭悊閫昏緫浣嶇疆
+ }
+ if (dmgInfo.isLastHit)
+ {
+ // 鍚姩鏂扮殑闅愯棌鍗忕▼锛屽厛鐢熸垚鏂扮殑鐗堟湰鍙蜂互鐢ㄤ簬鍗忕▼鏈夋晥鎬ф牎楠�
+ hideVersion++;
+ int myVersion = hideVersion;
+
+
+ var battleField = BattleManager.Instance.GetBattleField(dmgInfo.battleFieldGuid);
+
+ float ms = 1000f / battleField.speedRatio;
+
+ hideCoroutine = StartCoroutine(HideAfterDelayCoroutine(ms, myVersion));
+
+ task = default;
}
}
+ protected void OnDisable()
+ {
+ ClearHideCoroutine();
+ hideVersion++;
+ }
+ protected void OnDestroy()
+ {
+ ClearHideCoroutine();
+ hideVersion++;
+ }
+
+ public void CancelHide()
+ {
+ ClearHideCoroutine();
+ hideVersion++;
+ }
+
+ private void ClearHideCoroutine()
+ {
+ if (hideCoroutine != null)
+ {
+ try { StopCoroutine(hideCoroutine); } catch { }
+ hideCoroutine = null;
+ }
+ }
+
+ private IEnumerator HideAfterDelayCoroutine(float secondsDelay, int version = 0)
+ {
+ yield return new WaitForSeconds(secondsDelay);
+
+ if (version != 0 && version != hideVersion)
+ yield break;
+
+ if (this == null) yield break;
+ if (gameObject != null)
+ gameObject.SetActive(false);
+
+ if (hideCoroutine != null)
+ hideCoroutine = null;
+ }
}
--
Gitblit v1.8.0