2024-09-12 18:30:55 +08:00
|
|
|
|
using Framework;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
2024-09-25 13:58:35 +08:00
|
|
|
|
using cfg.LevelCfg;
|
2024-09-12 18:30:55 +08:00
|
|
|
|
using Sirenix.Utilities;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using Sirenix.Utilities.Editor;
|
|
|
|
|
|
using Level = cfg.LevelCfg.Level;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Sirenix.OdinInspector.Editor;
|
|
|
|
|
|
|
|
|
|
|
|
public class LevelValidatorWindow : OdinEditorWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
[MenuItem("Tools/关卡地图资源检查")]
|
|
|
|
|
|
public static void ShowWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
curWindow = GetWindow<LevelValidatorWindow>();
|
2024-09-25 13:58:35 +08:00
|
|
|
|
curWindow.position = GUIHelper.GetEditorWindowRect().AlignCenter(300, 250);
|
|
|
|
|
|
curWindow.titleContent = new GUIContent("关卡资源检查");
|
2024-09-12 18:30:55 +08:00
|
|
|
|
curWindow.LoadLevelCfg();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static LevelValidatorWindow curWindow;
|
|
|
|
|
|
private Level levelCfg;
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadLevelCfg()
|
|
|
|
|
|
{
|
|
|
|
|
|
levelCfg = EditorTableManager.instance.tables.Level;
|
2024-09-25 13:58:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 映射不同的检查类型
|
|
|
|
|
|
private readonly Dictionary<string, System.Func<string, string, DataLevel, LevelValidatorBase[]>> checkDictionary =
|
|
|
|
|
|
new()
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckAll", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckCaptureData(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckFlagData(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckProtectData(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckLevelRegionData(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckScenePostProcess(dataLevel),
|
|
|
|
|
|
new CheckLevelCondition(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckLevelStarTarget(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckLevelScoreTarget(levelDataPath, mapDataPath)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckFlag", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckFlagData(levelDataPath, mapDataPath)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckCapture", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckCaptureData(levelDataPath, mapDataPath)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckProtect", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckProtectData(levelDataPath, mapDataPath),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckRegion", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckLevelRegionData(levelDataPath, mapDataPath),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckScenePostProcess", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckScenePostProcess(dataLevel),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"CheckStage", (levelDataPath, mapDataPath, dataLevel) => new LevelValidatorBase[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new CheckLevelCondition(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckLevelStarTarget(levelDataPath, mapDataPath),
|
|
|
|
|
|
new CheckLevelScoreTarget(levelDataPath, mapDataPath)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private void RunCheck(string checkType)
|
|
|
|
|
|
{
|
|
|
|
|
|
var levelValidator = new Dictionary<int, LevelValidatorBase[]>();
|
2024-09-12 18:30:55 +08:00
|
|
|
|
foreach (var dataLevel in levelCfg.DataMap)
|
|
|
|
|
|
{
|
2024-09-25 13:58:35 +08:00
|
|
|
|
var levelDataPath = dataLevel.Value.LevelData;
|
|
|
|
|
|
var mapDataPath = dataLevel.Value.MapData;
|
|
|
|
|
|
|
|
|
|
|
|
if (!levelValidator.ContainsKey(dataLevel.Key))
|
2024-09-12 18:30:55 +08:00
|
|
|
|
{
|
2024-09-25 13:58:35 +08:00
|
|
|
|
levelValidator.Add(dataLevel.Key,
|
|
|
|
|
|
checkDictionary[checkType](levelDataPath, mapDataPath, dataLevel.Value));
|
2024-09-12 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-25 13:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
GetTipsMessage(levelValidator);
|
2024-09-12 18:30:55 +08:00
|
|
|
|
}
|
2024-09-25 13:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
private void GetTipsMessage(Dictionary<int, LevelValidatorBase[]> levelValidatorMap)
|
2024-09-12 18:30:55 +08:00
|
|
|
|
{
|
2024-09-25 13:58:35 +08:00
|
|
|
|
foreach (var levelValidatorData in levelValidatorMap)
|
2024-09-12 18:30:55 +08:00
|
|
|
|
{
|
2024-09-23 13:52:58 +08:00
|
|
|
|
var levelErrorTitle = $"关卡ID:{levelValidatorData.Key}";
|
2024-09-12 18:30:55 +08:00
|
|
|
|
var errorLevelMessage = "";
|
2024-09-23 13:52:58 +08:00
|
|
|
|
|
|
|
|
|
|
var levelWarningTitle = $"关卡ID:{levelValidatorData.Key}";
|
|
|
|
|
|
var warningLevelMessage = "";
|
|
|
|
|
|
|
2024-09-12 18:30:55 +08:00
|
|
|
|
foreach (var validator in levelValidatorData.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (validator.ErrorData)
|
|
|
|
|
|
{
|
2024-09-20 18:38:40 +08:00
|
|
|
|
AppendWithNewLine(ref errorLevelMessage, validator.ErrorMessage);
|
2024-09-12 18:30:55 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!validator.CheckData())
|
|
|
|
|
|
{
|
2024-09-20 19:00:13 +08:00
|
|
|
|
AppendWithNewLine(ref errorLevelMessage, validator.ErrorMessage);
|
2024-09-23 13:52:58 +08:00
|
|
|
|
AppendWithNewLine(ref warningLevelMessage, validator.WarningMessage);
|
2024-09-12 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(errorLevelMessage))
|
|
|
|
|
|
{
|
2024-09-23 13:52:58 +08:00
|
|
|
|
AppendWithNewLine(ref levelErrorTitle, errorLevelMessage);
|
|
|
|
|
|
DebugUtil.LogError(levelErrorTitle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(warningLevelMessage))
|
|
|
|
|
|
{
|
|
|
|
|
|
AppendWithNewLine(ref levelWarningTitle, warningLevelMessage);
|
|
|
|
|
|
DebugUtil.LogWarning(levelWarningTitle);
|
2024-09-12 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-25 13:58:35 +08:00
|
|
|
|
|
2024-09-20 18:38:40 +08:00
|
|
|
|
private void AppendWithNewLine(ref string original, string newString)
|
2024-09-12 18:30:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(original))
|
|
|
|
|
|
{
|
|
|
|
|
|
original += "\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
original += newString;
|
|
|
|
|
|
}
|
2024-09-25 13:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查所有关卡配置")]
|
|
|
|
|
|
private void CheckAllLevelInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckAll");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查扛旗相关")]
|
|
|
|
|
|
private void CheckLevelFlag()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckFlag");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查占领相关")]
|
|
|
|
|
|
private void CheckLevelCapture()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckCapture");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查护送相关")]
|
|
|
|
|
|
private void CheckLevelProtect()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckProtect");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查地区相关")]
|
|
|
|
|
|
private void CheckLevelRegion()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckRegion");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查后处理场景相关")]
|
|
|
|
|
|
private void CheckLevelScenePostProcess()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckScenePostProcess");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[VerticalGroup("Check"), PropertySpace(10)]
|
|
|
|
|
|
[Button("检查关卡条件相关")]
|
|
|
|
|
|
private void CheckLevelStage()
|
|
|
|
|
|
{
|
|
|
|
|
|
RunCheck("CheckStage");
|
|
|
|
|
|
}
|
2024-09-12 18:30:55 +08:00
|
|
|
|
}
|