更改buff片段参数类型, 目前还有编译错误, 马上会处理

This commit is contained in:
小李xl 2024-03-20 14:24:32 +08:00
parent 2bbfb58325
commit 16d224249f
18 changed files with 75 additions and 361 deletions

View File

@ -31,7 +31,7 @@ public static partial class ExcelConfig
/// value为buff初始化参数
/// </summary>
[JsonInclude]
public Dictionary<string, float[]> Buff;
public Dictionary<string, System.Text.Json.JsonElement[]> Buff;
/// <summary>
/// 道具使用条件 <br/>
@ -39,7 +39,7 @@ public static partial class ExcelConfig
/// 性名称请参阅condition属性表
/// </summary>
[JsonInclude]
public Dictionary<string, float[]> Condition;
public Dictionary<string, System.Text.Json.JsonElement[]> Condition;
/// <summary>
/// 道具使用效果 <br/>
@ -47,7 +47,7 @@ public static partial class ExcelConfig
/// 性名称请参阅effect属性表
/// </summary>
[JsonInclude]
public Dictionary<string, float[]> Effect;
public Dictionary<string, System.Text.Json.JsonElement[]> Effect;
/// <summary>
/// 道具充能效果 <br/>
@ -56,7 +56,7 @@ public static partial class ExcelConfig
/// 注意: 仅当'IsConsumables'为false是生效
/// </summary>
[JsonInclude]
public Dictionary<string, float[]> Charge;
public Dictionary<string, System.Text.Json.JsonElement[]> Charge;
/// <summary>
/// 使用道具的效果持续时间 <br/>

View File

