【ID1000825】配置表资源检查工具-角色技能相关

main
zhangaotian 2024-10-31 17:01:38 +08:00
parent 4099c99f36
commit 34d946ffcd
11 changed files with 293 additions and 1 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fca0daf0439b14f79a188d28040eac19
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,7 +11,7 @@ using Sirenix.OdinInspector.Editor;
public class LevelValidatorWindow : OdinEditorWindow
{
[MenuItem("Tools/关卡地图资源检查")]
[MenuItem("Tools/Validator/关卡地图资源检查")]
public static void ShowWindow()
{
curWindow = GetWindow<LevelValidatorWindow>();

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5949cbf6a10904267b457ec5d4729b05
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,174 @@
using System.Collections.Generic;
using Framework;
public abstract class TableValidatorBase
{
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage;
/// <summary>
/// 警告信息
/// </summary>
public string WarningMessage;
/// <summary>
/// 技能最大等级
/// </summary>
protected const int MaxSkillLevel = 5;
/// <summary>
/// 错误ID
/// </summary>
protected const int ErrorID = 0;
protected TableValidatorBase()
{
}
protected void AppendWithNewLine(ref string original, string newString)
{
if (!string.IsNullOrEmpty(original))
{
original += "\n";
}
original += newString;
}
public abstract void CheckData();
}
/// <summary>
/// 根据角色检查角色技能、子弹、buff
/// </summary>
///
/// 角色对应技能组ID 技能组ID对应技能 技能ID对应子弹 子弹对应Buff组
/// 检查角色技能组是否五个等级都填入
/// 检查技能组ID是否填入技能或填错
/// 检查技能的的子弹列表是否填入或填错
/// 检查子弹的Buff是否填入或填错
public class CheckSkillToBulletToBuff : TableValidatorBase
{
public override void CheckData()
{
#region 配置获取
// 所有角色
var characterTableList = TableManager.Instance.Tables.CharacterAttri.DataList;
// 角色等级技能
var characterSkillTableList = TableManager.Instance.Tables.CharacterSkillLevel.DataList;
// 技能组和对应技能字典
var skillGroupTableDic = TableManager.Instance.Tables.SkillReferConfig.DataMap;
// 所有技能字典
var allSkillTableDic = TableManager.Instance.Tables.SkillConfig.DataMap;
// 所有子弹字典
var bulletTableDic = TableManager.Instance.Tables.BulletConfig.DataMap;
// 所有Buff字典
var buffTableDic = TableManager.Instance.Tables.BuffConfig.DataMap;
#endregion
// 角色和对应的等级技能
var characterSkillGroup = new Dictionary<int, List<int>>();
foreach (var character in characterTableList)
{
var skillGroup = new List<int>();
foreach (var characterSkill in characterSkillTableList)
{
// 检查角色是否都配了技能组ID
if (characterSkill.RoleID == character.RoleID)
{
if (characterSkill.SkillGroupId > ErrorID)
skillGroup.Add(characterSkill.SkillGroupId);
else
AppendWithNewLine(ref ErrorMessage,
$"请检查【CharacterSkillLevel】表角色【{character.RoleID}】的【{characterSkill.SkillLevel}】等级配置的技能组ID为空");
}
}
characterSkillGroup.TryAdd(character.RoleID, skillGroup);
// 检查角色是否配了五个等级的技能
if (skillGroup.Count < MaxSkillLevel)
AppendWithNewLine(ref ErrorMessage, $"请检查【CharacterSkillLevel】表角色【{character.RoleID}】的等级技能数量不足5");
}
// 从角色获取到的有效技能列表
var characterSkillList = new List<int>();
foreach (var characterSkills in characterSkillGroup)
{
foreach (var skillGroupID in characterSkills.Value)
{
// 检查角色是否配置了技能组
if (!skillGroupTableDic.TryGetValue(skillGroupID, out var skills))
{
AppendWithNewLine(ref ErrorMessage,
$"请检查【SkillReferConfig】或【CharacterSkillLevel】表角色【{characterSkills.Key}】配置的技能组【{skillGroupID}】不存在");
continue;
}
// 检查角色的技能组中的技能是否为空
if (skills.SkillIds == null || skills.SkillIds.Count <= 0)
{
AppendWithNewLine(ref ErrorMessage,
$"请检查【SkillReferConfig】或【CharacterSkillLevel】表角色【{characterSkills.Key}】配置的技能组【{skillGroupID}】的【SkillIds】为空");
continue;
}
characterSkillList.AddRange(skills.SkillIds);
}
}
// 获取到的有效Buff列表
var buffList = new List<int>();
foreach (var skill in characterSkillList)
{
// 检查技能组中的技能是否存在
if (!allSkillTableDic.TryGetValue(skill, out var skillData))
{
AppendWithNewLine(ref ErrorMessage, $"请检查【SkillReferConfig】或【SkillConfig】表技能【{skill}】不存在");
continue;
}
// 检查技能的子弹列表是否填入
if (skillData.ReferIds == null || skillData.ReferIds.Count <= 0)
{
AppendWithNewLine(ref ErrorMessage, $"请检查【SkillConfig】或【BulletConfig】表技能【{skill}】中的子弹组【ReferIds】为空");
continue;
}
foreach (var bulletID in skillData.ReferIds)
{
// 检查技能中的子弹是否存在
if (!bulletTableDic.TryGetValue(bulletID, out var bulletData))
{
AppendWithNewLine(ref ErrorMessage, $"请检查【SkillConfig】或【BulletConfig】表技能【{skill}】对应子弹【{bulletID}】不存在");
continue;
}
// 检查子弹对应的buff列表是否为空
if (bulletData.BuffList == null || bulletData.BuffList.Count <= 0)
{
AppendWithNewLine(ref ErrorMessage, $"请检查【BulletConfig】或【BuffConfig】表子弹【{bulletID}】对应的【BuffList】为空");
continue;
}
buffList.AddRange(bulletData.BuffList);
}
}
foreach (var buff in buffList)
{
// buff是否存在
if (!buffTableDic.TryGetValue(buff, out var buffData))
{
AppendWithNewLine(ref ErrorMessage, $"请检查【BulletConfig】或【BuffConfig】表buff【{buff}】不存在");
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 54bd15ddfc8954384bf867ffa4a2ce71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
using UnityEditor;
using UnityEngine;
using Sirenix.Utilities;
using Sirenix.OdinInspector;
using Sirenix.Utilities.Editor;
using System.Collections.Generic;
using Sirenix.OdinInspector.Editor;
public class TableValidatorWindow : OdinEditorWindow
{
[MenuItem("Tools/Validator/配置表资源检查")]
public static void ShowWindow()
{
curWindow = GetWindow<TableValidatorWindow>();
curWindow.position = GUIHelper.GetEditorWindowRect().AlignCenter(300, 250);
curWindow.titleContent = new GUIContent("配置表资源检查");
}
private static TableValidatorWindow curWindow;
// 映射不同的检查类型
private readonly Dictionary<string, System.Func<TableValidatorBase[]>> checkDictionary =
new()
{
{
"CheckSkillToBulletToBuff", () => new TableValidatorBase[]
{
new CheckSkillToBulletToBuff()
}
}
};
private void RunCheck(string checkType)
{
var tableValidator = new List<TableValidatorBase[]> { checkDictionary[checkType]() };
GetTipsMessage(tableValidator);
}
private void GetTipsMessage(List<TableValidatorBase[]> TableValidators)
{
foreach (var tableValidator in TableValidators)
{
var errorLevelMessage = "";
var warningLevelMessage = "";
foreach (var validator in tableValidator)
{
validator.CheckData();
if (!string.IsNullOrEmpty(validator.ErrorMessage))
{
AppendWithNewLine(ref errorLevelMessage, validator.ErrorMessage);
AppendWithNewLine(ref warningLevelMessage, validator.WarningMessage);
}
}
DebugUtil.LogError(!string.IsNullOrEmpty(errorLevelMessage) ? errorLevelMessage : "没有数据异常");
if (!string.IsNullOrEmpty(warningLevelMessage))
DebugUtil.LogWarning(warningLevelMessage);
}
}
private void AppendWithNewLine(ref string original, string newString)
{
if (!string.IsNullOrEmpty(original))
{
original += "\n";
}
original += newString;
}
[VerticalGroup("Check"), PropertySpace(10)]
[Button("检查角色技能关联子弹及其Buff")]
private void CheckCharacterSkillInfo()
{
RunCheck("CheckSkillToBulletToBuff");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19fa04ac7748148a7a2250563f497067
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: