From 97f4169588320fcf84bda92e12415650869ddaff Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 18:45:54 +0800
Subject: [PATCH] 125 战斗 飘字配置化
---
Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs.meta | 11
Main/Component/UI/Effect/ScriptableObject.meta | 8
Main/System/Battle/UIComp/DamageContent.cs | 54 +-
Main/System/Battle/BattleField/RecordActions/BuffMountAction.cs | 6
Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs | 51 ++
Main/System/Battle/BattleHUDWin.cs | 7
Main/System/Battle/UIComp/BattleHeroInfoBar.cs | 412 +++++++++++++++------
Main/System/Battle/UIComp/BattleFloatingUIController.cs | 290 ++++++++++++--
Main/System/Battle/UIComp/BattleTips.cs | 253 +++++++++---
9 files changed, 809 insertions(+), 283 deletions(-)
diff --git a/Main/Component/UI/Effect/ScriptableObject.meta b/Main/Component/UI/Effect/ScriptableObject.meta
new file mode 100644
index 0000000..425d973
--- /dev/null
+++ b/Main/Component/UI/Effect/ScriptableObject.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c6e2ae278e429844e9d5da2ebc5e5d6d
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs b/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs
new file mode 100644
index 0000000..3541651
--- /dev/null
+++ b/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs
@@ -0,0 +1,51 @@
+using UnityEngine;
+
+/// <summary>
+/// 鎴樻枟椋樺瓧閰嶇疆 ScriptableObject
+/// 鐢ㄤ簬閰嶇疆椋樺瓧鐨勫姩鐢绘晥鏋滃弬鏁�
+/// </summary>
+[CreateAssetMenu(fileName = "FloatingConfig", menuName = "Battle/FloatingConfig", order = 1)]
+public class FloatingConfig : ScriptableObject
+{
+ [Header("Position Settings")]
+ [Tooltip("璧峰浣嶇疆鍋忕Щ")]
+ public Vector2 beginPos = Vector2.zero;
+ [Tooltip("缁撴潫浣嶇疆鍋忕Щ")]
+ public Vector2 endPos = new Vector2(0, 150);
+ [Tooltip("浣嶇疆绉诲姩鏇茬嚎 (X杞�=鏃堕棿杩涘害0-1, Y杞�=鎻掑�艰繘搴�0-1)")]
+ public AnimationCurve positionCurve = AnimationCurve.Linear(0, 0, 1, 1);
+
+ [Header("Time Settings")]
+ [Tooltip("缂╂斁鍙樺寲鏃堕棿 (绾�16甯�)")]
+ public float scaleChangeTime = 1f / BattleConst.skillMotionFps * 16f + 0.1f;
+ [Tooltip("鎬绘樉绀烘椂闂� (绾�48甯�)")]
+ public float totalShowTime = 1f / BattleConst.skillMotionFps * 48f + 0.1f;
+
+ [Header("Normal Animation Settings")]
+ [Tooltip("鏅�氶瀛楀垵濮嬬缉鏀�")]
+ public Vector3 normalBeginScale = new Vector3(2f, 2f, 2f);
+ [Tooltip("鏅�氶瀛楃粨鏉熺缉鏀�")]
+ public Vector3 normalEndScale = new Vector3(1f, 1f, 1f);
+
+ [Header("Critical Animation Settings")]
+ [Tooltip("鏆村嚮椋樺瓧鍒濆缂╂斁")]
+ public Vector3 critBeginScale = new Vector3(3f, 3f, 3f);
+ [Tooltip("鏆村嚮椋樺瓧缁撴潫缂╂斁")]
+ public Vector3 critEndScale = new Vector3(1.5f, 1.5f, 1.5f);
+ [Tooltip("缂╂斁鍙樺寲鏇茬嚎 (X杞�=鏃堕棿杩涘害0-1, Y杞�=鎻掑�艰繘搴�0-1)")]
+ public AnimationCurve scaleCurve = AnimationCurve.Linear(0, 0, 1, 1);
+
+ [Header("Color Settings")]
+ [Tooltip("鍒濆棰滆壊鍜岄�忔槑搴�")]
+ public Color beginColor = new Color(1f, 1f, 1f, 0.5f);
+ [Tooltip("缁撴潫棰滆壊鍜岄�忔槑搴�")]
+ public Color endColor = new Color(1f, 1f, 1f, 1f);
+ [Tooltip("棰滆壊鍙樺寲鏇茬嚎 (X杞�=鏃堕棿杩涘害0-1, Y杞�=鎻掑�艰繘搴�0-1)")]
+ public AnimationCurve colorCurve = AnimationCurve.Linear(0, 0, 1, 1);
+
+ [Header("Buff Color Settings")]
+ [Tooltip("姝e悜Buff棰滆壊 (澧炵泭buff)")]
+ public Color gainBuffColor = Color.green;
+ [Tooltip("璐熷悜Buff棰滆壊 (debuff)")]
+ public Color debuffColor = Color.red;
+}
\ No newline at end of file
diff --git a/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs.meta b/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs.meta
new file mode 100644
index 0000000..b69b3ec
--- /dev/null
+++ b/Main/Component/UI/Effect/ScriptableObject/FloatingConfig.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 900f40b168d3e0b4f9bebd9917a43c7e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Battle/BattleField/RecordActions/BuffMountAction.cs b/Main/System/Battle/BattleField/RecordActions/BuffMountAction.cs
index 15731ff..858697d 100644
--- a/Main/System/Battle/BattleField/RecordActions/BuffMountAction.cs
+++ b/Main/System/Battle/BattleField/RecordActions/BuffMountAction.cs
@@ -40,9 +40,11 @@
tipsInfo.useArtText = false;
tipsInfo.followCharacter = true;
tipsInfo.scaleRatio = 1f;
- tipsInfo.textColor = skillConfig.IsDebuff() ?
- Color.red : skillConfig.IsGainBuff() ? Color.green : Color.white;
tipsInfo.showBackground = true;
+
+ // 浣跨敤 Buff 棰滆壊
+ tipsInfo.useBuffColor = true;
+ tipsInfo.isDebuff = skillConfig.IsDebuff();
obj.heroInfoBar.ShowTips(tipsInfo);
}
diff --git a/Main/System/Battle/BattleHUDWin.cs b/Main/System/Battle/BattleHUDWin.cs
index 7a893e6..2b7539e 100644
--- a/Main/System/Battle/BattleHUDWin.cs
+++ b/Main/System/Battle/BattleHUDWin.cs
@@ -120,9 +120,10 @@
null,
out anchoredPos);
- // 璁剧疆鍒濆浣嶇疆鍜岀粨鏉熶綅缃�
- content.beginPos = anchoredPos;
- content.endPos = anchoredPos + new Vector2(0, 150);
+ // 璁剧疆鍔ㄦ�佷綅缃紙浼氳鐩栭厤缃腑鐨勪綅缃級
+ Vector2 beginPos = anchoredPos;
+ Vector2 endPos = anchoredPos + new Vector2(0, 150);
+ content.SetPosition(beginPos, endPos);
// 璁剧疆閫熷害姣斾緥
if (battleField != null)
diff --git a/Main/System/Battle/UIComp/BattleFloatingUIController.cs b/Main/System/Battle/UIComp/BattleFloatingUIController.cs
index fb14224..e67c50d 100644
--- a/Main/System/Battle/UIComp/BattleFloatingUIController.cs
+++ b/Main/System/Battle/UIComp/BattleFloatingUIController.cs
@@ -2,117 +2,297 @@
using System;
/// <summary>
-/// 鎴樻枟椋樺瓧UI鎺у埗鍣�:澶勭悊缂╂斁銆侀�忔槑搴︺�佷綅缃姩鐢婚�昏緫
+/// 鎴樻枟椋樺瓧UI鎺у埗鍣�
+/// 鑱岃矗锛氬鐞嗛瀛楃殑缂╂斁銆侀�忔槑搴︺�佷綅缃姩鐢婚�昏緫
/// </summary>
-[SerializeField]
+[Serializable]
public class BattleFloatingUIController
{
- // Position Settings
- public Vector2 beginPos = Vector2.zero;
- public Vector2 endPos = new Vector2(0, 150);
-
- // Time Settings
- public float scaleChangeTime = 1f / BattleConst.skillMotionFps * 16f + 0.1f; // 7~8甯� (8/30=0.2667绉�)
- public float totalShowTime = 1f / BattleConst.skillMotionFps * 48f + 0.1f; // 鎬绘椂闂寸害24甯� (8+16=24甯�)
-
- // Normal Settings
- public Vector3 normalBeginScale = new Vector3(2f, 2f, 2f);
- public Vector3 normalEndScale = new Vector3(1f, 1f, 1f);
-
- // Critical Settings
- public Vector3 critBeginScale = new Vector3(3f, 3f, 3f);
- public Vector3 critEndScale = new Vector3(1.5f, 1.5f, 1.5f);
+ #region 绉佹湁瀛楁
- // Color Settings
- public Color beginColor = new Color(1f, 1f, 1f, 0.5f);
- public Color endColor = new Color(1f, 1f, 1f, 1f);
-
+ private FloatingConfig config;
private RectTransform rectTransform;
+ private GameObject gameObject;
+ private Action<Color> applyColorCallback;
+
+ // 杩愯鏃剁姸鎬�
private float timer = 0f;
private float speedRatio = 1f;
private float scaleRatio = 1f;
private bool isCritical = false;
private Action onFinishCallback;
- private Action<Color> applyColorCallback;
- private GameObject gameObject;
+
+ // 杩愯鏃朵綅缃鐩栵紙浼樺厛绾ч珮浜庨厤缃級
+ private Vector2? runtimeBeginPos = null;
+ private Vector2? runtimeEndPos = null;
+
+ // 杩愯鏃堕鑹茶鐩栵紙浼樺厛绾ч珮浜庨厤缃級
+ private Color? runtimeBeginColor = null;
+ private Color? runtimeEndColor = null;
+
+ #endregion
- // 娣诲姞鍙灞炴�т互瀵瑰鏆撮湶
+ #region 鍏叡灞炴��
+
public float Timer => timer;
public float SpeedRatio => speedRatio;
public float ScaleRatio => scaleRatio;
+
+ #endregion
- public BattleFloatingUIController(RectTransform rect, GameObject go, Action<Color> applyColor)
+ #region 鏋勯�犲嚱鏁�
+
+ public BattleFloatingUIController(
+ RectTransform rect,
+ GameObject go,
+ Action<Color> applyColor,
+ FloatingConfig cfg)
{
rectTransform = rect;
gameObject = go;
applyColorCallback = applyColor;
+ config = cfg;
}
+
+ #endregion
+ #region 閰嶇疆绠$悊
+
+ /// <summary>
+ /// 璁剧疆鎴栨洿鏂伴厤缃�
+ /// </summary>
+ public void SetConfig(FloatingConfig cfg)
+ {
+ config = cfg;
+ }
+
+ /// <summary>
+ /// 璁剧疆杩愯鏃朵綅缃鐩栵紙浼氳鐩栭厤缃腑鐨勪綅缃級
+ /// </summary>
+ public void SetRuntimePosition(Vector2 beginPos, Vector2 endPos)
+ {
+ runtimeBeginPos = beginPos;
+ runtimeEndPos = endPos;
+ }
+
+ /// <summary>
+ /// 娓呴櫎杩愯鏃朵綅缃鐩栵紝鎭㈠浣跨敤閰嶇疆涓殑浣嶇疆
+ /// </summary>
+ public void ClearRuntimePosition()
+ {
+ runtimeBeginPos = null;
+ runtimeEndPos = null;
+ }
+
+ /// <summary>
+ /// 璁剧疆杩愯鏃堕鑹茶鐩栵紙浼氳鐩栭厤缃腑鐨勯鑹诧級
+ /// </summary>
+ public void SetRuntimeColor(Color beginColor, Color endColor)
+ {
+ runtimeBeginColor = beginColor;
+ runtimeEndColor = endColor;
+ }
+
+ /// <summary>
+ /// 娓呴櫎杩愯鏃堕鑹茶鐩栵紝鎭㈠浣跨敤閰嶇疆涓殑棰滆壊
+ /// </summary>
+ public void ClearRuntimeColor()
+ {
+ runtimeBeginColor = null;
+ runtimeEndColor = null;
+ }
+
+ #endregion
+
+ #region 鎾斁鎺у埗
+
+ /// <summary>
+ /// 璁剧疆閫熷害鍜岀缉鏀炬瘮渚�
+ /// </summary>
public void SetRatio(float speed, float scale)
{
speedRatio = speed;
scaleRatio = scale;
}
+ /// <summary>
+ /// 寮�濮嬫挱鏀惧姩鐢�
+ /// </summary>
public void Play(bool isCrit, Action onComplete = null)
{
+ if (!ValidateConfig()) return;
+
isCritical = isCrit;
onFinishCallback = onComplete;
timer = 0f;
- Vector3 beginScale = isCritical ? critBeginScale : normalBeginScale;
+ // 鍒濆鍖栦綅缃拰缂╂斁
+ Vector2 beginPos = GetBeginPosition();
+ Vector3 beginScale = GetBeginScale();
+
rectTransform.anchoredPosition = beginPos;
rectTransform.localScale = beginScale * scaleRatio;
gameObject.SetActive(true);
}
+ /// <summary>
+ /// 姣忓抚鏇存柊
+ /// </summary>
public void Run()
{
- if (!gameObject.activeSelf)
+ if (!gameObject.activeSelf || !ValidateConfig())
return;
- if (timer >= totalShowTime)
+ // 妫�鏌ユ槸鍚﹀畬鎴�
+ if (timer >= config.totalShowTime)
{
- gameObject.SetActive(false);
- onFinishCallback?.Invoke();
- onFinishCallback = null;
+ OnAnimationComplete();
return;
}
- // 鏁翠釜杩囩▼閮藉線涓婇
- float moveProgress = timer / totalShowTime;
- rectTransform.anchoredPosition = Vector2.Lerp(beginPos, endPos, moveProgress);
-
- Vector3 currentBeginScale = isCritical ? critBeginScale : normalBeginScale;
- Vector3 currentEndScale = isCritical ? critEndScale : normalEndScale;
-
- // 闃舵1: 7~8甯у唴缂╂斁鍜岄�忔槑搴﹀彉鍖�
- if (timer < scaleChangeTime)
- {
- float scaleProgress = timer / scaleChangeTime;
- rectTransform.localScale = Vector3.Lerp(currentBeginScale, currentEndScale, scaleProgress) * scaleRatio;
-
- Color currentColor = Color.Lerp(beginColor, endColor, scaleProgress);
- applyColorCallback?.Invoke(currentColor);
- }
- // 闃舵2: 淇濇寔缂╂斁鍜岄�忔槑搴︼紝缁х画寰�涓婇
- else
- {
- rectTransform.localScale = currentEndScale * scaleRatio;
- applyColorCallback?.Invoke(endColor);
- }
-
- timer += 1f / BattleConst.skillMotionFps * speedRatio;
+ // 鏇存柊鍔ㄧ敾
+ UpdatePosition();
+ UpdateScaleAndColor();
+
+ // 澧炲姞璁℃椂鍣�
+ timer += GetDeltaTime();
}
+ /// <summary>
+ /// 鏆傚仠锛堥鐣欐帴鍙o級
+ /// </summary>
public void Stop()
{
// 鍙互娣诲姞鏆傚仠閫昏緫
}
+ /// <summary>
+ /// 鎭㈠锛堥鐣欐帴鍙o級
+ /// </summary>
public void Resume()
{
// 鍙互娣诲姞鎭㈠閫昏緫
}
+
+ #endregion
+
+ #region 绉佹湁鏂规硶
+
+ /// <summary>
+ /// 楠岃瘉閰嶇疆鏈夋晥鎬�
+ /// </summary>
+ private bool ValidateConfig()
+ {
+ if (config == null)
+ {
+ Debug.LogError("[BattleFloatingUIController] FloatingConfig 閰嶇疆涓虹┖");
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// 鑾峰彇璧峰浣嶇疆锛堣繍琛屾椂浣嶇疆浼樺厛锛�
+ /// </summary>
+ private Vector2 GetBeginPosition()
+ {
+ return runtimeBeginPos ?? config.beginPos;
+ }
+
+ /// <summary>
+ /// 鑾峰彇缁撴潫浣嶇疆锛堣繍琛屾椂浣嶇疆浼樺厛锛�
+ /// </summary>
+ private Vector2 GetEndPosition()
+ {
+ return runtimeEndPos ?? config.endPos;
+ }
+
+ /// <summary>
+ /// 鑾峰彇璧峰缂╂斁
+ /// </summary>
+ private Vector3 GetBeginScale()
+ {
+ return isCritical ? config.critBeginScale : config.normalBeginScale;
+ }
+
+ /// <summary>
+ /// 鑾峰彇缁撴潫缂╂斁
+ /// </summary>
+ private Vector3 GetEndScale()
+ {
+ return isCritical ? config.critEndScale : config.normalEndScale;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鏃堕棿澧為噺
+ /// </summary>
+ private float GetDeltaTime()
+ {
+ return 1f / BattleConst.skillMotionFps * speedRatio;
+ }
+
+ /// <summary>
+ /// 鏇存柊浣嶇疆
+ /// </summary>
+ private void UpdatePosition()
+ {
+ float moveProgress = timer / config.totalShowTime;
+ Vector2 currentPos = Vector2.Lerp(GetBeginPosition(), GetEndPosition(), moveProgress);
+ rectTransform.anchoredPosition = currentPos;
+ }
+
+ /// <summary>
+ /// 鑾峰彇璧峰棰滆壊锛堣繍琛屾椂棰滆壊浼樺厛锛�
+ /// </summary>
+ private Color GetBeginColor()
+ {
+ return runtimeBeginColor ?? config.beginColor;
+ }
+
+ /// <summary>
+ /// 鑾峰彇缁撴潫棰滆壊锛堣繍琛屾椂棰滆壊浼樺厛锛�
+ /// </summary>
+ private Color GetEndColor()
+ {
+ return runtimeEndColor ?? config.endColor;
+ }
+
+ /// <summary>
+ /// 鏇存柊缂╂斁鍜岄鑹�
+ /// </summary>
+ private void UpdateScaleAndColor()
+ {
+ // 闃舵1: 缂╂斁鍜岄�忔槑搴﹀彉鍖�
+ if (timer < config.scaleChangeTime)
+ {
+ float progress = timer / config.scaleChangeTime;
+
+ // 缂╂斁鎻掑��
+ Vector3 currentScale = Vector3.Lerp(GetBeginScale(), GetEndScale(), progress);
+ rectTransform.localScale = currentScale * scaleRatio;
+
+ // 棰滆壊鎻掑�硷紙浣跨敤杩愯鏃堕鑹叉垨閰嶇疆棰滆壊锛�
+ Color currentColor = Color.Lerp(GetBeginColor(), GetEndColor(), progress);
+ applyColorCallback?.Invoke(currentColor);
+ }
+ // 闃舵2: 淇濇寔鏈�缁堢缉鏀惧拰閫忔槑搴�
+ else
+ {
+ rectTransform.localScale = GetEndScale() * scaleRatio;
+ applyColorCallback?.Invoke(GetEndColor());
+ }
+ }
+
+ /// <summary>
+ /// 鍔ㄧ敾瀹屾垚鍥炶皟
+ /// </summary>
+ private void OnAnimationComplete()
+ {
+ gameObject.SetActive(false);
+ onFinishCallback?.Invoke();
+ onFinishCallback = null;
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
index 1ba959c..859cb6b 100644
--- a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
+++ b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
@@ -4,49 +4,78 @@
using System;
using DG.Tweening;
-
+/// <summary>
+/// 鎴樻枟瑙掕壊淇℃伅鏍�
+/// 鑱岃矗锛氭樉绀鸿鑹茶鏉°�佹�掓皵銆丅uff鍜岄瀛楁彁绀�
+/// </summary>
public class BattleHeroInfoBar : MonoBehaviour
{
+ #region 鍐呴儴绫�
+
+ /// <summary>
+ /// 椋樺瓧淇℃伅閰嶇疆
+ /// </summary>
public class TipsInfo
{
public string message;
public bool useArtText;
public bool followCharacter;
public float scaleRatio;
-
- public Color textColor = Color.white;
-
public bool showBackground = false;
+ public bool useBuffColor = false; // 鏄惁浣跨敤 Buff 棰滆壊锛堜粠 FloatingConfig 璇诲彇锛�
+ public bool isDebuff = false; // 鏄惁鏄礋鍚� Buff锛堝喅瀹氱敤鍝釜棰滆壊锛�
}
+
+ #endregion
- protected BattleObject battleObject;
-
+ #region Inspector瀛楁
+
+ [Header("UI Components")]
public Slider sliderHp;
-
- public Slider sliderXp; //鎬掓皵
-
- protected float timer = 0f;
-
- public float PopUpInterval = 0.2f;
-
-
- [SerializeField] public List<BattleBuffCell> buffCells = new List<BattleBuffCell>();
-
- protected List<TipsInfo> messages = new List<TipsInfo>();
-
+ public Slider sliderXp;
public BasicHeroInfoContainer heroInfoContainer;
-
public BattleTips textTips;
+
+ [Header("Buff Components")]
+ [SerializeField]
+ public List<BattleBuffCell> buffCells = new List<BattleBuffCell>();
- protected Tween hpTween;
+ [Header("Floating Configs")]
+ [Tooltip("璺熼殢瑙掕壊鐨勯瀛楅厤缃�")]
+ public FloatingConfig followFloatingConfig;
+ [Tooltip("涓嶈窡闅忚鑹茬殑椋樺瓧閰嶇疆锛堝浐瀹氬湪鎴樺満鑺傜偣锛�")]
+ public FloatingConfig noFollowFloatingConfig;
+
+ [Header("Settings")]
+ public float PopUpInterval = 0.2f;
+
+ #endregion
- protected Tween xpTween;
-
+ #region 绉佹湁瀛楁
+
+ protected BattleObject battleObject;
+ protected float timer = 0f;
+
+ protected List<TipsInfo> messages = new List<TipsInfo>();
protected List<BattleTips> tipsList = new List<BattleTips>();
-
protected List<HB428_tagSCBuffRefresh> buffList = new List<HB428_tagSCBuffRefresh>();
+
+ protected Tween hpTween;
+ protected Tween xpTween;
+
+ #endregion
+ #region Unity鐢熷懡鍛ㄦ湡
+
+ protected void OnDisable()
+ {
+ CleanupTips();
+ }
+
+ #endregion
+ #region 鍏叡鏂规硶 - 鍒濆鍖�
+
public void SetBattleObject(BattleObject _battleObject)
{
battleObject = _battleObject;
@@ -55,23 +84,27 @@
UpdateHP(battleObject.teamHero.curHp, battleObject.teamHero.curHp, battleObject.teamHero.maxHp, false);
UpdateXP(battleObject.teamHero.rage, battleObject.teamHero.rage, 100, false);
}
+
+ public void SetActive(bool active)
+ {
+ gameObject.SetActive(active);
+ }
+
+ #endregion
+ #region 鍏叡鏂规硶 - Buff绠$悊
+
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
- });
+ buffCells[i].Init(datas[i], OnBuffCellClicked);
}
else
{
@@ -79,19 +112,14 @@
}
}
}
+
+ #endregion
- protected void OnDisable()
- {
- // TODO YYL 鑰冭檻姹犲寲
- messages.Clear();
- for (int i = 0; i < tipsList.Count; i++)
- {
- var tip = tipsList[i];
- tip.OnFinish = null;
- GameObject.DestroyImmediate(tip.gameObject);
- }
- tipsList.Clear();
- }
+ #region 鍏叡鏂规硶 - 椋樺瓧绠$悊
+
+ /// <summary>
+ /// 娣诲姞椋樺瓧鍒伴槦鍒�
+ /// </summary>
public void ShowTips(string message, bool useArtText = false, bool followCharacter = true, float scaleRatio = 1f)
{
messages.Add(new TipsInfo
@@ -103,134 +131,266 @@
});
}
+ /// <summary>
+ /// 娣诲姞鑷畾涔夐瀛楅厤缃埌闃熷垪
+ /// </summary>
public void ShowTips(TipsInfo tipsInfo)
{
messages.Add(tipsInfo);
}
+
+ #endregion
- public void SetActive(bool active)
+ #region 鍏叡鏂规硶 - 鏁板�兼洿鏂�
+
+ /// <summary>
+ /// 鏇存柊琛�閲忔樉绀�
+ /// </summary>
+ public void UpdateHP(long fromHp, long toHp, long maxHp, bool tween = true)
{
- gameObject.SetActive(active);
- }
-
- public void PopUpTipsDirectly(TipsInfo tipsInfo)
- {
- GameObject prefab = textTips.gameObject;
-
- GameObject go = GameObject.Instantiate(prefab, tipsInfo.followCharacter ? transform : battleObject.battleField.battleRootNode.transform);
-
- BattleTips tips = go.GetComponent<BattleTips>();
-
- if (!tipsInfo.followCharacter)
- {
- var contentRect = go.GetComponent<RectTransform>();
- var contentParentRect = contentRect.parent as RectTransform;
- var infoBarRect = GetComponent<RectTransform>();
-
- Vector3 worldTargetPos = infoBarRect.transform.TransformPoint(infoBarRect.rect.center);
-
- Vector2 anchoredPos;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(
- contentParentRect,
- RectTransformUtility.WorldToScreenPoint(null, worldTargetPos),
- null,
- out anchoredPos);
-
- tips.UpdatePositions(anchoredPos, anchoredPos + new Vector2(0, 150));
-
- // 鍚屾椂鏇存柊缂╂斁
- Vector3 newBeginScale = tips.normalBeginScale * tipsInfo.scaleRatio;
- Vector3 newEndScale = tips.normalEndScale * tipsInfo.scaleRatio;
- tips.UpdateScales(newBeginScale, newEndScale);
- }
-
- tips.SetRatio(battleObject.battleField.speedRatio, 1f);
-
- tips.SetText(tipsInfo.message, tipsInfo.useArtText, false, tipsInfo.textColor);
-
- tips.ShowBackground(tipsInfo.showBackground);
-
- tips.OnFinish = () =>
- {
- tipsList.Remove(tips);
- GameObject.DestroyImmediate(tips.gameObject);
- };
-
- tipsList.Add(tips);
- }
-
-
- public void UpdateHP(long fromHp, long toHp, long maxHp, bool tween = true)
- {
- // 鍋歨p澧炲姞鎴栬�呭噺灏戠殑鍔ㄧ敾
- // sliderHp.value = ((float)fromHp) / ((float)maxHp);
- if (hpTween != null)
- {
- battleObject.battleField.battleTweenMgr.OnKillTween(hpTween);
- }
-
+ KillTween(ref hpTween);
+
+ float targetValue = (float)toHp / (float)maxHp;
+
if (tween)
{
- hpTween = sliderHp.DOValue((float)toHp / (float)maxHp, 0.3f);
+ hpTween = sliderHp.DOValue(targetValue, 0.3f);
battleObject.battleField.battleTweenMgr.OnPlayTween(hpTween);
}
else
{
- sliderHp.value = ((float)toHp) / ((float)maxHp);
+ sliderHp.value = targetValue;
}
-
- // BattleDebug.LogError("update hp from " + fromHp + " to " + toHp + " maxHp " + maxHp);
}
+ /// <summary>
+ /// 鏇存柊鎬掓皵鏄剧ず
+ /// </summary>
public void UpdateXP(long fromXp, long toXp, long maxXp, bool tween = true)
{
- // 鍋歑p澧炲姞鎴栬�呭噺灏戠殑鍔ㄧ敾
- // sliderXp.value = ((float)fromXp) / ((float)maxXp);
- if (xpTween != null)
- {
- battleObject.battleField.battleTweenMgr.OnKillTween(xpTween);
- }
-
+ KillTween(ref xpTween);
+
+ float targetValue = (float)toXp / (float)maxXp;
+
if (tween)
{
- xpTween = sliderXp.DOValue((float)toXp / (float)maxXp, 0.2f);
+ xpTween = sliderXp.DOValue(targetValue, 0.2f);
battleObject.battleField.battleTweenMgr.OnPlayTween(xpTween);
}
else
{
- sliderXp.value = ((float)toXp) / ((float)maxXp);
+ sliderXp.value = targetValue;
}
-
- // BattleDebug.LogError("update xp from " + fromXp + " to " + toXp + " maxXp " + maxXp);
}
+
+ #endregion
+ #region 鍏叡鏂规硶 - 杩愯鏃舵洿鏂�
+
+ /// <summary>
+ /// 姣忓抚鏇存柊
+ /// </summary>
public void Run()
{
- // 鍊掑簭閬嶅巻 鍒犻櫎.run閲屽垹闄ゅ厓绱犱笉鍙楀奖鍝�
+ // 鏇存柊鎵�鏈夐瀛�
+ UpdateActiveTips();
+
+ // 澶勭悊椋樺瓧闃熷垪
+ ProcessTipsQueue();
+ }
+
+ /// <summary>
+ /// 璁剧疆閫熷害姣斾緥
+ /// </summary>
+ public void SetSpeedRatio(float ratio)
+ {
+ foreach (var tip in tipsList)
+ {
+ tip.SetRatio(ratio, 1f);
+ }
+ }
+
+ #endregion
+
+ #region 绉佹湁鏂规硶 - 椋樺瓧澶勭悊
+
+ /// <summary>
+ /// 绔嬪嵆寮瑰嚭椋樺瓧
+ /// </summary>
+ private void PopUpTipsDirectly(TipsInfo tipsInfo)
+ {
+ // 鍒涘缓椋樺瓧瀹炰緥
+ BattleTips tips = CreateTipsInstance(tipsInfo);
+
+ // 閰嶇疆椋樺瓧
+ ConfigureTips(tips, tipsInfo);
+
+ // 璁剧疆浣嶇疆锛堝鏋滀笉璺熼殢锛�
+ if (!tipsInfo.followCharacter)
+ {
+ SetNonFollowPosition(tips);
+ }
+
+ // 璁剧疆鍙傛暟骞舵樉绀�
+ tips.SetRatio(battleObject.battleField.speedRatio, tipsInfo.scaleRatio);
+ tips.SetText(tipsInfo.message, tipsInfo.useArtText, false); // 绉婚櫎 textColor 鍙傛暟
+ tips.ShowBackground(tipsInfo.showBackground);
+
+ // 娉ㄥ唽瀹屾垚鍥炶皟
+ tips.OnFinish = () => RemoveTips(tips);
+
+ // 娣诲姞鍒板垪琛�
+ tipsList.Add(tips);
+ }
+
+ /// <summary>
+ /// 鍒涘缓椋樺瓧瀹炰緥
+ /// </summary>
+ private BattleTips CreateTipsInstance(TipsInfo tipsInfo)
+ {
+ Transform parent = tipsInfo.followCharacter
+ ? transform
+ : battleObject.battleField.battleRootNode.transform;
+
+ GameObject go = GameObject.Instantiate(textTips.gameObject, parent);
+ return go.GetComponent<BattleTips>();
+ }
+
+ /// <summary>
+ /// 閰嶇疆椋樺瓧
+ /// </summary>
+ private void ConfigureTips(BattleTips tips, TipsInfo tipsInfo)
+ {
+ FloatingConfig targetConfig = tipsInfo.followCharacter
+ ? followFloatingConfig
+ : noFollowFloatingConfig;
+
+ if (targetConfig == null)
+ {
+ Debug.LogError($"[BattleHeroInfoBar] FloatingConfig 鏈厤缃�! " +
+ $"followCharacter={tipsInfo.followCharacter}, GameObject: {gameObject.name}");
+ return;
+ }
+
+ tips.SetFloatingConfig(targetConfig);
+
+ // 璁剧疆鏄惁浣跨敤 Buff 棰滆壊
+ if (tipsInfo.useBuffColor)
+ {
+ tips.SetBuffColor(true, tipsInfo.isDebuff);
+ }
+ }
+
+ /// <summary>
+ /// 璁剧疆涓嶈窡闅忛瀛楃殑浣嶇疆
+ /// </summary>
+ private void SetNonFollowPosition(BattleTips tips)
+ {
+ RectTransform contentRect = tips.GetComponent<RectTransform>();
+ RectTransform contentParentRect = contentRect.parent as RectTransform;
+ RectTransform infoBarRect = GetComponent<RectTransform>();
+
+ // 璁$畻涓栫晫鍧愭爣
+ Vector3 worldTargetPos = infoBarRect.transform.TransformPoint(infoBarRect.rect.center);
+
+ // 杞崲鍒扮埗鑺傜偣鍧愭爣
+ Vector2 anchoredPos;
+ RectTransformUtility.ScreenPointToLocalPointInRectangle(
+ contentParentRect,
+ RectTransformUtility.WorldToScreenPoint(null, worldTargetPos),
+ null,
+ out anchoredPos
+ );
+
+ // 璁剧疆鍔ㄦ�佷綅缃�
+ tips.SetPosition(anchoredPos, anchoredPos + new Vector2(0, 150));
+ }
+
+ /// <summary>
+ /// 绉婚櫎椋樺瓧
+ /// </summary>
+ private void RemoveTips(BattleTips tips)
+ {
+ tipsList.Remove(tips);
+ GameObject.DestroyImmediate(tips.gameObject);
+ }
+
+ /// <summary>
+ /// 鏇存柊鎵�鏈夋縺娲荤殑椋樺瓧
+ /// </summary>
+ private void UpdateActiveTips()
+ {
for (int i = tipsList.Count - 1; i >= 0; i--)
{
tipsList[i].Run();
}
-
- timer += 1f / (float)BattleConst.skillMotionFps * battleObject.battleField.speedRatio;
+ }
+
+ /// <summary>
+ /// 澶勭悊椋樺瓧闃熷垪
+ /// </summary>
+ private void ProcessTipsQueue()
+ {
+ timer += GetDeltaTime();
if (messages.Count > 0 && timer >= PopUpInterval)
{
- // 鎾斁椋樺瓧
TipsInfo tipsInfo = messages[0];
messages.RemoveAt(0);
-
+
PopUpTipsDirectly(tipsInfo);
-
+
timer = 0f;
}
}
-
- public void SetSpeedRatio(float ratio)
+
+ /// <summary>
+ /// 娓呯悊鎵�鏈夐瀛�
+ /// </summary>
+ private void CleanupTips()
{
- for (int i = 0; i < tipsList.Count; i++)
+ messages.Clear();
+
+ foreach (var tip in tipsList)
{
- tipsList[i].SetRatio(ratio, 1f);
+ tip.OnFinish = null;
+ GameObject.DestroyImmediate(tip.gameObject);
+ }
+
+ tipsList.Clear();
+ }
+
+ #endregion
+
+ #region 绉佹湁鏂规硶 - 杈呭姪鏂规硶
+
+ /// <summary>
+ /// 鍋滄骞舵竻鐞員ween
+ /// </summary>
+ private void KillTween(ref Tween tween)
+ {
+ if (tween != null && battleObject != null)
+ {
+ battleObject.battleField.battleTweenMgr.OnKillTween(tween);
+ tween = null;
}
}
+
+ /// <summary>
+ /// 鑾峰彇鏃堕棿澧為噺
+ /// </summary>
+ private float GetDeltaTime()
+ {
+ return 1f / (float)BattleConst.skillMotionFps * battleObject.battleField.speedRatio;
+ }
+
+ /// <summary>
+ /// Buff鍥炬爣鐐瑰嚮鍥炶皟
+ /// </summary>
+ private void OnBuffCellClicked()
+ {
+ // TODO: 鏄剧ずbuff鎻忚堪/褰撳墠韬笂鎵�鏈塨uff
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/Main/System/Battle/UIComp/BattleTips.cs b/Main/System/Battle/UIComp/BattleTips.cs
index bda5b8b..ca50cd7 100644
--- a/Main/System/Battle/UIComp/BattleTips.cs
+++ b/Main/System/Battle/UIComp/BattleTips.cs
@@ -2,79 +2,135 @@
using System;
using UnityEngine.UI;
+/// <summary>
+/// 鎴樻枟椋樺瓧UI缁勪欢
+/// 鑱岃矗锛氱鐞哢I鍏冪礌鍜屼笌鎺у埗鍣ㄧ殑浜や簰
+/// </summary>
public class BattleTips : MonoBehaviour, IBattleFloatingUI
{
- public Vector2 beginPos = Vector2.zero;
- public Vector2 endPos = new Vector2(0, 150);
-
+ #region Inspector瀛楁
+
+ [Header("UI Components")]
public RectTransform rectTransform;
public Text tipText;
public Text artText;
-
public Image background;
- public Vector3 normalBeginScale = new Vector3(2f, 2f, 2f);
- public Vector3 normalEndScale = new Vector3(1f, 1f, 1f);
+ [Header("Floating Config")]
+ [Tooltip("椋樺瓧鍔ㄧ敾閰嶇疆锛岃鍦↖nspector涓嫋鎷借祴鍊�")]
+ public FloatingConfig floatingConfig;
+
+ #endregion
- public Action OnFinish; // 淇濈暀 OnFinish
+ #region 鍏叡瀛楁
+
+ public Action OnFinish;
+
+ // Buff 棰滆壊鐩稿叧
+ private bool useBuffColor = false;
+ private bool isDebuff = false;
+
+ #endregion
- [SerializeField]
+ #region 绉佹湁瀛楁
+
+ // 绉婚櫎 [SerializeField]锛宑ontroller 涓嶅簲璇ヨ搴忓垪鍖�
private BattleFloatingUIController controller;
+
+ #endregion
- void Awake()
- {
- InitController();
- }
- private void InitController()
- {
- if (controller != null) return;
-
- controller = new BattleFloatingUIController(rectTransform, gameObject, ApplyColor);
- controller.beginPos = beginPos;
- controller.endPos = endPos;
- controller.normalBeginScale = normalBeginScale;
- controller.normalEndScale = normalEndScale;
- }
-
+ #region 鍏叡鏂规硶
+
+ /// <summary>
+ /// 璁剧疆閫熷害鍜岀缉鏀炬瘮渚�
+ /// </summary>
public void SetRatio(float speed, float scale)
{
- InitController(); // 纭繚 controller 宸插垵濮嬪寲
- controller.SetRatio(speed, scale);
+ EnsureControllerInitialized();
+ controller?.SetRatio(speed, scale);
}
- public void SetText(string text, bool useArtText = false, bool isCrit = false, Color textColor = default)
+ /// <summary>
+ /// 璁剧疆杩愯鏃朵綅缃紙鐢ㄤ簬涓嶈窡闅忚鑹茬殑椋樺瓧锛�
+ /// </summary>
+ public void SetPosition(Vector2 beginPos, Vector2 endPos)
{
- if (textColor == default)
+ EnsureControllerInitialized();
+ controller?.SetRuntimePosition(beginPos, endPos);
+ }
+
+ /// <summary>
+ /// 杩愯鏃舵洿鏂伴厤缃�
+ /// </summary>
+ public void SetFloatingConfig(FloatingConfig config)
+ {
+ floatingConfig = config;
+
+ if (controller != null)
{
- textColor = Color.white;
- }
-
- InitController();
- if (useArtText)
- {
- artText.text = text;
- tipText.gameObject.SetActive(false);
- artText.gameObject.SetActive(true);
+ controller.SetConfig(config);
}
else
{
- tipText.text = text;
- artText.gameObject.SetActive(false);
- tipText.gameObject.SetActive(true);
+ InitController();
}
+ }
- controller.beginColor = new Color(textColor.r, textColor.g, textColor.b, controller.beginColor.a);
- controller.endColor = new Color(textColor.r, textColor.g, textColor.b, controller.endColor.a);
- ApplyColor(controller.beginColor);
+ /// <summary>
+ /// 璁剧疆鏄惁浣跨敤 Buff 棰滆壊
+ /// </summary>
+ public void SetBuffColor(bool useBuff, bool isDebuffBuff)
+ {
+ useBuffColor = useBuff;
+ isDebuff = isDebuffBuff;
+
+ // 濡傛灉浣跨敤 buff 棰滆壊锛岀珛鍗宠缃繍琛屾椂棰滆壊瑕嗙洊
+ if (useBuffColor && floatingConfig != null)
+ {
+ Color buffColor = isDebuff ? floatingConfig.debuffColor : floatingConfig.gainBuffColor;
+ Color beginColor = new Color(buffColor.r, buffColor.g, buffColor.b, floatingConfig.beginColor.a);
+ Color endColor = new Color(buffColor.r, buffColor.g, buffColor.b, floatingConfig.endColor.a);
+
+ EnsureControllerInitialized();
+ controller?.SetRuntimeColor(beginColor, endColor);
+ }
+ }
+
+ /// <summary>
+ /// 璁剧疆鏂囨湰鍐呭鍜屾牱寮�
+ /// </summary>
+ public void SetText(string text, bool useArtText = false, bool isCrit = false)
+ {
+ EnsureControllerInitialized();
+
+ // 鍒囨崲鏂囨湰鏄剧ず绫诲瀷
+ SwitchTextDisplay(useArtText, text);
+
+ // 寮�濮嬫挱鏀�
Play(isCrit);
}
+ /// <summary>
+ /// 鏄剧ず/闅愯棌鑳屾櫙
+ /// </summary>
+ public void ShowBackground(bool show)
+ {
+ if (background != null)
+ background.enabled = show;
+ }
+
+ #endregion
+
+ #region IBattleFloatingUI鎺ュ彛瀹炵幇
+
public void Play(bool isCrit, Action onComplete = null)
{
- InitController(); // 纭繚 controller 宸插垵濮嬪寲
+ EnsureControllerInitialized();
- // 鍚堝苟 OnFinish 鍜� onComplete
+ if (controller == null) return;
+
+ // 鍚堝苟鍥炶皟
Action combinedCallback = () =>
{
OnFinish?.Invoke();
@@ -87,51 +143,100 @@
public void Run()
{
- if (controller == null) return; // 闃叉鍦� Awake 鍓嶈皟鐢�
- controller.Run();
+ controller?.Run();
}
public void Stop()
{
- if (controller == null) return;
- controller.Stop();
+ controller?.Stop();
}
public void Resume()
{
- if (controller == null) return;
- controller.Resume();
+ controller?.Resume();
}
+
+ #endregion
+ #region 绉佹湁鏂规硶
+
+ /// <summary>
+ /// 鍒濆鍖栨帶鍒跺櫒
+ /// </summary>
+ private void InitController()
+ {
+ if (controller != null) return;
+
+ if (floatingConfig == null)
+ {
+ Debug.LogError($"[BattleTips] FloatingConfig 鏈厤缃�! GameObject: {gameObject.name}");
+ return;
+ }
+
+ controller = new BattleFloatingUIController(
+ rectTransform,
+ gameObject,
+ ApplyColor,
+ floatingConfig
+ );
+ }
+
+ /// <summary>
+ /// 纭繚鎺у埗鍣ㄥ凡鍒濆鍖�
+ /// </summary>
+ private void EnsureControllerInitialized()
+ {
+ if (controller == null)
+ InitController();
+ }
+
+ /// <summary>
+ /// 鍒囨崲鏂囨湰鏄剧ず绫诲瀷
+ /// </summary>
+ private void SwitchTextDisplay(bool useArtText, string text)
+ {
+ if (useArtText)
+ {
+ artText.text = text;
+ tipText.gameObject.SetActive(false);
+ artText.gameObject.SetActive(true);
+ }
+ else
+ {
+ tipText.text = text;
+ artText.gameObject.SetActive(false);
+ tipText.gameObject.SetActive(true);
+ }
+ }
+
+ /// <summary>
+ /// 搴旂敤鏂囨湰棰滆壊锛堜繚鐣欓厤缃殑閫忔槑搴︼級
+ /// </summary>
+ private void ApplyTextColor(Color textColor)
+ {
+ if (floatingConfig != null)
+ {
+ Color colorWithAlpha = new Color(
+ textColor.r,
+ textColor.g,
+ textColor.b,
+ floatingConfig.beginColor.a
+ );
+ ApplyColor(colorWithAlpha);
+ }
+ }
+
+ /// <summary>
+ /// 搴旂敤棰滆壊鍒版縺娲荤殑鏂囨湰缁勪欢
+ /// </summary>
private void ApplyColor(Color color)
{
if (tipText.gameObject.activeSelf)
tipText.color = color;
+
if (artText.gameObject.activeSelf)
artText.color = color;
}
-
- public void ShowBackground(bool showBackground)
- {
- // Implement the logic to show or hide the background
- background.enabled = showBackground;
- }
-
- public void UpdatePositions(Vector2 begin, Vector2 end)
- {
- InitController();
- beginPos = begin;
- endPos = end;
- controller.beginPos = begin;
- controller.endPos = end;
- }
-
- public void UpdateScales(Vector3 beginScale, Vector3 endScale)
- {
- InitController();
- normalBeginScale = beginScale;
- normalEndScale = endScale;
- controller.normalBeginScale = beginScale;
- controller.normalEndScale = endScale;
- }
+
+ #endregion
}
\ No newline at end of file
diff --git a/Main/System/Battle/UIComp/DamageContent.cs b/Main/System/Battle/UIComp/DamageContent.cs
index a87ed73..407d864 100644
--- a/Main/System/Battle/UIComp/DamageContent.cs
+++ b/Main/System/Battle/UIComp/DamageContent.cs
@@ -9,15 +9,13 @@
public GameObject line;
public RectTransform parent;
- public Vector2 beginPos = Vector2.zero;
- public Vector2 endPos = new Vector2(0, 150);
+ [Header("Floating Config")]
+ [Tooltip("璇峰湪Inspector涓嫋鎷紽loatingConfig璧勬簮")]
+ public FloatingConfig floatingConfig;
protected List<DamageLine> damageLineList = new List<DamageLine>();
private BattleDmgInfo battleDmgInfo;
private BattleFloatingUIController controller;
-
- // 椋樿浼樺寲锛氬垵濮嬫斁澶�200%锛岄�忔槑搴�50%锛�7~8甯у唴缂╂斁鍥�100%锛岄�忔槑搴﹀洖鍒�100%锛屽啀寰�涓婇14~16甯с��30甯�/绉掋�戯紝鏆村嚮鍒濆鏀惧ぇ300%锛岀缉鍥�150%
- // 鎴樻枟甯attleConst.skillMotionFps 1绉�=30甯�
void Awake()
{
@@ -28,26 +26,29 @@
{
if (controller != null) return;
+ if (floatingConfig == null)
+ {
+ Debug.LogError($"[DamageContent] FloatingConfig 鏈厤缃紝璇峰湪Inspector涓嫋鎷借祴鍊�! GameObject: {gameObject.name}");
+ return;
+ }
+
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;
+ controller = new BattleFloatingUIController(rectTransform, gameObject, ApplyColor, floatingConfig);
}
public void SetRatio(float speed, float scale)
{
InitController();
- controller.SetRatio(speed, scale);
+ controller?.SetRatio(speed, scale);
+ }
+
+ /// <summary>
+ /// 璁剧疆椋樺瓧鐨勮捣鐐瑰拰缁堢偣浣嶇疆锛堣繍琛屾椂鍔ㄦ�佽缃級
+ /// </summary>
+ public void SetPosition(Vector2 beginPos, Vector2 endPos)
+ {
+ InitController();
+ controller?.SetRuntimePosition(beginPos, endPos);
}
public async void SetDamage(BattleDmgInfo _damageInfo, Action _onComplete)
@@ -81,10 +82,7 @@
public void Play(bool isCrit, Action onComplete = null)
{
InitController();
- // 姣忔Play鍓嶆洿鏂癱ontroller鐨勪綅缃缃�
- controller.beginPos = beginPos;
- controller.endPos = endPos;
- controller.Play(isCrit, onComplete);
+ controller?.Play(isCrit, onComplete);
}
public void Run()
@@ -115,4 +113,14 @@
}
}
}
+
+ // 杩愯鏃舵洿鏂伴厤缃�
+ public void SetFloatingConfig(FloatingConfig config)
+ {
+ floatingConfig = config;
+ if (controller != null)
+ {
+ controller.SetConfig(config);
+ }
+ }
}
--
Gitblit v1.8.0