@ -31,7 +31,7 @@ public static partial class ExcelConfig
/// value为buff初始化参数
/// </summary>
[JsonInclude]
public Dictionary<string, float[]> Buff;
public Dictionary<string, System.Text.Json.JsonElement[]> Buff;
/// <summary>
/// 返回浅拷贝出的新对象

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using Config;
using Godot;
@ -121,43 +122,9 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
switch (item.Length)
{
case 0:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
_buffFragment.Add(buff);
}
break;
case 1:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0]);
_buffFragment.Add(buff);
}
break;
case 2:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1]);
_buffFragment.Add(buff);
}
break;
case 3:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2]);
_buffFragment.Add(buff);
}
break;
case 4:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2], item[3]);
_buffFragment.Add(buff);
}
break;
}
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item);
_buffFragment.Add(buff);
}
}
@ -168,43 +135,9 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
var buffInfo = PropFragmentRegister.ConditionFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
switch (item.Length)
{
case 0:
{
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
_conditionFragment.Add(buff);
}
break;
case 1:
{
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0]);
_conditionFragment.Add(buff);
}
break;
case 2:
{
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1]);
_conditionFragment.Add(buff);
}
break;
case 3:
{
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2]);
_conditionFragment.Add(buff);
}
break;
case 4:
{
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2], item[3]);
_conditionFragment.Add(buff);
}
break;
}
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
buff.InitParam(item);
_conditionFragment.Add(buff);
}
}
@ -215,43 +148,9 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
var buffInfo = PropFragmentRegister.EffectFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
switch (item.Length)
{
case 0:
{
var buff = (EffectFragment)AddComponent(buffInfo.Type);
_effectFragment.Add(buff);
}
break;
case 1:
{
var buff = (EffectFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0]);
_effectFragment.Add(buff);
}
break;
case 2:
{
var buff = (EffectFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1]);
_effectFragment.Add(buff);
}
break;
case 3:
{
var buff = (EffectFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2]);
_effectFragment.Add(buff);
}
break;
case 4:
{
var buff = (EffectFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2], item[3]);
_effectFragment.Add(buff);
}
break;
}
var buff = (EffectFragment)AddComponent(buffInfo.Type);
buff.InitParam(item);
_effectFragment.Add(buff);
}
}
@ -262,43 +161,9 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
var buffInfo = PropFragmentRegister.ChargeFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
switch (item.Length)
{
case 0:
{
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
_chargeFragment.Add(buff);
}
break;
case 1:
{
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0]);
_chargeFragment.Add(buff);
}
break;
case 2:
{
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1]);
_chargeFragment.Add(buff);
}
break;
case 3:
{
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2]);
_chargeFragment.Add(buff);
}
break;
case 4:
{
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2], item[3]);
_chargeFragment.Add(buff);
}
break;
}
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
buff.InitParam(item);
_chargeFragment.Add(buff);
}
}
@ -626,70 +491,14 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
Master.ThrowActiveProp(PackageIndex);
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>() where T : BuffFragment, new()
public void AddBuffFragment<T>(JsonElement[] arg) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2, float arg3) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2, arg3);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2, arg3, arg4);
fragment.InitParam(arg);
if (Master != null)
{
fragment.OnPickUpItem();

View File

@ -1,6 +1,7 @@

using System;
using System.Collections.Generic;
using System.Text.Json;
using Config;
using Godot;
@ -30,43 +31,9 @@ public partial class BuffProp : PropActivity
{
var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
switch (item.Length)
{
case 0:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
_buffFragment.Add(buff);
}
break;
case 1:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0]);
_buffFragment.Add(buff);
}
break;
case 2:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1]);
_buffFragment.Add(buff);
}
break;
case 3:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2]);
_buffFragment.Add(buff);
}
break;
case 4:
{
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item[0], item[1], item[2], item[3]);
_buffFragment.Add(buff);
}
break;
}
var buff = (BuffFragment)AddComponent(buffInfo.Type);
buff.InitParam(item);
_buffFragment.Add(buff);
}
}
@ -92,70 +59,15 @@ public partial class BuffProp : PropActivity
buffFragment.OnRemoveItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>() where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1) where T : BuffFragment, new()
public void AddBuffFragment<T>(JsonElement[] arg) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2, float arg3) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2, arg3);
if (Master != null)
{
fragment.OnPickUpItem();
}
}
/// <summary>
/// 添加被动属性
/// </summary>
public void AddBuffFragment<T>(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new()
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
fragment.InitParam(arg1, arg2, arg3, arg4);
fragment.InitParam(arg);
if (Master != null)
{
fragment.OnPickUpItem();

View File

@ -1,4 +1,6 @@
using System.Text.Json;
/// <summary>
/// 道具逻辑片段组件
/// </summary>
@ -9,6 +11,11 @@ public abstract class PropFragment : Component<PropActivity>
/// </summary>
public Role Role => Master?.Master;
/// <summary>
/// 初始化被动属性参数
/// </summary>
public abstract void InitParam(JsonElement[] args);
/// <summary>
/// 当道具被拾起时调用 (在 Role 赋值之后调用)
/// </summary>
@ -26,36 +33,4 @@ public abstract class PropFragment : Component<PropActivity>
{
return Master != null;
}
/// <summary>
/// 初始化被动属性参数
/// </summary>
public virtual void InitParam(float arg1)
{
Debug.LogError($"'{GetType().FullName}'为实现1参数初始化函数!");
}
/// <summary>
/// 初始化被动属性参数
/// </summary>
public virtual void InitParam(float arg1, float arg2)
{
Debug.LogError($"'{GetType().FullName}'为实现2参数初始化函数!");
}
/// <summary>
/// 初始化被动属性参数
/// </summary>
public virtual void InitParam(float arg1, float arg2, float arg3)
{
Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!");
}
/// <summary>
/// 初始化被动属性参数
/// </summary>
public virtual void InitParam(float arg1, float arg2, float arg3, float arg4)
{
Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!");
}
}

View File

@ -1,12 +1,14 @@
using System.Text.Json;
[BuffFragment("ActivePropsCapacity", "主动道具背包容量 buff, 参数1为主动道具背包增加的容量")]
public class Buff_ActivePropsCapacity : BuffFragment
{
private int _value;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_value = (int)arg1;
_value = arg[0].GetInt32();
}
public override void OnPickUpItem()

View File

@ -1,12 +1,14 @@
using System.Text.Json;
[BuffFragment("BulletBounceCount", "子弹弹射数量 buff, 参数1为增加的弹射次数")]
public class Buff_BulletBounceCount : BuffFragment
{
private int _value;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_value = (int)arg1;
_value = arg[0].GetInt32();
}
public override void OnPickUpItem()

View File

@ -1,4 +1,5 @@
using System.Text.Json;
using Godot;
[BuffFragment("BulletCount",
@ -10,10 +11,10 @@ public class Buff_BulletCount : BuffFragment
private int _type;
private float _value;
public override void InitParam(float arg1, float arg2)
public override void InitParam(JsonElement[] arg)
{
_type = (int)arg1;
_value = (int)arg2;
_type = arg[0].GetInt32();
_value = arg[1].GetSingle();
}
public override void OnPickUpItem()

View File

@ -1,4 +1,5 @@
using System.Text.Json;
using Godot;
[BuffFragment("BulletDamage",
@ -10,10 +11,10 @@ public class Buff_BulletDamage : BuffFragment
private int _type;
private float _value;
public override void InitParam(float arg1, float arg2)
public override void InitParam(JsonElement[] arg)
{
_type = (int)arg1;
_value = arg2;
_type = arg[0].GetInt32();
_value = arg[1].GetSingle();
}
public override void OnPickUpItem()

View File

@ -1,13 +1,15 @@
using System.Text.Json;
[ChargeFragment("Hurt",
"造成伤害充能, 参数1为充满能量需要造成的伤害值")]
public class Cha_Hurt : ChargeFragment
{
private int _value = 100;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_value = (int)arg1;
_value = arg[0].GetInt32();
}
public override void OnUse()

View File

@ -1,4 +1,6 @@
using System.Text.Json;
[ConditionFragment("AmmoFull",
"判断当前武器弹药状态, " +
"参数1可选值: 0:判断非满弹药, 1:判断满弹药")]
@ -6,9 +8,9 @@ public class Cond_AmmoFull : ConditionFragment
{
private int _type;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_type = (int)arg1;
_type = arg[0].GetInt32();
}
public override bool OnCheckUse()

View File

@ -1,4 +1,6 @@
using System.Text.Json;
[ConditionFragment("HpFull",
"判断满血状态, " +
"参数1可选值: 0:判断非满血, 1:判断满血")]
@ -6,9 +8,9 @@ public class Cond_HpFull : ConditionFragment
{
private int _type;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_type = (int)arg1;
_type = arg[0].GetInt32();
}
public override bool OnCheckUse()

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Text.Json;
using Godot;
[EffectFragment("AreaTrigger",
@ -13,9 +14,9 @@ public class Eff_AreaTrigger : EffectFragment
private int _radius = 250;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_radius = (int)arg1;
_radius = arg[0].GetInt32();
}
public override void Ready()

View File

@ -1,12 +1,14 @@
using System.Text.Json;
[EffectFragment("Hp", "修改血量, 参数1为血量变化的具体值")]
public class Eff_Hp : EffectFragment
{
private int _value;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_value = (int) arg1;
_value = arg[0].GetInt32();
}
public override void OnUse()

View File

@ -1,4 +1,5 @@
using System.Text.Json;
using Godot;
[EffectFragment("PiggyBank", "存钱罐, 使用后返还存入的金币, 参数1为返还金币的倍率(小数)")]
@ -8,9 +9,9 @@ public class Eff_PiggyBank : EffectFragment
//当前存入的金币数量
private float _currValue;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] arg)
{
_value = arg1;
_value = arg[0].GetSingle();
}
public override bool OnCheckUse()

View File

@ -1,4 +1,6 @@
using System.Text.Json;
[EffectFragment("TotalAmmo",
"修改武器总弹药量, " +
"参数1(选填)为弹药变化的具体值, 如果不传则表示补满弹药")]
@ -7,10 +9,10 @@ public class Eff_TotalAmmo : EffectFragment
private bool _initParam = false;
private int _value;
public override void InitParam(float arg1)
public override void InitParam(JsonElement[] args)
{
_initParam = true;
_value = (int) arg1;
_value = args[0].GetInt32();
}
public override void OnUse()