重命名buff表

This commit is contained in:
小李xl 2024-03-15 19:43:13 +08:00
parent 13a70dd50e
commit 9c88de3834
5 changed files with 165 additions and 166 deletions

View File

@ -8,22 +8,13 @@ namespace Config;
public static partial class ExcelConfig
{
/// <summary>
/// Sound.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// ActivityBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<Sound> Sound_List { get; private set; }
public static List<ActivityBase> ActivityBase_List { get; private set; }
/// <summary>
/// Sound.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// ActivityBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, Sound> Sound_Map { get; private set; }
/// <summary>
/// WeaponBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<WeaponBase> WeaponBase_List { get; private set; }
/// <summary>
/// WeaponBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, WeaponBase> WeaponBase_Map { get; private set; }
public static Dictionary<string, ActivityBase> ActivityBase_Map { get; private set; }
/// <summary>
/// ActivityMaterial.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
@ -43,15 +34,6 @@ public static partial class ExcelConfig
/// </summary>
public static Dictionary<string, AiAttackAttr> AiAttackAttr_Map { get; private set; }
/// <summary>
/// BuffBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<BuffBase> BuffBase_List { get; private set; }
/// <summary>
/// BuffBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, BuffBase> BuffBase_Map { get; private set; }
/// <summary>
/// BulletBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
@ -70,15 +52,6 @@ public static partial class ExcelConfig
/// </summary>
public static Dictionary<string, EnemyBase> EnemyBase_Map { get; private set; }
/// <summary>
/// ActivityBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<ActivityBase> ActivityBase_List { get; private set; }
/// <summary>
/// ActivityBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, ActivityBase> ActivityBase_Map { get; private set; }
/// <summary>
/// LiquidMaterial.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
@ -88,6 +61,33 @@ public static partial class ExcelConfig
/// </summary>
public static Dictionary<string, LiquidMaterial> LiquidMaterial_Map { get; private set; }
/// <summary>
/// PropBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<PropBase> PropBase_List { get; private set; }
/// <summary>
/// PropBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, PropBase> PropBase_Map { get; private set; }
/// <summary>
/// Sound.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<Sound> Sound_List { get; private set; }
/// <summary>
/// Sound.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, Sound> Sound_Map { get; private set; }
/// <summary>
/// WeaponBase.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同
/// </summary>
public static List<WeaponBase> WeaponBase_List { get; private set; }
/// <summary>
/// WeaponBase.xlsx表数据集合, 里 Map 形式存储, key 为 Id
/// </summary>
public static Dictionary<string, WeaponBase> WeaponBase_Map { get; private set; }
private static bool _init = false;
/// <summary>
@ -98,55 +98,37 @@ public static partial class ExcelConfig
if (_init) return;
_init = true;
_InitSoundConfig();
_InitWeaponBaseConfig();
_InitActivityBaseConfig();
_InitActivityMaterialConfig();
_InitAiAttackAttrConfig();
_InitBuffBaseConfig();
_InitBulletBaseConfig();
_InitEnemyBaseConfig();
_InitActivityBaseConfig();
_InitLiquidMaterialConfig();
_InitPropBaseConfig();
_InitSoundConfig();
_InitWeaponBaseConfig();
_InitWeaponBaseRef();
_InitBuffBaseRef();
_InitEnemyBaseRef();
_InitActivityBaseRef();
_InitEnemyBaseRef();
_InitPropBaseRef();
_InitWeaponBaseRef();
}
private static void _InitSoundConfig()
private static void _InitActivityBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/Sound.json");
Sound_List = JsonSerializer.Deserialize<List<Sound>>(text);
Sound_Map = new Dictionary<string, Sound>();
foreach (var item in Sound_List)
var text = _ReadConfigAsText("res://resource/config/ActivityBase.json");
ActivityBase_List = new List<ActivityBase>(JsonSerializer.Deserialize<List<Ref_ActivityBase>>(text));
ActivityBase_Map = new Dictionary<string, ActivityBase>();
foreach (var item in ActivityBase_List)
{
Sound_Map.Add(item.Id, item);
ActivityBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'Sound'失败!");
}
}
private static void _InitWeaponBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/WeaponBase.json");
WeaponBase_List = new List<WeaponBase>(JsonSerializer.Deserialize<List<Ref_WeaponBase>>(text));
WeaponBase_Map = new Dictionary<string, WeaponBase>();
foreach (var item in WeaponBase_List)
{
WeaponBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'WeaponBase'失败!");
throw new Exception("初始化表'ActivityBase'失败!");
}
}
private static void _InitActivityMaterialConfig()
@ -185,24 +167,6 @@ public static partial class ExcelConfig
throw new Exception("初始化表'AiAttackAttr'失败!");
}
}
private static void _InitBuffBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/BuffBase.json");
BuffBase_List = new List<BuffBase>(JsonSerializer.Deserialize<List<Ref_BuffBase>>(text));
BuffBase_Map = new Dictionary<string, BuffBase>();
foreach (var item in BuffBase_List)
{
BuffBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'BuffBase'失败!");
}
}
private static void _InitBulletBaseConfig()
{
try
@ -239,24 +203,6 @@ public static partial class ExcelConfig
throw new Exception("初始化表'EnemyBase'失败!");
}
}
private static void _InitActivityBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/ActivityBase.json");
ActivityBase_List = new List<ActivityBase>(JsonSerializer.Deserialize<List<Ref_ActivityBase>>(text));
ActivityBase_Map = new Dictionary<string, ActivityBase>();
foreach (var item in ActivityBase_List)
{
ActivityBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'ActivityBase'失败!");
}
}
private static void _InitLiquidMaterialConfig()
{
try
@ -275,7 +221,118 @@ public static partial class ExcelConfig
throw new Exception("初始化表'LiquidMaterial'失败!");
}
}
private static void _InitPropBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/PropBase.json");
PropBase_List = new List<PropBase>(JsonSerializer.Deserialize<List<Ref_PropBase>>(text));
PropBase_Map = new Dictionary<string, PropBase>();
foreach (var item in PropBase_List)
{
PropBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'PropBase'失败!");
}
}
private static void _InitSoundConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/Sound.json");
Sound_List = JsonSerializer.Deserialize<List<Sound>>(text);
Sound_Map = new Dictionary<string, Sound>();
foreach (var item in Sound_List)
{
Sound_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'Sound'失败!");
}
}
private static void _InitWeaponBaseConfig()
{
try
{
var text = _ReadConfigAsText("res://resource/config/WeaponBase.json");
WeaponBase_List = new List<WeaponBase>(JsonSerializer.Deserialize<List<Ref_WeaponBase>>(text));
WeaponBase_Map = new Dictionary<string, WeaponBase>();
foreach (var item in WeaponBase_List)
{
WeaponBase_Map.Add(item.Id, item);
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化表'WeaponBase'失败!");
}
}
private static void _InitActivityBaseRef()
{
foreach (Ref_ActivityBase item in ActivityBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Material))
{
item.Material = ActivityMaterial_Map[item.__Material];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'ActivityBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static void _InitEnemyBaseRef()
{
foreach (Ref_EnemyBase item in EnemyBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Activity))
{
item.Activity = ActivityBase_Map[item.__Activity];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'EnemyBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static void _InitPropBaseRef()
{
foreach (Ref_PropBase item in PropBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Activity))
{
item.Activity = ActivityBase_Map[item.__Activity];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'PropBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static void _InitWeaponBaseRef()
{
foreach (Ref_WeaponBase item in WeaponBase_List)
@ -344,63 +401,6 @@ public static partial class ExcelConfig
}
}
}
private static void _InitBuffBaseRef()
{
foreach (Ref_BuffBase item in BuffBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Activity))
{
item.Activity = ActivityBase_Map[item.__Activity];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'BuffBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static void _InitEnemyBaseRef()
{
foreach (Ref_EnemyBase item in EnemyBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Activity))
{
item.Activity = ActivityBase_Map[item.__Activity];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'EnemyBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static void _InitActivityBaseRef()
{
foreach (Ref_ActivityBase item in ActivityBase_List)
{
try
{
if (!string.IsNullOrEmpty(item.__Material))
{
item.Material = ActivityMaterial_Map[item.__Material];
}
}
catch (Exception e)
{
GD.PrintErr(e.ToString());
throw new Exception("初始化'ActivityBase'引用其他表数据失败, 当前行id: " + item.Id);
}
}
}
private static string _ReadConfigAsText(string path)
{
var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);

View File

@ -5,7 +5,7 @@ namespace Config;
public static partial class ExcelConfig
{
public class BuffBase
public class PropBase
{
/// <summary>
/// Buff Id
@ -42,9 +42,9 @@ public static partial class ExcelConfig
/// <summary>
/// 返回浅拷贝出的新对象
/// </summary>
public BuffBase Clone()
public PropBase Clone()
{
var inst = new BuffBase();
var inst = new PropBase();
inst.Id = Id;
inst.Remark = Remark;
inst.Activity = Activity;
@ -53,7 +53,7 @@ public static partial class ExcelConfig
return inst;
}
}
private class Ref_BuffBase : BuffBase
private class Ref_PropBase : PropBase
{
[JsonInclude]
public string __Activity;

View File

@ -175,8 +175,8 @@ public partial class BuffActivity : PropActivity
private static bool _init = false;
private static Dictionary<string, ExcelConfig.BuffBase> _buffAttributeMap =
new Dictionary<string, ExcelConfig.BuffBase>();
private static Dictionary<string, ExcelConfig.PropBase> _buffAttributeMap =
new Dictionary<string, ExcelConfig.PropBase>();
/// <summary>
/// 初始化 buff 属性数据
@ -189,7 +189,7 @@ public partial class BuffActivity : PropActivity
}
_init = true;
foreach (var buffAttr in ExcelConfig.BuffBase_List)
foreach (var buffAttr in ExcelConfig.PropBase_List)
{
if (buffAttr.Activity != null)
{
@ -204,7 +204,7 @@ public partial class BuffActivity : PropActivity
/// <summary>
/// 根据 ActivityBase.Id 获取对应 buff 的属性数据
/// </summary>
public static ExcelConfig.BuffBase GetBuffAttribute(string itemId)
public static ExcelConfig.PropBase GetBuffAttribute(string itemId)
{
if (itemId == null)
{
@ -215,7 +215,6 @@ public partial class BuffActivity : PropActivity
return attr;
}
return null;
//throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!");
throw new Exception($"buff'{itemId}'没有在 BuffBase 表中配置属性数据!");
}
}