using UnityEngine; using UnityEditor; using System; using System.Collections; using System.Collections.Generic; using System.Linq; public class StoryBattleEditorWindow : EditorWindow { private StoryBattleField storyBattleField; // 假设你有如下字段 private int redIndex = 0; private int blueIndex = 0; private int skillId = 0; private SkillConfig currentSkillConfig; private int casterCamp = 0; // 0=红方,1=蓝方 private float timeScale = 1f; [MenuItem("Tools/StoryBattleEditor")] public static void OpenWindow() { StoryBattleEditorWindow window = GetWindow("Story Battle Editor"); window.minSize = new Vector2(800, 600); window.Show(); BattleManager.Instance.StartStoryBattle(); window.storyBattleField = BattleManager.Instance.storyBattleField; } private void OnGUI() { GUILayout.Label("Story Battle Editor", EditorStyles.boldLabel); if (storyBattleField == null) { EditorGUILayout.HelpBox("请先指定 StoryBattleField 实例", MessageType.Warning); if (GUILayout.Button("重新加载")) { storyBattleField = BattleManager.Instance.storyBattleField; } return; } EditorGUILayout.Space(); EditorGUILayout.LabelField("技能录制动作测试", EditorStyles.boldLabel); // 技能ID输入与配置获取 skillId = EditorGUILayout.IntField("技能ID", skillId); currentSkillConfig = SkillConfig.Get(skillId); if (currentSkillConfig != null) { EditorGUILayout.LabelField($"技能名: {currentSkillConfig.SkillName}"); } else { EditorGUILayout.HelpBox("未找到该技能配置", MessageType.Warning); } timeScale = EditorGUILayout.FloatField("TimeScale", timeScale); Time.timeScale = timeScale; // 红蓝双方 BattleObject 选择 var redCampList = new List(from BO in storyBattleField.battleObjMgr.redCampList where !BO.IsDead() select BO); var blueCampList = new List(from BO in storyBattleField.battleObjMgr.blueCampList where !BO.IsDead() select BO); string[] redNames = redCampList != null ? redCampList.ConvertAll(obj => obj != null ? obj.BattleObjectId.ToString() : "null").ToArray() : new string[0]; redIndex = EditorGUILayout.Popup("红方 BattleObject", redIndex, redNames); string[] blueNames = blueCampList != null ? blueCampList.ConvertAll(obj => obj != null ? obj.BattleObjectId.ToString() : "null").ToArray() : new string[0]; blueIndex = EditorGUILayout.Popup("蓝方 BattleObject", blueIndex, blueNames); // 选择施法者 casterCamp = EditorGUILayout.Popup("施法者阵营", casterCamp, new string[] { "红方", "蓝方" }); EditorGUILayout.Space(); if (GUILayout.Button("播放 SkillRecordAction")) { if (currentSkillConfig == null) { Debug.LogError("SkillConfig 未找到!"); return; } if (redCampList == null || blueCampList == null || redCampList.Count == 0 || blueCampList.Count == 0) { Debug.LogError("红方或蓝方列表为空!"); return; } var redObj = redCampList[Mathf.Clamp(redIndex, 0, redCampList.Count - 1)]; var blueObj = blueCampList[Mathf.Clamp(blueIndex, 0, blueCampList.Count - 1)]; BattleObject caster = (casterCamp == 0) ? redObj : blueObj; // 构造SkillRecordAction var action = new SkillRecordAction(skillId, storyBattleField, caster); if (storyBattleField.recordPlayer != null) { storyBattleField.recordPlayer.PlayRecord(action); } else { Debug.LogError("recordPlayer 未设置!"); } } if (GUILayout.Button("全部复活")) { storyBattleField.battleObjMgr.ReviveAll(); } } }