解决编译错误

This commit is contained in:
小李xl 2024-03-20 18:03:40 +08:00
parent f611eddc19
commit 03e3d2be3e
18 changed files with 124 additions and 47 deletions

View File

@ -123,7 +123,14 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
var buffInfo = PropFragmentRegister.BuffFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
var buff = (BuffFragment)AddComponent(buffInfo.Type);
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<Role>
var buffInfo = PropFragmentRegister.ConditionFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
var buff = (ConditionFragment)AddComponent(buffInfo.Type);
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<Role>
var buffInfo = PropFragmentRegister.EffectFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
var buff = (EffectFragment)AddComponent(buffInfo.Type);
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<Role>
var buffInfo = PropFragmentRegister.ChargeFragmentInfos[keyValuePair.Key];
var item = keyValuePair.Value;
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
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<Role>
{
var fragment = AddComponent<T>();
_buffFragment.Add(fragment);
try
{
fragment.InitParam(arg);
}
catch (Exception e)
{
Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}");
}
if (Master != null)
{
fragment.OnPickUpItem();

View File

@ -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);
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<T>();
_buffFragment.Add(fragment);
try
{
fragment.InitParam(arg);
}
catch (Exception e)
{
Debug.LogError($"初始化道具'{ActivityBase.Id}'参数时发生异常: {e.Message}\n{e.StackTrace}");
}
if (Master != null)
{
fragment.OnPickUpItem();

View File

@ -1,4 +1,6 @@
using System.Text.Json;
[BuffFragment("BulletDeviationAngle",
"子弹偏移角度 buff, " +
"参数1为增加子弹偏移角度下限, " +
@ -8,10 +10,10 @@ 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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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<ulong> _cacheId = new List<ulong>();
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()

View File

@ -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<ulong> _cacheId = new List<ulong>();
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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -10,10 +10,13 @@ public class Eff_TotalAmmo : EffectFragment
private int _value;
public override void InitParam(JsonElement[] args)
{
if (args.Length > 0)
{
_initParam = true;
_value = args[0].GetInt32();
}
}
public override void OnUse()
{