diff --git a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs index f3493368..830eb27e 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs @@ -123,7 +123,14 @@ public partial class ActiveProp : PropActivity, IPackageItem var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; var buff = (BuffFragment)AddComponent(buffInfo.Type); - buff.InitParam(item); + try + { + buff.InitParam(item); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } _buffFragment.Add(buff); } } @@ -136,7 +143,14 @@ public partial class ActiveProp : PropActivity, IPackageItem var buffInfo = PropFragmentRegister.ConditionFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; var buff = (ConditionFragment)AddComponent(buffInfo.Type); - buff.InitParam(item); + try + { + buff.InitParam(item); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } _conditionFragment.Add(buff); } } @@ -149,7 +163,14 @@ public partial class ActiveProp : PropActivity, IPackageItem var buffInfo = PropFragmentRegister.EffectFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; var buff = (EffectFragment)AddComponent(buffInfo.Type); - buff.InitParam(item); + try + { + buff.InitParam(item); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } _effectFragment.Add(buff); } } @@ -162,7 +183,14 @@ public partial class ActiveProp : PropActivity, IPackageItem var buffInfo = PropFragmentRegister.ChargeFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; var buff = (ChargeFragment)AddComponent(buffInfo.Type); - buff.InitParam(item); + try + { + buff.InitParam(item); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } _chargeFragment.Add(buff); } } @@ -498,7 +526,14 @@ public partial class ActiveProp : PropActivity, IPackageItem { var fragment = AddComponent(); _buffFragment.Add(fragment); - fragment.InitParam(arg); + try + { + fragment.InitParam(arg); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } if (Master != null) { fragment.OnPickUpItem(); diff --git a/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs b/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs index bbbbafe5..b1d3b55c 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/BuffProp.cs @@ -32,7 +32,14 @@ public partial class BuffProp : PropActivity var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key]; var item = keyValuePair.Value; var buff = (BuffFragment)AddComponent(buffInfo.Type); - buff.InitParam(item); + try + { + buff.InitParam(item); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } _buffFragment.Add(buff); } } @@ -67,7 +74,14 @@ public partial class BuffProp : PropActivity { var fragment = AddComponent(); _buffFragment.Add(fragment); - fragment.InitParam(arg); + try + { + fragment.InitParam(arg); + } + catch (Exception e) + { + Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}"); + } if (Master != null) { fragment.OnPickUpItem(); diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs index fe3f7bb3..99288776 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDeviationAngle.cs @@ -1,4 +1,6 @@ +using System.Text.Json; + [BuffFragment("BulletDeviationAngle", "子弹偏移角度 buff, " + "参数‘1’为增加子弹偏移角度下限, " + @@ -7,13 +9,13 @@ public class Buff_BulletDeviationAngle : BuffFragment { private float _min; private float _max; - - public override void InitParam(float arg1, float arg2) + + public override void InitParam(JsonElement[] args) { - _min = arg1; - _max = arg2; + _min = args[0].GetSingle(); + _max = args[1].GetSingle(); } - + public override void OnPickUpItem() { Role.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent; diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs index 595022b1..bf75520d 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletDistance.cs @@ -1,4 +1,6 @@ +using System.Text.Json; + [BuffFragment("BulletDistance", "子弹射程 buff, " + "参数‘1’为射程增加类型: 1:具体射程, 2:百分比射程(小数), " + @@ -8,10 +10,10 @@ public class Buff_BulletDistance : BuffFragment private int _type; private float _value; - public override void InitParam(float arg1, float arg2) + public override void InitParam(JsonElement[] args) { - _type = (int)arg1; - _value = arg2; + _type = args[0].GetInt32(); + _value = args[1].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs index eb0732f4..600c7b6f 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletPenetration.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("BulletPenetration", "子弹穿透次数 buff, 参数‘1’为增加的穿透次数")] public class Buff_BulletPenetration : BuffFragment { private int _value; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _value = (int)arg1; + _value = args[0].GetInt32(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs index 9e711f61..e6711c0d 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletRepel.cs @@ -1,4 +1,5 @@ +using System.Text.Json; using Godot; [BuffFragment("BulletRepel", @@ -9,10 +10,10 @@ public class Buff_BulletRepel : BuffFragment { private int _type; private float _value; - public override void InitParam(float arg1, float arg2) + public override void InitParam(JsonElement[] args) { - _type = (int)arg1; - _value = arg2; + _type = args[0].GetInt32(); + _value = args[1].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs index a8c9ffab..1a4994a2 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_BulletSpeed.cs @@ -1,4 +1,6 @@ +using System.Text.Json; + [BuffFragment("BulletSpeed", "子弹速度 buff, " + "参数‘1’为射速增加类型: 1:具体射速, 2:百分比射速(小数), " + @@ -8,10 +10,10 @@ public class Buff_BulletSpeed : BuffFragment private int _type; private float _value; - public override void InitParam(float arg1, float arg2) + public override void InitParam(JsonElement[] args) { - _type = (int)arg1; - _value = arg2; + _type = args[0].GetInt32(); + _value = args[1].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_GetGold.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_GetGold.cs index d3cff87e..a5fe5d0a 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_GetGold.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_GetGold.cs @@ -1,4 +1,5 @@ +using System.Text.Json; using Godot; [BuffFragment("GetGold", "计算获取的金币buff, " + @@ -9,10 +10,10 @@ public class Buff_GetGold : BuffFragment private int _type; private float _value; - public override void InitParam(float arg1, float arg2) + public override void InitParam(JsonElement[] args) { - _type = (int)arg1; - _value = arg2; + _type = args[0].GetInt32(); + _value = args[1].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs index 8e7a107b..5f0ae1b5 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxHp.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; +using System.Text.Json; [BuffFragment("MaxHp", "血量上限 buff, 参数‘1’为血量上限值")] public class Buff_MaxHp : BuffFragment @@ -7,9 +8,9 @@ public class Buff_MaxHp : BuffFragment private List _cacheId = new List(); private int _maxHp; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _maxHp = (int)arg1; + _maxHp = args[0].GetInt32(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs index 20ade21b..aac29fa5 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MaxShield.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; +using System.Text.Json; [BuffFragment("MaxShield", "护盾上限buff, 参数‘1’为护盾上限")] public class Buff_MaxShield : BuffFragment @@ -7,9 +8,9 @@ public class Buff_MaxShield : BuffFragment private List _cacheId = new List(); private int _maxShield; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _maxShield = (int)arg1; + _maxShield = args[0].GetInt32(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs index e528c471..f4ae7eff 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_MoveSpeed.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("MoveSpeed", "移速 buff, 参数‘1’为移动速度值")] public class Buff_MoveSpeed : BuffFragment { private float _moveSpeed; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _moveSpeed = arg1; + _moveSpeed = args[0].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs index 008abe09..01dcee8b 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_OffsetInjury.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("OffsetInjury", "受伤时有概率抵消伤害的buff, 参数‘1’为抵消伤害概率百分比(小数)")] public class Buff_OffsetInjury : BuffFragment { private float _value; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _value = arg1; + _value = args[0].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs index c2d1ab0e..52ab6467 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_RandomBulletSpeed.cs @@ -1,4 +1,6 @@ +using System.Text.Json; + [BuffFragment("RandomBulletSpeed", "子弹增加随机速度 buff, " + "参数‘1’为增加子弹速度下限, " + @@ -8,10 +10,10 @@ public class Buff_RandomBulletSpeed : BuffFragment private float _min; private float _max; - public override void InitParam(float arg1, float arg2) + public override void InitParam(JsonElement[] args) { - _min = arg1; - _max = arg2; + _min = args[0].GetSingle(); + _max = args[1].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs index edee9258..0149164f 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_Scattering.cs @@ -1,4 +1,5 @@ +using System.Text.Json; using Godot; [BuffFragment("Scattering", "提高武器精准度buff, 参数‘1’为提升的精准度百分比值(小数)")] @@ -6,9 +7,9 @@ public class Buff_Scattering : BuffFragment { private float _value; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _value = arg1; + _value = args[0].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs index 88bb3dff..ffde4922 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_ShieldRecoveryTime.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数‘1’单位: 秒")] public class Buff_ShieldRecoveryTime : BuffFragment { private float _time; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _time = arg1; + _time = args[0].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs index 10b986a8..8e45113e 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WeaponCapacity.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("WeaponCapacity", "武器背包容量 buff, 参数‘1’为武器背包增加的容量")] public class Buff_WeaponCapacity : BuffFragment { private int _value; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _value = (int)arg1; + _value = args[0].GetInt32(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs index 27b84caf..07dfe398 100644 --- a/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs +++ b/DungeonShooting_Godot/src/game/buff/buff/Buff_WoundedInvincibleTime.cs @@ -1,12 +1,14 @@ +using System.Text.Json; + [BuffFragment("WoundedInvincibleTime", "延长无敌时间buff, 参数‘1’为延长时间, 单位秒")] public class Buff_WoundedInvincibleTime : BuffFragment { private float _time; - public override void InitParam(float arg1) + public override void InitParam(JsonElement[] args) { - _time = arg1; + _time = args[0].GetSingle(); } public override void OnPickUpItem() diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs index bbd99b86..6964de88 100644 --- a/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_TotalAmmo.cs @@ -11,8 +11,11 @@ public class Eff_TotalAmmo : EffectFragment public override void InitParam(JsonElement[] args) { - _initParam = true; - _value = args[0].GetInt32(); + if (args.Length > 0) + { + _initParam = true; + _value = args[0].GetInt32(); + } } public override void OnUse()