From cec8b67d82c2c2c1662d55c818c4a46bcc0487db Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 25 八月 2025 17:36:02 +0800
Subject: [PATCH] 125 【战斗】战斗系统 战斗技能

---
 Main/System/Battle/BattleUtility.cs |  100 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
index a16cf6e..4a2c228 100644
--- a/Main/System/Battle/BattleUtility.cs
+++ b/Main/System/Battle/BattleUtility.cs
@@ -10,28 +10,110 @@
 {
     // 鍏朵粬閫氱敤鐨勬垬鏂楀伐鍏锋柟娉曞彲浠ユ斁鍦ㄨ繖閲�
 
-    public static TweenerCore<Vector2, Vector2, DG.Tweening.Plugins.Options.VectorOptions> MoveToTarget(RectTransform transform, RectTransform target, Vector2 offset, float duration, Action onComplete = null)
+
+    public static void MarkStartAndEnd(RectTransform startNode, RectTransform endNode)
     {
-        // 1. 鑾峰彇鐩爣鐨勬渶缁� anchoredPosition锛堝姞涓� offset锛�
-        Vector2 targetAnchoredPos = target.anchoredPosition + offset;
-        Vector3 worldAnchorPos = target.TransformPoint(targetAnchoredPos);
+        // 杩愯鏃舵墠鎵ц
+        if (!Application.isPlaying)
+        {
+            Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+            return;
+        }
+
+        var battleField = BattleManager.Instance.storyBattleField;
+        if (battleField == null)
+        {
+            BattleDebug.LogError("BattleManager.storyBattleField 鏈垵濮嬪寲锛�");
+            return;
+        }
 
 
-        // 杞崲 target 鐨� anchoredPosition 鍒� sourceParent 鐨勫潗鏍囩郴
+        BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>();
+
+        RectTransform canvasRect = battleWin.transform as RectTransform;
+
+        CreateMarker(canvasRect, startNode, "StartMarker");
+        CreateMarker(canvasRect, endNode, "EndMarker");
+    }
+
+    private static void CreateMarker(RectTransform canvasRect, RectTransform targetNode, string markerName)
+    {
+        // 鑾峰彇鐩爣鑺傜偣鐨勪笘鐣屽潗鏍囷紙涓績鐐癸級
+        Vector3 worldPos = targetNode.TransformPoint(targetNode.rect.center);
+
+        // 杞崲鍒癈anvas鏈湴鍧愭爣
         Vector2 localPoint;
         RectTransformUtility.ScreenPointToLocalPointInRectangle(
-            transform,
-            RectTransformUtility.WorldToScreenPoint(CameraManager.uiCamera, worldAnchorPos),
-            CameraManager.uiCamera,
+            canvasRect,
+            RectTransformUtility.WorldToScreenPoint(null, worldPos),
+            null,
             out localPoint);
 
-        // 3. DOTween 绉诲姩
+        // 鍒涘缓RawImage
+        GameObject marker = new GameObject(markerName, typeof(RawImage));
+        GameObject.Destroy(marker, 5f);
+        marker.transform.SetParent(canvasRect, false);
+        var rawImage = marker.GetComponent<RawImage>();
+        rawImage.color = Color.white;
+        rawImage.rectTransform.sizeDelta = new Vector2(100, 100);
+        rawImage.rectTransform.anchoredPosition = localPoint;
+    }
+
+
+    public static TweenerCore<Vector2, Vector2, DG.Tweening.Plugins.Options.VectorOptions> MoveToTarget(
+        RectTransform transform, RectTransform target, Vector2 offset, float duration, Action onComplete = null)
+    {
+
+        // 鑾峰彇鐩爣鑺傜偣鐨勪笘鐣屽潗鏍囷紙涓績鐐癸級
+        Vector3 worldPos = target.TransformPoint(target.rect.center + offset);
+
+        RectTransform canvasRect = transform.parent as RectTransform;
+
+        // 杞崲鍒癈anvas鏈湴鍧愭爣
+        Vector2 localPoint;
+        RectTransformUtility.ScreenPointToLocalPointInRectangle(
+            canvasRect,
+            RectTransformUtility.WorldToScreenPoint(null, worldPos),
+            null,
+            out localPoint);
+
+        // 鍒涘缓RawImage
+
         var tween = transform.DOAnchorPos(localPoint, duration).SetEase(Ease.Linear);
         tween.onComplete += () =>
         {
             onComplete?.Invoke();
         };
 
+        // MarkStartAndEnd(transform as RectTransform, target);
+
+
+        // // 1. 鑾峰彇鐩爣鐨勪笘鐣屽潗鏍囷紙鍔� offset锛�
+        // Vector3 targetWorldPos = target.TransformPoint(target.anchoredPosition + offset);
+
+        // // 2. 鑾峰彇婧愯妭鐐圭殑 parent
+        // RectTransform sourceParent = transform.parent as RectTransform;
+        // if (sourceParent == null)
+        // {
+        //     BattleDebug.LogError("婧愯妭鐐规病鏈夌埗鑺傜偣锛屾棤娉曡浆鎹㈠潗鏍囷紒");
+        //     return null;
+        // }
+
+        // // 3. 鎶婄洰鏍囦笘鐣屽潗鏍囪浆鎹㈠埌婧� parent 鐨勬湰鍦板潗鏍�
+        // Vector2 targetAnchoredPos;
+        // RectTransformUtility.ScreenPointToLocalPointInRectangle(
+        //     sourceParent,
+        //     RectTransformUtility.WorldToScreenPoint(CameraManager.uiCamera, targetWorldPos),
+        //     CameraManager.uiCamera,
+        //     out targetAnchoredPos);
+
+        // // 4. DOTween 绉诲姩
+        // var tween = transform.DOAnchorPos(targetAnchoredPos, duration).SetEase(Ease.Linear);
+        // tween.onComplete += () =>
+        // {
+        //     onComplete?.Invoke();
+        // };
+
         return tween;
     }
 

--
Gitblit v1.8.0