buff系统重构中

This commit is contained in:
小李xl 2024-03-15 13:41:42 +08:00
parent dc5519dcdc
commit d39385f7a1
11 changed files with 175 additions and 21 deletions

View File

@ -19,6 +19,7 @@ public static class BuffGenerator
{
try
{
var str = "";
var buffInfos = new Dictionary<string, BuffInfo>();
var types = typeof(BuffGenerator).Assembly.GetTypes();
//包含[BuffAttribute]特性
@ -35,6 +36,7 @@ public static class BuffGenerator
return false;
}
var buffInfo = new BuffInfo(attribute.BuffName, attribute.Description, type);
str += $"{buffInfo.Name}: {buffInfo.Description}\n";
buffInfos.Add(attribute.BuffName, buffInfo);
//判断重写参数情况
//1参数
@ -78,6 +80,8 @@ public static class BuffGenerator
}
GenerateCode(buffInfos);
GD.Print("-----------------------------");
GD.Print(str);
}
catch (Exception e)
{

View File

@ -471,7 +471,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0002.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0002.png",
"ShowInMapEditor": true
},
@ -485,7 +485,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0003.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0003.png",
"ShowInMapEditor": true
},
@ -499,7 +499,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0004.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0004.png",
"ShowInMapEditor": true
},
@ -513,7 +513,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0005.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0005.png",
"ShowInMapEditor": true
},
@ -527,7 +527,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0006.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0006.png",
"ShowInMapEditor": true
},
@ -541,7 +541,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0007.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0007.png",
"ShowInMapEditor": true
},
@ -555,7 +555,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0008.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0008.png",
"ShowInMapEditor": true
},
@ -569,7 +569,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0009.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0009.png",
"ShowInMapEditor": true
},
@ -597,7 +597,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0011.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0011.png",
"ShowInMapEditor": true
},
@ -611,7 +611,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0012.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0012.png",
"ShowInMapEditor": true
},
@ -625,7 +625,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0013.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0013.png",
"ShowInMapEditor": true
},
@ -639,7 +639,7 @@
"Details": "",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/buff/BuffProp0014.tscn",
"Prefab": "res://prefab/prop/BuffActivity.tscn",
"Icon": "res://resource/sprite/prop/buff/BuffProp0014.png",
"ShowInMapEditor": true
},

View File

@ -10,6 +10,100 @@
]
}
},
{
"Id": "0002",
"Remark": "\u5FC3\u4E4B\u5BB9\u5668",
"__Activity": "prop0002",
"IsActivity": false,
"Buff": {
"MaxHp": [
2
]
}
},
{
"Id": "0003",
"Remark": "\u62A4\u76FE",
"__Activity": "prop0003",
"IsActivity": false,
"Buff": {
"MaxShield": [
1
]
}
},
{
"Id": "0004",
"Remark": "\u62A4\u76FE\u8BA1\u65F6\u5668",
"__Activity": "prop0004",
"IsActivity": false,
"Buff": {
"ShieldRecoveryTime": [
2.5
]
}
},
{
"Id": "0005",
"Remark": "\u6740\u4F24\u5F39",
"__Activity": "prop0005",
"IsActivity": false,
"Buff": {
"Damage": [
2,
0.2
]
}
},
{
"Id": "0006",
"Remark": "\u7EA2\u5B9D\u77F3\u6212\u6307",
"__Activity": "prop0006",
"IsActivity": false,
"Buff": {
"WoundedInvincibleTime": [
2
]
}
},
{
"Id": "0007",
"Remark": "\u5907\u7528\u62A4\u76FE",
"__Activity": "prop0007",
"IsActivity": false,
"Buff": {
"OffsetInjury": [
0.15
]
}
},
{
"Id": "0008",
"Remark": "\u773C\u955C",
"__Activity": "prop0008",
"IsActivity": false,
"Buff": {
"Scattering": [
0.5
]
}
},
{
"Id": "0009",
"Remark": "\u9AD8\u901F\u5B50\u5F39",
"__Activity": "prop0009",
"IsActivity": false,
"Buff": {
"BulletSpeed": [
2,
0.25
],
"BulletDistance": [
2,
0.25
]
}
},
{
"Id": "0010",
"Remark": "\u5206\u88C2\u5B50\u5F39",
@ -37,5 +131,49 @@
0.05
]
}
},
{
"Id": "0011",
"Remark": "\u5F39\u5C04\u5B50\u5F39",
"__Activity": "prop0011",
"IsActivity": false,
"Buff": {
"BulletBounceCount": [
2
]
}
},
{
"Id": "0012",
"Remark": "\u7A7F\u900F\u5B50\u5F39",
"__Activity": "prop0012",
"IsActivity": false,
"Buff": {
"BulletPenetration": [
1
]
}
},
{
"Id": "0013",
"Remark": "\u6B66\u5668\u80CC\u5305",
"__Activity": "prop0013",
"IsActivity": false,
"Buff": {
"WeaponCapacity": [
1
]
}
},
{
"Id": "0014",
"Remark": "\u9053\u5177\u80CC\u5305",
"__Activity": "prop0014",
"IsActivity": false,
"Buff": {
"ActivePropsCapacity": [
1
]
}
}
]

