三国卡牌客户端基础资源仓库
yyl
2025-08-25 214fe94eaf7f09741a7857775dfffe8c3b83c75c
125 【战斗】战斗系统
1个文件已修改
4个文件已添加
230 ■■■■■ 已修改文件
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/Launch.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs
New file
@@ -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);
        // 转换到Canvas本地坐标
        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
Assets/Editor/ScriptEditor/TestActionEditorWindow.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec550ea40001db4439cc23b8e873defd
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs
New file
@@ -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
Assets/Editor/ScriptEditor/TestSkillActionEditorWindow.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e1ba39e4d98a0740930d1303fe8c1d6
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Launch/Launch.cs
@@ -16,6 +16,8 @@
{
#if UNITY_EDITOR
    public bool isOpenConfigTesting = false;
    public bool isOpenBattleDebug = false;
#endif