From dc7922d80c1d133b6261b8af1d521567d2c0a35d Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 30 十月 2025 16:51:39 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts
---
Main/System/Battle/UIComp/DamageContent.cs | 148 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 96 insertions(+), 52 deletions(-)
diff --git a/Main/System/Battle/UIComp/DamageContent.cs b/Main/System/Battle/UIComp/DamageContent.cs
index 357149f..a87ed73 100644
--- a/Main/System/Battle/UIComp/DamageContent.cs
+++ b/Main/System/Battle/UIComp/DamageContent.cs
@@ -4,71 +4,115 @@
using System;
using Cysharp.Threading.Tasks;
-public class DamageContent : MonoBehaviour
+public class DamageContent : MonoBehaviour, IBattleFloatingUI
{
- public GameObject line;
+ public GameObject line;
+ public RectTransform parent;
- public RectTransform parent;
+ public Vector2 beginPos = Vector2.zero;
+ public Vector2 endPos = new Vector2(0, 150);
- protected List<DamageLine> damageLineList = new List<DamageLine>();
+ protected List<DamageLine> damageLineList = new List<DamageLine>();
+ private BattleDmgInfo battleDmgInfo;
+ private BattleFloatingUIController controller;
- public PositionTween posTween;
+ // 椋樿浼樺寲锛氬垵濮嬫斁澶�200%锛岄�忔槑搴�50%锛�7~8甯у唴缂╂斁鍥�100%锛岄�忔槑搴﹀洖鍒�100%锛屽啀寰�涓婇14~16甯с��30甯�/绉掋�戯紝鏆村嚮鍒濆鏀惧ぇ300%锛岀缉鍥�150%
+ // 鎴樻枟甯attleConst.skillMotionFps 1绉�=30甯�
- public ScaleTween scaleTween;
+ void Awake()
+ {
+ line.SetActive(false);
+ }
- private BattleDmgInfo battleDmgInfo;
+ private void InitController()
+ {
+ if (controller != null) return;
- void Awake()
- {
- line.SetActive(false);
- }
+ RectTransform rectTransform = GetComponent<RectTransform>();
+ controller = new BattleFloatingUIController(rectTransform, gameObject, ApplyColor);
+
+ // 浣跨敤褰撳墠璁剧疆鐨� beginPos 鍜� endPos
+ controller.beginPos = beginPos;
+ controller.endPos = endPos;
+ // controller.scaleChangeTime = scaleChangeTime;
+ // controller.totalShowTime = totalShowTime;
+ // controller.normalBeginScale = normalBeginScale;
+ // controller.normalEndScale = normalEndScale;
+ // controller.critBeginScale = critBeginScale;
+ // controller.critEndScale = critEndScale;
+ // controller.beginColor = beginColor;
+ // controller.endColor = endColor;
+ }
- public async void SetDamage(BattleDmgInfo _damageInfo, Action _onComplete)
- {
- battleDmgInfo = _damageInfo;
+ public void SetRatio(float speed, float scale)
+ {
+ InitController();
+ controller.SetRatio(speed, scale);
+ }
- var damages = battleDmgInfo.battleDamageList;
+ public async void SetDamage(BattleDmgInfo _damageInfo, Action _onComplete)
+ {
+ battleDmgInfo = _damageInfo;
- for (int i = damages.Count; i < damageLineList.Count; i++)
- {
- damageLineList[i].SetActive(false);
- }
+ var damages = battleDmgInfo.battleDamageList;
- posTween.Play(_onComplete);
+ for (int i = damages.Count; i < damageLineList.Count; i++)
+ {
+ damageLineList[i].SetActive(false);
+ }
- if (battleDmgInfo.IsCrit())
- {
- scaleTween.Play();
- }
+ // 浣跨敤鎺у埗鍣ㄧ殑Play鏂规硶
+ bool isCrit = battleDmgInfo.IsCrit();
+ Play(isCrit, _onComplete);
- for (int i = 0; i < damages.Count; i++)
- {
- if (i >= damageLineList.Count)
- {
- GameObject newLine = GameObject.Instantiate(line, parent);
- damageLineList.Add(newLine.GetComponent<DamageLine>());
- }
- damageLineList[i].SetActive(true);
- damageLineList[i].SetDamage(damages[i]);
- await UniTask.Delay(100);
- }
- }
+ for (int i = 0; i < damages.Count; i++)
+ {
+ if (i >= damageLineList.Count)
+ {
+ GameObject newLine = GameObject.Instantiate(line, parent);
+ damageLineList.Add(newLine.GetComponent<DamageLine>());
+ }
+ damageLineList[i].SetActive(true);
+ damageLineList[i].SetDamage(damages[i]);
+ await UniTask.Delay(100);
+ }
+ }
- public void Stop()
- {
- posTween.Stop();
- if (battleDmgInfo.IsCrit())
- {
- scaleTween.Stop();
- }
- }
+ public void Play(bool isCrit, Action onComplete = null)
+ {
+ InitController();
+ // 姣忔Play鍓嶆洿鏂癱ontroller鐨勪綅缃缃�
+ controller.beginPos = beginPos;
+ controller.endPos = endPos;
+ controller.Play(isCrit, onComplete);
+ }
- public void Resume()
- {
- posTween.Resume();
- if (battleDmgInfo.IsCrit())
- {
- scaleTween.Resume();
- }
- }
+ public void Run()
+ {
+ if (controller == null) return;
+ controller.Run();
+ }
+
+ public void Stop()
+ {
+ if (controller == null) return;
+ controller.Stop();
+ }
+
+ public void Resume()
+ {
+ if (controller == null) return;
+ controller.Resume();
+ }
+
+ private void ApplyColor(Color color)
+ {
+ for (int i = 0; i < damageLineList.Count; i++)
+ {
+ if (damageLineList[i].gameObject.activeSelf)
+ {
+ damageLineList[i].SetColor(color);
+ }
+ }
+ }
}
--
Gitblit v1.8.0