【战斗剧情】缓存部分代码
parent
e47d2cbaee
commit
20b873f1b2
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79b170e9e8de4320bf6f42368be40c50
|
||||
timeCreated: 1731393825
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Gameplay.Fight.FightStory.Cmp
|
||||
{
|
||||
public class CmpFightStory : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 82a6ee46a05f45d9b9c0bc725450865b
|
||||
timeCreated: 1731393832
|
||||
|
|
@ -5,9 +5,19 @@ namespace Gameplay.Fight.FightStory.Data
|
|||
[Serializable]
|
||||
public class FightStoryData
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否强制指定玩家队伍
|
||||
/// </summary>
|
||||
public bool forceUserTeam;
|
||||
public FightStoryTeamData playerTeamData;
|
||||
|
||||
public bool hasBeforeFightStage;
|
||||
public FightStoryStageData beforeFightStageData;
|
||||
|
||||
public bool hasAfterFightStage;
|
||||
public FightStoryStageData afterFightStageData;
|
||||
|
||||
public bool hasDuringFightStage;
|
||||
public List<FightStoryActionData> duringFightActionList = new List<FightStoryActionData>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace Gameplay.Fight.FightStory.Data
|
|||
[Serializable]
|
||||
public class FightStoryStageData
|
||||
{
|
||||
public List<int> forceTeamIds = new List<int>();
|
||||
public FightStoryTriggerData triggerData;
|
||||
public List<FightStoryActionData> actionList = new List<FightStoryActionData>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace Gameplay.Fight.FightStory.Data
|
||||
{
|
||||
[Serializable]
|
||||
public class FightStoryTeamData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 队长ID
|
||||
/// 读 NPC 配置表
|
||||
/// </summary>
|
||||
public int leaderId;
|
||||
|
||||
/// <summary>
|
||||
/// 队伍成员 长度一定为指挥位数+1
|
||||
/// 包括队长, 0 号位为队长
|
||||
/// 剩下的 如果npcConfigId 为 0 则表示空位
|
||||
/// </summary>
|
||||
public List<FightStoryNpcData> memberList = new List<FightStoryNpcData>();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class FightStoryNpcData
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置ID 读 NPC 配置表
|
||||
/// </summary>
|
||||
public int npcConfigId;
|
||||
/// <summary>
|
||||
/// 对应关卡内的unit id
|
||||
/// </summary>
|
||||
public int unitLocalId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e3a2bd322fb04f0ca67e5cdc3bfc1c96
|
||||
timeCreated: 1731396336
|
||||
|
|
@ -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";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取战斗剧情配置文件路径
|
||||
/// </summary>
|
||||
/// <param name="sceneName"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b07b2a6469e829443ba76eacdb383687
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e826452cf2af23448ec90fc69619314
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -391,7 +391,5 @@
|
|||
"x": 4,
|
||||
"y": 1
|
||||
},
|
||||
"capturePoints": [],
|
||||
"flagStartPoints": [],
|
||||
"showBuffPoints": []
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 07407c694ec944da9ef33702bbe11c98
|
||||
timeCreated: 1731393788
|
||||
|
|
@ -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<FightStoryWindow>();
|
||||
window.titleContent = new GUIContent("剧情编辑器");
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: debff0a20c824a539e8720431c4bf620
|
||||
timeCreated: 1731393926
|
||||
|
|
@ -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<FightStoryData>(loadJsonStr);
|
||||
}
|
||||
|
||||
if (_storyData == null)
|
||||
{
|
||||
Debug.Log("没有找到剧情数据, 创建新的剧情数据");
|
||||
_storyData = new FightStoryData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5295557dfa164449a6ffc21441f0dd8b
|
||||
timeCreated: 1731393797
|
||||
Loading…
Reference in New Issue