View File

@ -477,7 +477,14 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
else
{
SpriteFrames spriteFrames = AnimatedSprite.SpriteFrames;
spriteFrames.SetFrame("default", 0, texture);
if (spriteFrames.GetFrameCount("default") > 0)
{
spriteFrames.SetFrame("default", 0, texture);
}
else
{
spriteFrames.AddFrame("default", texture);
}
}
AnimatedSprite.Play("default");

View File

@ -1,5 +1,8 @@
[Buff("BulletDistance", "子弹射程 buff, 参数1为射程增加类型: 1:具体射程, 2:百分比射程(小数), 参数2为子弹增加的射程值")]
[Buff("BulletDistance",
"子弹射程 buff, " +
"参数1为射程增加类型: 1:具体射程, 2:百分比射程(小数), " +
"参数2为子弹增加的射程值")]
public class Buff_BulletDistance : BuffFragment
{
private int _type;

View File

@ -3,8 +3,8 @@ using Godot;
[Buff("BulletRepel",
"子弹击退 buff, " +
"参数1为击退增加类型: 1:具体击退值, " +
"2:百分比击退值(小数), 参数2为子弹增加的击退值")]
"参数1为击退增加类型: 1:具体击退值, 2:百分比击退值(小数), " +
"参数2为子弹增加的击退值")]
public class Buff_BulletRepel : BuffFragment
{
private int _type;
@ -61,7 +61,7 @@ public class Buff_BulletRepel : BuffFragment
}
else
{
repel.Value = Mathf.Max(0, repel.Value - Mathf.FloorToInt(repel.Value * _value));
repel.Value = Mathf.Max(0, repel.Value + Mathf.FloorToInt(repel.Value * _value));
}
}
}

View File

@ -53,7 +53,7 @@ public class Buff_Damage : BuffFragment
}
else
{
refValue.Value = Mathf.Max(1, refValue.Value - Mathf.FloorToInt(refValue.Value * _value));
refValue.Value = Mathf.Max(1, refValue.Value + Mathf.FloorToInt(refValue.Value * _value));
}
}
}

View File

@ -1,4 +1,6 @@
using Godot;
[Buff("Scattering", "提高武器精准度buff, 参数1为提升的精准度百分比值(小数)")]
public class Buff_Scattering : BuffFragment
{
@ -23,11 +25,11 @@ public class Buff_Scattering : BuffFragment
private void CalcStartScatteringEvent(float originValue, RefValue<float> refValue)
{
refValue.Value -= refValue.Value * _value;
refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value);
}
private void CalcFinalScatteringEvent(float originValue, RefValue<float> refValue)
{
refValue.Value -= refValue.Value * _value;
refValue.Value = Mathf.Max(0, refValue.Value - refValue.Value * _value);
}
}

View File

@ -1,5 +1,5 @@
[Buff("ShieldRecoveryTime", "单格护盾恢复时间, 参数1单位: 秒")]
[Buff("ShieldRecoveryTime", "单格护盾减少的恢复时间, 参数1单位: 秒")]
public class Buff_ShieldRecoveryTime : BuffFragment
{
private float _time;