From 214fe94eaf7f09741a7857775dfffe8c3b83c75c Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 25 八月 2025 17:38:30 +0800
Subject: [PATCH] 125 【战斗】战斗系统
---
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta | 11 ++
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs | 73 ++++++++++++++++++
Assets/Launch/Launch.cs | 2
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta | 11 ++
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs | 133 +++++++++++++++++++++++++++++++++
5 files changed, 230 insertions(+), 0 deletions(-)
diff --git a/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs b/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs
new file mode 100644
index 0000000..3865e64
--- /dev/null
+++ b/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs
@@ -0,0 +1,133 @@
+#if UNITY_EDITOR
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class TestActionEditorWindow : EditorWindow
+{
+ protected int targetIndex = 0;
+ protected int selfIndex = 0;
+ protected int distance = 100;
+ protected float duration = 2f;
+
+ [MenuItem("Battle/TestAction鐢熸垚鍣�")]
+ public static void ShowWindow()
+ {
+ GetWindow<TestActionEditorWindow>("TestAction鐢熸垚鍣�");
+ }
+
+ private void OnGUI()
+ {
+ GUILayout.Label("TestAction鍙傛暟璁剧疆", EditorStyles.boldLabel);
+
+ targetIndex = EditorGUILayout.IntField("Target Index", targetIndex);
+ selfIndex = EditorGUILayout.IntField("Self Index", selfIndex);
+ distance = EditorGUILayout.IntField("Distance", distance);
+ duration = EditorGUILayout.FloatField("Duration", duration);
+
+ if (GUILayout.Button("鐢熸垚骞舵挱鏀� TestAction"))
+ {
+ PlayTestAction();
+ }
+
+ if (GUILayout.Button("鏍囪璧风偣鍜岀粓鐐�"))
+ {
+ MarkStartAndEnd();
+ }
+
+ if (GUILayout.Button("澶嶄綅RecordPlayer"))
+ {
+ ResetRecordPlayer();
+ }
+ }
+
+ private void PlayTestAction()
+ {
+ // 杩愯鏃舵墠鎵ц
+ if (!Application.isPlaying)
+ {
+ Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+ return;
+ }
+
+ var battleField = BattleManager.Instance.storyBattleField;
+ if (battleField == null || battleField.recordPlayer == null)
+ {
+ Debug.LogError("BattleManager.storyBattleField 鎴� recordPlayer 鏈垵濮嬪寲锛�");
+ return;
+ }
+
+ var action = new TestAction(battleField, targetIndex, selfIndex, distance, duration);
+ battleField.recordPlayer.PlayRecord(action);
+ Debug.Log($"宸茬敓鎴愬苟鎾斁 TestAction: targetIndex={targetIndex}, selfIndex={selfIndex}, distance={distance}, duration={duration}");
+ }
+
+ private void MarkStartAndEnd()
+ {
+ // 杩愯鏃舵墠鎵ц
+ if (!Application.isPlaying)
+ {
+ Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+ return;
+ }
+
+ var battleField = BattleManager.Instance.storyBattleField;
+ if (battleField == null)
+ {
+ Debug.LogError("BattleManager.storyBattleField 鏈垵濮嬪寲锛�");
+ return;
+ }
+
+ // 鑾峰彇鑺傜偣
+ RectTransform startNode = battleField.GetTeamNode(BattleCamp.Red, selfIndex);
+ RectTransform endNode = battleField.GetTeamNode(BattleCamp.Blue, targetIndex);
+
+ BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>();
+ RectTransform canvasRect = battleWin.transform as RectTransform;
+
+ CreateMarker(canvasRect, startNode, "StartMarker");
+ CreateMarker(canvasRect, endNode, "EndMarker");
+ }
+
+ private void CreateMarker(RectTransform canvasRect, RectTransform targetNode, string markerName)
+ {
+ // 鑾峰彇鐩爣鑺傜偣鐨勪笘鐣屽潗鏍囷紙涓績鐐癸級
+ Vector3 worldPos = targetNode.TransformPoint(targetNode.rect.center);
+
+ // 杞崲鍒癈anvas鏈湴鍧愭爣
+ Vector2 localPoint;
+ RectTransformUtility.ScreenPointToLocalPointInRectangle(
+ canvasRect,
+ RectTransformUtility.WorldToScreenPoint(null, worldPos),
+ null,
+ out localPoint);
+
+ // 鍒涘缓RawImage
+ GameObject marker = new GameObject(markerName, typeof(RawImage));
+ 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;
+ }
+
+ private void ResetRecordPlayer()
+ {
+ if (!Application.isPlaying)
+ {
+ Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+ return;
+ }
+
+ var battleField = BattleManager.Instance.storyBattleField;
+ if (battleField == null || battleField.recordPlayer == null)
+ {
+ Debug.LogError("BattleManager.storyBattleField 鎴� recordPlayer 鏈垵濮嬪寲锛�");
+ return;
+ }
+
+ battleField.recordPlayer.HaveRest();
+ Debug.Log("RecordPlayer宸插浣嶏紒");
+ }
+}
+#endif
\ No newline at end of file
diff --git a/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta b/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta
new file mode 100644
index 0000000..27e944a
--- /dev/null
+++ b/Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ec550ea40001db4439cc23b8e873defd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs b/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs
new file mode 100644
index 0000000..a290c59
--- /dev/null
+++ b/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs
@@ -0,0 +1,73 @@
+#if UNITY_EDITOR
+using UnityEditor;
+using UnityEngine;
+
+public class TestSkillActionEditorWindow : EditorWindow
+{
+ protected int skillId = 1;
+ protected int hurtIndex = 0;
+
+ [MenuItem("Battle/TestSkillAction鐢熸垚鍣�")]
+ public static void ShowWindow()
+ {
+ GetWindow<TestSkillActionEditorWindow>("TestSkillAction鐢熸垚鍣�");
+ }
+
+ private void OnGUI()
+ {
+ GUILayout.Label("TestSkillAction鍙傛暟璁剧疆", EditorStyles.boldLabel);
+
+ skillId = EditorGUILayout.IntField("Skill ID", skillId);
+ hurtIndex = EditorGUILayout.IntField("Hurt Index", hurtIndex);
+
+ if (GUILayout.Button("鐢熸垚骞舵挱鏀� TestSkillAction"))
+ {
+ PlayTestSkillAction();
+ }
+
+ if (GUILayout.Button("澶嶄綅RecordPlayer"))
+ {
+ ResetRecordPlayer();
+ }
+ }
+
+ private void PlayTestSkillAction()
+ {
+ if (!Application.isPlaying)
+ {
+ Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+ return;
+ }
+
+ var battleField = BattleManager.Instance.storyBattleField;
+ if (battleField == null || battleField.recordPlayer == null)
+ {
+ Debug.LogError("BattleManager.storyBattleField 鎴� recordPlayer 鏈垵濮嬪寲锛�");
+ return;
+ }
+
+ var action = new TestSkillAction(battleField, skillId, hurtIndex);
+ battleField.recordPlayer.PlayRecord(action);
+ Debug.Log($"宸茬敓鎴愬苟鎾斁 TestSkillAction: skillId={skillId}, hurtIndex={hurtIndex}");
+ }
+
+ private void ResetRecordPlayer()
+ {
+ if (!Application.isPlaying)
+ {
+ Debug.LogWarning("璇峰湪杩愯鏃朵娇鐢ㄨ鍔熻兘锛�");
+ return;
+ }
+
+ var battleField = BattleManager.Instance.storyBattleField;
+ if (battleField == null || battleField.recordPlayer == null)
+ {
+ Debug.LogError("BattleManager.storyBattleField 鎴� recordPlayer 鏈垵濮嬪寲锛�");
+ return;
+ }
+
+ battleField.recordPlayer.HaveRest();
+ Debug.Log("RecordPlayer宸插浣嶏紒");
+ }
+}
+#endif
\ No newline at end of file
diff --git a/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta b/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta
new file mode 100644
index 0000000..75cebc7
--- /dev/null
+++ b/Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4e1ba39e4d98a0740930d1303fe8c1d6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Launch/Launch.cs b/Assets/Launch/Launch.cs
index 8b88680..a5faf41 100644
--- a/Assets/Launch/Launch.cs
+++ b/Assets/Launch/Launch.cs
@@ -16,6 +16,8 @@
{
#if UNITY_EDITOR
public bool isOpenConfigTesting = false;
+
+ public bool isOpenBattleDebug = false;
#endif
--
Gitblit v1.8.0