From 6c7778309dfe0350819cd182d37dc6baee26177b 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: Sat, 6 Sep 2025 08:17:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E6=AD=A6=E5=99=A8=E6=8F=8F=E8=BF=B0=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为武器系统添加数据类型支持,包括数值、百分比和角度显示格式 添加debugRebuild选项用于编辑器调试 移除调试用的print语句 更新LGBT武器的场景配置和描述显示 --- components/Weapons/LGBT.tscn | 3 ++- scripts/Contents/Weapons/LGBTWeapon.gd | 1 + scripts/Contents/Weapons/PurpleCrystal.gd | 1 - scripts/Statemachine/EntityBase.gd | 1 - scripts/Structs/Weapon.gd | 23 ++++++++++++++++++++--- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/Weapons/LGBT.tscn b/components/Weapons/LGBT.tscn index 57d2c6a..2af53cd 100644 --- a/components/Weapons/LGBT.tscn +++ b/components/Weapons/LGBT.tscn @@ -18,6 +18,7 @@ store = { "power": 0.3, "trace": 2.0 } +storeType = Array[int]([0, 0, 1, 0]) descriptionTemplate = "发射$count条可追踪$trace秒,效率为$power的带状彩虹,每条造成$atk点伤害。" needEnergy = 150.0 @@ -33,5 +34,5 @@ quality = 4 [node name="description" parent="container" index="2"] size_flags_vertical = 3 -text = "[center]发射[color=cyan]7.0[/color]条可追踪[color=cyan]2.0[/color]秒,效率为[color=cyan]0.3[/color]的带状彩虹,每条造成[color=cyan]20.0[/color]点伤害。[/center]" +text = "[center]发射[color=cyan]7.0[/color]条可追踪[color=cyan]2.0[/color]秒,效率为[color=cyan]30.0%[/color]的带状彩虹,每条造成[color=cyan]20.0[/color]点伤害。[/center]" autowrap_mode = 2 diff --git a/scripts/Contents/Weapons/LGBTWeapon.gd b/scripts/Contents/Weapons/LGBTWeapon.gd index 0665395..b52f1f2 100644 --- a/scripts/Contents/Weapons/LGBTWeapon.gd +++ b/scripts/Contents/Weapons/LGBTWeapon.gd @@ -1,3 +1,4 @@ +@tool extends Weapon class_name LGBTWeapon diff --git a/scripts/Contents/Weapons/PurpleCrystal.gd b/scripts/Contents/Weapons/PurpleCrystal.gd index 472e9ba..692e2f1 100644 --- a/scripts/Contents/Weapons/PurpleCrystal.gd +++ b/scripts/Contents/Weapons/PurpleCrystal.gd @@ -7,5 +7,4 @@ func update(to: int, origin: Dictionary, _entity: EntityBase): func attack(entity: EntityBase): var weaponPos = entity.findWeaponAnchor("normal") BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), entity, weaponPos, (get_global_mouse_position() - weaponPos).angle()) - print("test2") return true diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index aa55a99..db0867d 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -211,7 +211,6 @@ func tryAttack(type: int, needChargeUp: bool = false): var done if isPlayer(): done = weapon.attack(self) - print("test", done, weapon.name) else: done = attack(type) if done: diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 49217d7..df9d194 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -13,9 +13,13 @@ signal selected(applied: bool) @export var store: Dictionary = { "atk": 10 } +@export var storeType: Array[FieldStore.DataType] = [ + FieldStore.DataType.VALUE +] @export var descriptionTemplate: String = "造成$atk点伤害。" @export var needEnergy: float = 0 @export var cooldown: float = 100 +@export var debugRebuild: bool = false @onready var avatarRect: TextureRect = $"%avatar" @onready var nameLabel: WeaponName = $"%name" @@ -33,8 +37,10 @@ func _ready(): ) cooldownTimer.cooldown = cooldown rebuildInfo() -func _physics_process(_delta: float): - descriptionLabel.text = buildDescription() + debugRebuild = false # 只能在编辑器里打开 +func _physics_process(_delta): + if debugRebuild: + rebuildInfo() func allHad(entity: EntityBase) -> bool: var allHave = true @@ -66,6 +72,7 @@ func rebuildInfo(): nameLabel.quality = quality nameLabel.typeTopic = typeTopic energyLabel.text = "%.1f" % needEnergy + descriptionLabel.text = buildDescription() for i in costsBox.get_children(): i.queue_free() for i in range(min(costs.size(), costCounts.size())): @@ -77,8 +84,18 @@ func rebuildInfo(): costsBox.add_child(costShow) func buildDescription(): var result = descriptionTemplate + var i = 0 for key in store.keys(): - result = result.replace("$" + key, "[color=cyan]%.1f[/color]" % readStore(key)) + var data = store[key] + var type = storeType[i] + if type == FieldStore.DataType.VALUE: + data = "%.1f" % data + elif type == FieldStore.DataType.PERCENT: + data = ("%.1f" % (data * 100)) + "%" + elif type == FieldStore.DataType.ANGLE: + data = "%.1f°" % data + result = result.replace("$" + key, "[color=cyan]%s[/color]" % data) + i += 1 return "[center]%s[/center]" % result func readStore(key: String, default: Variant = null): return store.get(key, default)