buff系统重构中

This commit is contained in:
小李xl 2024-03-15 10:24:53 +08:00
parent 181e5d3d6d
commit dc5519dcdc
11 changed files with 72 additions and 7 deletions

View File

@ -20,6 +20,7 @@ public static class ExcelGenerator
public string TypeStr;
public string TypeName;
public CollectionsType CollectionsType;
public bool AutoParentheses = false;
public bool IsRefExcel;
public string RefTypeStr;
@ -392,7 +393,15 @@ public static class ExcelGenerator
MappingData mappingData;
try
{
var autoParentheses = false;
if (typeString.EndsWith('*'))
{
autoParentheses = true;
typeString = typeString.TrimEnd('*');
}
mappingData = ConvertToType(typeString.Replace(" ", ""));
mappingData.AutoParentheses = autoParentheses;
}
catch (Exception e)
{
@ -545,6 +554,17 @@ public static class ExcelGenerator
}
else
{
if (mappingData.AutoParentheses)
{
if (mappingData.CollectionsType == CollectionsType.Array)
{
cellStringValue = "[" + cellStringValue.TrimEnd(',') + "]";
}
if (mappingData.CollectionsType == CollectionsType.Map)
{
cellStringValue = "{" + cellStringValue.TrimEnd(',') + "}";
}
}
data.Add(field, JsonSerializer.Deserialize(cellStringValue, excelData.ColumnType[fieldName]));
}
}

View File

@ -1 +1 @@
5
6

View File

@ -583,7 +583,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0010.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0010.png",
"ShowInMapEditor": true
},

View File

@ -31,6 +31,10 @@
"BulletRepel": [
2,
-0.35
],
"RandomBulletSpeed": [
-0.05,
0.05
]
}
}

View File

@ -1,7 +1,10 @@
using Godot;
[Buff("BulletCount", "子弹数量 buff, 参数1为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), 参数2为增加子弹的数量")]
[Buff("BulletCount",
"子弹数量 buff, " +
"参数1为子弹数量添加类型, 1: 具体数量, 2:百分比(小数), " +
"参数2为增加子弹的数量")]
public class Buff_BulletCount : BuffFragment
{
private int _type;
@ -9,8 +12,8 @@ public class Buff_BulletCount : BuffFragment
public override void InitParam(float arg1, float arg2)
{
_type = (int)arg2;
_value = (int)arg1;
_type = (int)arg1;
_value = (int)arg2;
}
public override void OnPickUpItem()

View File

@ -1,5 +1,8 @@
[Buff("BulletDeviationAngle", "偏移角度 buff, 参数1为增加子弹偏移角度下限, 参数2为增加子弹偏移角度上限, 单位角度制, 会从上限和下限随机抽取值")]
[Buff("BulletDeviationAngle",
"子弹偏移角度 buff, " +
"参数1为增加子弹偏移角度下限, " +
"参数2为增加子弹偏移角度上限, 单位角度制, 会从上限和下限随机抽取值")]
public class Buff_BulletDeviationAngle : BuffFragment
{
private float _min;

View File

@ -1,7 +1,10 @@
using Godot;
[Buff("BulletRepel", "子弹击退 buff, 参数1为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), 参数2为子弹增加的击退值")]
[Buff("BulletRepel",
"子弹击退 buff, " +
"参数1为击退增加类型: 1:具体击退值, " +
"2:百分比击退值(小数), 参数2为子弹增加的击退值")]
public class Buff_BulletRepel : BuffFragment
{
private int _type;

View File

@ -0,0 +1,31 @@
[Buff("RandomBulletSpeed",
"子弹增加随机速度 buff, " +
"参数1为增加子弹速度下限, " +
"参数2为增加子弹速度上限, 会从上限和下限随机抽取值")]
public class Buff_RandomBulletSpeed : BuffFragment
{
private float _min;
private float _max;
public override void InitParam(float arg1, float arg2)
{
_min = arg1;
_max = arg2;
}
public override void OnPickUpItem()
{
Role.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent;
}
public override void OnRemoveItem()
{
Role.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent;
}
private void CalcBulletSpeedEvent(float originSpeed, RefValue<float> speed)
{
speed.Value += originSpeed * Utils.Random.RandomRangeFloat(_min, _max);
}
}

View File

@ -28,6 +28,7 @@ public class BuffRegister
BuffInfos.Add("MaxShield", new BuffInfo("MaxShield", null, new List<int>() { 1 }, typeof(Buff_MaxShield)));
BuffInfos.Add("MoveSpeed", new BuffInfo("MoveSpeed", null, new List<int>() { 1 }, typeof(Buff_MoveSpeed)));
BuffInfos.Add("OffsetInjury", new BuffInfo("OffsetInjury", null, new List<int>() { 1 }, typeof(Buff_OffsetInjury)));
BuffInfos.Add("RandomBulletSpeed", new BuffInfo("RandomBulletSpeed", null, new List<int>() { 2 }, typeof(Buff_RandomBulletSpeed)));
BuffInfos.Add("Scattering", new BuffInfo("Scattering", null, new List<int>() { 1 }, typeof(Buff_Scattering)));
BuffInfos.Add("ShieldRecoveryTime", new BuffInfo("ShieldRecoveryTime", null, new List<int>() { 1 }, typeof(Buff_ShieldRecoveryTime)));
BuffInfos.Add("WeaponCapacity", new BuffInfo("WeaponCapacity", null, new List<int>() { 1 }, typeof(Buff_WeaponCapacity)));