生成道具逻辑属性表表

This commit is contained in:
小李xl 2024-03-22 21:31:22 +08:00
parent 1bac8dffdf
commit 8f4a5c6d7e
5 changed files with 134 additions and 9 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@
/DungeonShooting_Godot/DungeonShooting.sln.DotSettings.user /DungeonShooting_Godot/DungeonShooting.sln.DotSettings.user
/DungeonShooting_Godot/.VSCodeCounter /DungeonShooting_Godot/.VSCodeCounter
**/*.txt **/*.txt
/DungeonShooting_Godot/buffTable

View File

@ -15,8 +15,74 @@ public static class BuffGenerator
{ {
public static bool Generate() public static bool Generate()
{ {
PropFragmentRegister.Init();
var outStr = "# 道具逻辑属性表\n\n";
outStr += GetSplit("Buff 属性片段");
outStr += GetTableTitle();
foreach (var fragment in PropFragmentRegister.BuffFragmentInfos)
{
outStr += GetTableLine(fragment.Value);
}
outStr += "\n\n";
outStr += GetSplit("主动道具使用条件片段");
outStr += GetTableTitle();
foreach (var fragment in PropFragmentRegister.ConditionFragmentInfos)
{
outStr += GetTableLine(fragment.Value);
}
outStr += "\n\n";
outStr += GetSplit("主动道具使用效果片段");
outStr += GetTableTitle();
foreach (var fragment in PropFragmentRegister.EffectFragmentInfos)
{
outStr += GetTableLine(fragment.Value);
}
outStr += "\n\n";
outStr += GetSplit("主动道具充能条件片段");
outStr += GetTableTitle();
foreach (var fragment in PropFragmentRegister.ChargeFragmentInfos)
{
outStr += GetTableLine(fragment.Value);
}
outStr += "\n\n";
if (!Directory.Exists("buffTable"))
{
Directory.CreateDirectory("buffTable");
}
File.WriteAllText("buffTable/BuffTable.md", outStr);
return true; return true;
} }
private static string GetSplit(string title)
{
return $"---\n### {title}\n";
}
private static string GetTableTitle()
{
return $"| 属性名称 | 描述 | 参数 |\n" +
$"|-|-|-|\n";
}
private static string GetTableLine(PropFragmentInfo fragmentInfo)
{
var arg = "";
for (var i = 0; i < fragmentInfo.ArgInfos.Count; i++)
{
var argInfo = fragmentInfo.ArgInfos[i];
if (i > 0)
{
arg += "<br/>";
}
arg += $"参数{argInfo.ArgIndex}: {argInfo.Description}";
}
return $"| {fragmentInfo.Name} | {fragmentInfo.Description} | {arg} |\n";
}
} }
#endif #endif

View File

@ -4,7 +4,7 @@ using Godot;
[BuffFragment( [BuffFragment(
"BulletCount", "BulletCount",
"子弹数量 buff, ", "子弹数量 buff",
Arg1 = "(int)子弹数量添加类型, 1: 具体数量, 2:百分比", Arg1 = "(int)子弹数量添加类型, 1: 具体数量, 2:百分比",
Arg2 = "(float)增加子弹的数量" Arg2 = "(float)增加子弹的数量"
)] )]

View File

@ -1,11 +1,31 @@
using System; using System;
using System.Collections.Generic;
/// <summary> /// <summary>
/// 道具逻辑片段数据 /// 道具逻辑片段数据
/// </summary> /// </summary>
public class PropFragmentInfo public class PropFragmentInfo
{ {
public class PropFragmentArgInfo
{
/// <summary>
/// 参数索引
/// </summary>
public int ArgIndex;
/// <summary>
/// 参数描述
/// </summary>
public string Description;
public PropFragmentArgInfo(int argIndex, string description)
{
ArgIndex = argIndex;
Description = description;
}
}
/// <summary> /// <summary>
/// buff 名称 /// buff 名称
/// </summary> /// </summary>
@ -21,10 +41,48 @@ public class PropFragmentInfo
/// </summary> /// </summary>
public Type Type; public Type Type;
public PropFragmentInfo(string name, string description, Type type) /// <summary>
/// buff 参数信息
/// </summary>
public List<PropFragmentArgInfo> ArgInfos = new List<PropFragmentArgInfo>();
public PropFragmentInfo(FragmentAttribute attribute, Type type)
{ {
Name = name; Name = attribute.Name;
Description = description; Description = attribute.Description;
Type = type; Type = type;
if (attribute.Arg1 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(1, attribute.Arg1));
}
if (attribute.Arg2 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(2, attribute.Arg2));
}
if (attribute.Arg3 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(3, attribute.Arg3));
}
if (attribute.Arg4 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(4, attribute.Arg4));
}
if (attribute.Arg5 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(5, attribute.Arg5));
}
if (attribute.Arg6 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(6, attribute.Arg6));
}
if (attribute.Arg7 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(7, attribute.Arg7));
}
if (attribute.Arg8 != null)
{
ArgInfos.Add(new PropFragmentArgInfo(8, attribute.Arg8));
}
} }
} }

View File

@ -53,7 +53,7 @@ public class PropFragmentRegister
continue; continue;
} }
var buffInfo = new PropFragmentInfo(attribute.Name, attribute.Description, type); var buffInfo = new PropFragmentInfo(attribute, type);
BuffFragmentInfos.Add(attribute.Name, buffInfo); BuffFragmentInfos.Add(attribute.Name, buffInfo);
} }
} }
@ -71,7 +71,7 @@ public class PropFragmentRegister
continue; continue;
} }
var conditionInfo = new PropFragmentInfo(attribute.Name, attribute.Description, type); var conditionInfo = new PropFragmentInfo(attribute, type);
ConditionFragmentInfos.Add(attribute.Name, conditionInfo); ConditionFragmentInfos.Add(attribute.Name, conditionInfo);
} }
} }
@ -89,7 +89,7 @@ public class PropFragmentRegister
continue; continue;
} }
var effectInfo = new PropFragmentInfo(attribute.Name, attribute.Description, type); var effectInfo = new PropFragmentInfo(attribute, type);
EffectFragmentInfos.Add(attribute.Name, effectInfo); EffectFragmentInfos.Add(attribute.Name, effectInfo);
} }
} }
@ -107,7 +107,7 @@ public class PropFragmentRegister
continue; continue;
} }
var chargeInfo = new PropFragmentInfo(attribute.Name, attribute.Description, type); var chargeInfo = new PropFragmentInfo(attribute, type);
ChargeFragmentInfos.Add(attribute.Name, chargeInfo); ChargeFragmentInfos.Add(attribute.Name, chargeInfo);
} }
} }