From 1071e87da6e1052d68964d6db033a9106825afda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sun, 10 May 2026 10:01:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AD=A6=E5=99=A8=E5=8D=87=E5=8D=8E=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现武器升华选项系统,允许为武器添加可选的强化效果。主要修改包括: 1. 新增 SublimateOption 类用于定义升华选项 2. 在 Weapon 类中添加 storeExtra 字典和相关方法用于存储额外属性 3. 为 Tree 武器实现具体的升华选项 4. 添加调试标记 debugRebuild --- components/Weapons/Tree.tscn | 1 + scripts/Contents/Weapons/Tree.gd | 15 +++++++++++++++ scripts/Structs/SublimateOption.gd | 15 +++++++++++++++ scripts/Structs/SublimateOption.gd.uid | 1 + scripts/Structs/Weapon.gd | 13 +++++++++++-- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 scripts/Structs/SublimateOption.gd create mode 100644 scripts/Structs/SublimateOption.gd.uid diff --git a/components/Weapons/Tree.tscn b/components/Weapons/Tree.tscn index 253229d..ecbfe7a 100644 --- a/components/Weapons/Tree.tscn +++ b/components/Weapons/Tree.tscn @@ -70,6 +70,7 @@ descriptionTemplate = "进行[b]格挡[/b],化解敌人的攻击。 sources = Array[String](["Nine Sols", "Terraria"]) tease = "卸劲反伤" cooldown = 250.0 +debugRebuild = true [node name="avatar" parent="container/info" parent_id_path=PackedInt32Array(1625294072) index="0" unique_id=1021985889] texture = ExtResource("3_nwamk") diff --git a/scripts/Contents/Weapons/Tree.gd b/scripts/Contents/Weapons/Tree.gd index f32bafa..3f31d60 100644 --- a/scripts/Contents/Weapons/Tree.gd +++ b/scripts/Contents/Weapons/Tree.gd @@ -1,6 +1,21 @@ @tool extends Weapon +func sublimateOptions() -> Array[SublimateOption]: + return [ + SublimateOption.new("健体·阳", "格挡次数+1", func(w: Weapon, _e): w.addStoreExtra("count", 1)), + SublimateOption.new("健体·阴", "气力上限+1", func(w: Weapon, _e): w.addStoreExtra("max", 1)), + SublimateOption.new("引气入体", "乾坤剑伤害+6", func(w: Weapon, _e): w.addStoreExtra("atk", 6)), + SublimateOption.new("献祭", "乾坤剑伤害-8,但弹反概率+4%", + func(w: Weapon, _e): + w.addStoreExtra("atk", -10) + w.addStoreExtra("rate", 0.05), + ), + SublimateOption.new("亏心", "扣除你的所有幸运,每点幸运增加1%弹反概率", + func(w: Weapon, e: EntityBase): + w.addStoreExtra("rate", e.fields[FieldStore.Entity.LUCK_VALUE]), + ), + ] func update(to: int, origin: Dictionary, _entity: EntityBase): origin["atk"] += 2 * to * soulLevel origin["count"] += 1 * (soulLevel - 1) diff --git a/scripts/Structs/SublimateOption.gd b/scripts/Structs/SublimateOption.gd new file mode 100644 index 0000000..6b75de2 --- /dev/null +++ b/scripts/Structs/SublimateOption.gd @@ -0,0 +1,15 @@ +class_name SublimateOption + +var displayName: String = "升华" +var description: String = "描述" +var executor: Callable = func(_weapon: Weapon, _entity: EntityBase): return + +func _init(displayNames: String, descriptions: String, executors: Callable): + displayName = displayNames + description = descriptions + executor = executors + +func apply(entity: EntityBase, index: int): + var weapon = entity.weapons[index] + if weapon is Weapon: + executor.call(weapon, entity) diff --git a/scripts/Structs/SublimateOption.gd.uid b/scripts/Structs/SublimateOption.gd.uid new file mode 100644 index 0000000..aa6ac5e --- /dev/null +++ b/scripts/Structs/SublimateOption.gd.uid @@ -0,0 +1 @@ +uid://8e7whqgtnl5w diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 20c96b3..9ce8ee7 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -54,6 +54,7 @@ var chargedTime: float = 0 var attackSpeed: float = 1 var looping: bool = false var autoUpdate: bool = false +var storeExtra: Dictionary = {} func _ready(): cooldownTimer = CooldownTimer.new() @@ -201,8 +202,8 @@ func buildDescription(showNext: bool = false) -> String: text = "[color=cyan]%s[/color]" % data result = result.replace("$" + key, text) return result -func readStore(key: String, default: Variant = null): - return store.get(key, default) +func readStore(key: String): + return store.get(key, 0) + readStoreExtra(key) func playSound(sound: String): var body = sounds.get_node_or_null(sound) if body is AudioStreamPlayer2D: @@ -241,8 +242,16 @@ func exitLoop(entity: EntityBase): if !looping: return looping = false loopExit(entity) +func addStoreExtra(key: String, value: float): + if !storeExtra.has(key): + storeExtra[key] = 0 + storeExtra[key] += value +func readStoreExtra(key: String): + return storeExtra.get(key, 0) # 抽象 +func sublimateOptions() -> Array[SublimateOption]: + return [] as Array[SublimateOption] func update(_to: int, origin: Dictionary, _entity: EntityBase): return origin func loopStart(_entity: EntityBase):