From 20b873f1b2470a857d8b787f97aaa990f6b2a192 Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Tue, 12 Nov 2024 16:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=88=98=E6=96=97=E5=89=A7=E6=83=85?= =?UTF-8?q?=E3=80=91=E7=BC=93=E5=AD=98=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gameplay/Fight/FightStory/Cmp.meta | 3 + .../Fight/FightStory/Cmp/CmpFightStory.cs | 9 + .../FightStory/Cmp/CmpFightStory.cs.meta | 3 + .../Fight/FightStory/Data/FightStoryData.cs | 10 + .../FightStory/Data/FightStoryStageData.cs | 1 - .../FightStory/Data/FightStoryTeamData.cs | 36 ++++ .../Data/FightStoryTeamData.cs.meta | 3 + .../Code/Scripts/Gameplay/Utils/PathEx.cs | 22 +++ ProjectNLD/Assets/Config/FightStory.meta | 8 + .../FightStory/Maps04_Snowfield_12.json | 47 +++++ .../FightStory/Maps04_Snowfield_12.json.meta | 7 + .../Maps/MapData_Maps04_Snowfield_12.json | 2 - ProjectNLD/Assets/Editor/FightStory.meta | 3 + .../FightStory/CmpFightStoryInspector.cs | 24 +++ .../FightStory/CmpFightStoryInspector.cs.meta | 3 + .../Editor/FightStory/FightStoryWindow.cs | 182 ++++++++++++++++++ .../FightStory/FightStoryWindow.cs.meta | 3 + 17 files changed, 363 insertions(+), 3 deletions(-) create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp.meta create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs.meta create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs.meta create mode 100644 ProjectNLD/Assets/Config/FightStory.meta create mode 100644 ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json create mode 100644 ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json.meta create mode 100644 ProjectNLD/Assets/Editor/FightStory.meta create mode 100644 ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs create mode 100644 ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs.meta create mode 100644 ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs create mode 100644 ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp.meta b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp.meta new file mode 100644 index 00000000000..98765fbc477 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 79b170e9e8de4320bf6f42368be40c50 +timeCreated: 1731393825 \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs new file mode 100644 index 00000000000..58e53074cb7 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace Gameplay.Fight.FightStory.Cmp +{ + public class CmpFightStory : MonoBehaviour + { + + } +} diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs.meta b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs.meta new file mode 100644 index 00000000000..0c93cf57757 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Cmp/CmpFightStory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82a6ee46a05f45d9b9c0bc725450865b +timeCreated: 1731393832 \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryData.cs index c241553a45a..9511aec032a 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryData.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryData.cs @@ -5,9 +5,19 @@ namespace Gameplay.Fight.FightStory.Data [Serializable] public class FightStoryData { + /// + /// 是否强制指定玩家队伍 + /// + public bool forceUserTeam; + public FightStoryTeamData playerTeamData; + + public bool hasBeforeFightStage; public FightStoryStageData beforeFightStageData; + + public bool hasAfterFightStage; public FightStoryStageData afterFightStageData; + public bool hasDuringFightStage; public List duringFightActionList = new List(); } } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryStageData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryStageData.cs index a86e0ac4532..b560445a699 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryStageData.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryStageData.cs @@ -5,7 +5,6 @@ namespace Gameplay.Fight.FightStory.Data [Serializable] public class FightStoryStageData { - public List forceTeamIds = new List(); public FightStoryTriggerData triggerData; public List actionList = new List(); } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs new file mode 100644 index 00000000000..f696155328e --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +namespace Gameplay.Fight.FightStory.Data +{ + [Serializable] + public class FightStoryTeamData + { + + /// + /// 队长ID + /// 读 NPC 配置表 + /// + public int leaderId; + + /// + /// 队伍成员 长度一定为指挥位数+1 + /// 包括队长, 0 号位为队长 + /// 剩下的 如果npcConfigId 为 0 则表示空位 + /// + public List memberList = new List(); + } + + [Serializable] + public class FightStoryNpcData + { + /// + /// 配置ID 读 NPC 配置表 + /// + public int npcConfigId; + /// + /// 对应关卡内的unit id + /// + public int unitLocalId; + } + +} diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs.meta b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs.meta new file mode 100644 index 00000000000..ea3e27067a4 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/FightStory/Data/FightStoryTeamData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e3a2bd322fb04f0ca67e5cdc3bfc1c96 +timeCreated: 1731396336 \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/PathEx.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/PathEx.cs index eb412e5bbeb..ccbea598e8a 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/PathEx.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/PathEx.cs @@ -1,4 +1,5 @@ using Framework; +using UnityEngine; namespace Gameplay.Utils { @@ -121,6 +122,27 @@ namespace Gameplay.Utils return $"Assets/Art_Out/Manual/Protect/{modelName}.prefab"; } + /// + /// 获取战斗剧情配置文件路径 + /// + /// + /// + public static string GetFightStoryJsonPath(string sceneName) + { + return $"Assets/Config/FightStory/{sceneName}.json"; + } + + public static string GetRealPath(string assetPath) + { + if (assetPath.StartsWith("Assets/")) + { + // 替换为Application.dataPath + return $"{Application.dataPath}/{assetPath.Substring(7)}"; + } + // 不是Assets/开头的路径,直接返回 + return assetPath; + } + public static string GetFightBuildingModelPath(uint uid) { var cfg = TableManager.Instance.Tables.BuildConfig.Get((int)uid); diff --git a/ProjectNLD/Assets/Config/FightStory.meta b/ProjectNLD/Assets/Config/FightStory.meta new file mode 100644 index 00000000000..560d78e717d --- /dev/null +++ b/ProjectNLD/Assets/Config/FightStory.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b07b2a6469e829443ba76eacdb383687 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json b/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json new file mode 100644 index 00000000000..2d9308ae956 --- /dev/null +++ b/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json @@ -0,0 +1,47 @@ +{ + "forceUserTeam": true, + "playerTeamData": { + "leaderId": 1, + "memberList": [ + { + "npcConfigId": 1, + "unitLocalId": 0 + }, + { + "npcConfigId": 0, + "unitLocalId": 0 + }, + { + "npcConfigId": 0, + "unitLocalId": 0 + }, + { + "npcConfigId": 0, + "unitLocalId": 0 + }, + { + "npcConfigId": 0, + "unitLocalId": 0 + } + ] + }, + "hasBeforeFightStage": false, + "beforeFightStageData": { + "forceTeamIds": [], + "triggerData": { + "triggerType": 0, + "intParams": [], + "floatParams": [] + } + }, + "hasAfterFightStage": false, + "afterFightStageData": { + "forceTeamIds": [], + "triggerData": { + "triggerType": 0, + "intParams": [], + "floatParams": [] + } + }, + "hasDuringFightStage": false +} \ No newline at end of file diff --git a/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json.meta b/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json.meta new file mode 100644 index 00000000000..6a8ade4f48c --- /dev/null +++ b/ProjectNLD/Assets/Config/FightStory/Maps04_Snowfield_12.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1e826452cf2af23448ec90fc69619314 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectNLD/Assets/Config/Maps/MapData_Maps04_Snowfield_12.json b/ProjectNLD/Assets/Config/Maps/MapData_Maps04_Snowfield_12.json index 735bb17699e..51bb602ac17 100644 --- a/ProjectNLD/Assets/Config/Maps/MapData_Maps04_Snowfield_12.json +++ b/ProjectNLD/Assets/Config/Maps/MapData_Maps04_Snowfield_12.json @@ -391,7 +391,5 @@ "x": 4, "y": 1 }, - "capturePoints": [], - "flagStartPoints": [], "showBuffPoints": [] } \ No newline at end of file diff --git a/ProjectNLD/Assets/Editor/FightStory.meta b/ProjectNLD/Assets/Editor/FightStory.meta new file mode 100644 index 00000000000..a224bcc55ce --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightStory.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 07407c694ec944da9ef33702bbe11c98 +timeCreated: 1731393788 \ No newline at end of file diff --git a/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs b/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs new file mode 100644 index 00000000000..b363b03dd62 --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs @@ -0,0 +1,24 @@ +using Gameplay.Fight.FightStory.Cmp; +using UnityEditor; +using UnityEngine; + +namespace CEditor.FightStory +{ + [CustomEditor(typeof(CmpFightStory))] + public class CmpFightStoryInspector : Editor + { + + public override void OnInspectorGUI() + { + // base.OnInspectorGUI(); + + if (GUILayout.Button("打开剧情编辑器")) + { + FightStoryWindow window = EditorWindow.GetWindow(); + window.titleContent = new GUIContent("剧情编辑器"); + window.Show(); + } + } + + } +} diff --git a/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs.meta b/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs.meta new file mode 100644 index 00000000000..c9d7126c418 --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightStory/CmpFightStoryInspector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: debff0a20c824a539e8720431c4bf620 +timeCreated: 1731393926 \ No newline at end of file diff --git a/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs b/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs new file mode 100644 index 00000000000..2d0543a02ee --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs @@ -0,0 +1,182 @@ +using System; +using System.IO; +using cfg.FightCfg; +using Framework; +using Gameplay.Fight.FightStory.Data; +using Gameplay.Utils; +using UnityEditor; +using UnityEngine; + +namespace CEditor.FightStory +{ + public class FightStoryWindow : EditorWindow + { + + private FightStoryData _storyData; + + private string _jsonPath; + private Vector2 _scrollPos1; + + private void OnGUI() + { + _InitData(); + + _ShowTitle(); + + _scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1); + GUILayout.BeginVertical(); + _ShowNPCInfos(); + _ShowPreStory(); + + GUILayout.EndVertical(); + EditorGUILayout.EndScrollView(); + } + + private void OnDestroy() + { + _storyData = null; + } + + private void _ShowPreStory() + { + _storyData.hasBeforeFightStage = EditorGUILayout.ToggleLeft("是否有战前剧情", _storyData.hasBeforeFightStage); + if (_storyData.hasBeforeFightStage) + { + + } + + } + + private void _ShowTitle() + { + GUILayout.BeginHorizontal(); + GUILayout.Label("文件:" + _jsonPath); + if (GUILayout.Button("保存")) + { + var jsonStr = JsonUtility.ToJson(_storyData, true); + var realPath = PathEx.GetRealPath(_jsonPath); + File.WriteAllText(realPath, jsonStr); + + // 弹出提示 + if (EditorUtility.DisplayDialog("保存成功", "保存成功", "确定")) + { + AssetDatabase.Refresh(); + } + } + GUILayout.EndHorizontal(); + } + + private void _ShowNPCInfos() + { + GUILayout.Label("准备NPC信息"); + + _storyData.forceUserTeam = EditorGUILayout.ToggleLeft("是否强制指定玩家队伍", _storyData.forceUserTeam); + + if (_storyData.forceUserTeam) + { + if (_storyData.playerTeamData == null) + { + _storyData.playerTeamData = new FightStoryTeamData(); + } + + GUILayout.BeginHorizontal(); + + GUILayout.Label("队长ID:", GUILayout.Width(60)); + _storyData.playerTeamData.leaderId = EditorGUILayout.IntField(_storyData.playerTeamData.leaderId); + GUILayout.EndHorizontal(); + + var npcConfig = EditorTableManager.instance.tables.FightNPCConfig.GetOrDefault(_storyData.playerTeamData.leaderId); + if (npcConfig == null) + { + EditorGUILayout.HelpBox("没有找到对应的NPC配置:" + _storyData.playerTeamData.leaderId, MessageType.Error); + } + else + { + _ShowDetailTeamInfo(npcConfig); + } + GUILayout.Space(10); + } + + } + + private void _ShowDetailTeamInfo(DataFightNPC npcConfig) + { + var provideJobs = npcConfig.ProvideJob; + if (_storyData.playerTeamData.memberList.Count != provideJobs.Length + 1) + { + _storyData.playerTeamData.memberList.Clear(); + for (int i = 0; i < provideJobs.Length + 1; i++) + { + _storyData.playerTeamData.memberList.Add(new FightStoryNpcData()); + } + } + GUILayout.Space(10); + + _storyData.playerTeamData.memberList[0].npcConfigId = _storyData.playerTeamData.leaderId; + _ShowNpcInfo(_storyData.playerTeamData.memberList[0], "队长位:"); + for (int i = 1; i < _storyData.playerTeamData.memberList.Count; i++) + { + var job = provideJobs[i - 1]; + var npcInfo = _storyData.playerTeamData.memberList[i]; + GUILayout.Space(10); + _ShowNpcInfo(npcInfo, "位置:" + i + " 职业:" + (int)job); + } + } + + private void _ShowNpcInfo(FightStoryNpcData npcData, string titleName) + { + GUILayout.BeginHorizontal(); + + GUILayout.Label(titleName); + npcData.npcConfigId = EditorGUILayout.IntField(npcData.npcConfigId); + npcData.unitLocalId = EditorGUILayout.IntField(npcData.unitLocalId); + + GUILayout.EndHorizontal(); + + _NpcErrorCheck(npcData); + } + + private void _NpcErrorCheck(FightStoryNpcData npcData) + { + if (npcData.npcConfigId != 0) + { + var npcConfig = EditorTableManager.instance.tables.FightNPCConfig.GetOrDefault(npcData.npcConfigId); + if (npcConfig == null) + { + EditorGUILayout.HelpBox("没有找到对应的NPC配置:" + npcData.npcConfigId, MessageType.Error); + return; + } + else + { + GUILayout.Label("NPC名字: " + npcConfig.NameRead + " 职业:" + (int)npcConfig.Job); + } + } + else + { + GUILayout.Label("玩家自由配置"); + } + } + + private void _InitData() + { + if (_storyData != null) return; + // 先判断有没有json数据 + // 获取当前场景的名字 + var sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; + var jsonPath = PathEx.GetFightStoryJsonPath(sceneName); + _jsonPath = jsonPath; + var realPath = PathEx.GetRealPath(jsonPath); + if (File.Exists(realPath)) + { + var loadJsonStr = File.ReadAllText(realPath); + _storyData = JsonUtility.FromJson(loadJsonStr); + } + + if (_storyData == null) + { + Debug.Log("没有找到剧情数据, 创建新的剧情数据"); + _storyData = new FightStoryData(); + } + } + } +} diff --git a/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs.meta b/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs.meta new file mode 100644 index 00000000000..2f02e26eec4 --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightStory/FightStoryWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5295557dfa164449a6ffc21441f0dd8b +timeCreated: 1731393797 \ No newline at end of file