From 5c2c29fdcbf4baaf64b8a5f2f657ab9cf8b5481b 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, 20 Sep 2025 17:23:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=AD=A6=E5=99=A8=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=92=8C=E6=8F=8F=E8=BF=B0=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改武器升级计算公式,将指数运算改为线性运算以提高性能 在武器描述中显示当前值和升级后的值 调整costBeachball的默认值从500改为100 --- components/Abstracts/WeaponCardBase.tscn | 1 + scripts/Contents/Weapons/BigLaser.gd | 2 +- scripts/Contents/Weapons/LGBTWeapon.gd | 2 +- scripts/Contents/Weapons/VectorStarWeapon.gd | 4 +-- scripts/Structs/Weapon.gd | 30 +++++++++++++------- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/components/Abstracts/WeaponCardBase.tscn b/components/Abstracts/WeaponCardBase.tscn index 4066261..41f3f0a 100644 --- a/components/Abstracts/WeaponCardBase.tscn +++ b/components/Abstracts/WeaponCardBase.tscn @@ -29,6 +29,7 @@ offset_right = 350.0 offset_bottom = 304.0 theme_override_styles/panel = SubResource("StyleBoxFlat_n2ewr") script = ExtResource("1_g802t") +costBeachball = 500 metadata/_edit_lock_ = true [node name="sounds" type="Node2D" parent="."] diff --git a/scripts/Contents/Weapons/BigLaser.gd b/scripts/Contents/Weapons/BigLaser.gd index 7b21d51..e226881 100644 --- a/scripts/Contents/Weapons/BigLaser.gd +++ b/scripts/Contents/Weapons/BigLaser.gd @@ -4,7 +4,7 @@ class_name BigLaserWeapon func update(to: int, origin: Dictionary, _entity: EntityBase): origin["atk"] += 5 * to * soulLevel - origin["time"] /= 1.05 ** soulLevel * to + origin["time"] /= 1 + 0.05 * to * soulLevel return origin func attack(entity: EntityBase): var weaponPos = entity.findWeaponAnchor("normal") diff --git a/scripts/Contents/Weapons/LGBTWeapon.gd b/scripts/Contents/Weapons/LGBTWeapon.gd index d59ff72..09f21b1 100644 --- a/scripts/Contents/Weapons/LGBTWeapon.gd +++ b/scripts/Contents/Weapons/LGBTWeapon.gd @@ -7,7 +7,7 @@ func update(to: int, origin: Dictionary, _entity: EntityBase): origin["count"] += to * soulLevel origin["power"] += 0.05 * to * soulLevel origin["trace"] += 0.25 * to * soulLevel - origin["angle"] /= 1.05 ** soulLevel * to + origin["angle"] /= 1 + 0.05 * to * soulLevel return origin func attack(entity: EntityBase): var weaponPos = entity.findWeaponAnchor("normal") diff --git a/scripts/Contents/Weapons/VectorStarWeapon.gd b/scripts/Contents/Weapons/VectorStarWeapon.gd index b74b1cf..cb6dcc9 100644 --- a/scripts/Contents/Weapons/VectorStarWeapon.gd +++ b/scripts/Contents/Weapons/VectorStarWeapon.gd @@ -4,8 +4,8 @@ class_name VectorStarWeapon func update(to: int, origin: Dictionary, _entity: EntityBase): origin["atk"] += 5 * to * soulLevel - origin["forwardtime"] /= 1.05 ** soulLevel * to - origin["maxcount"] += 1 * level * soulLevel + origin["forwardtime"] /= 1 + 0.05 * to * soulLevel + origin["maxcount"] += 1 * to * soulLevel return origin func attack(entity: EntityBase): var weaponPos = entity.findWeaponAnchor("normal") diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 678cd7a..e16ebe2 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -7,7 +7,7 @@ class_name Weapon @export var quality: WeaponName.Quality = WeaponName.Quality.COMMON @export var typeTopic: WeaponName.TypeTopic = WeaponName.TypeTopic.IMPACT @export var soulLevel: int = 1 -@export var costBeachball: int = 500 +@export var costBeachball: int = 100 @export var store: Dictionary = { "atk": 10 } @@ -100,20 +100,28 @@ func rebuildInfo(): beachballLabel.text = str(costBeachball) soulLabel.text = str(soulLevel) descriptionLabel.text = buildDescription() +func formatValue(value: Variant, type: FieldStore.DataType) -> String: + if type == FieldStore.DataType.VALUE: + return "%.2f" % value + elif type == FieldStore.DataType.INTEGER: + return "%d" % value + elif type == FieldStore.DataType.PERCENT: + return ("%d" % (value * 100)) + "%" + elif type == FieldStore.DataType.ANGLE: + return "%.1f°" % value + else: + return str(value) func buildDescription() -> String: + var current = store + var next = update(level + 1, originalStore.duplicate(), UIState.player) var result = descriptionTemplate for key in store.keys(): - var data = store[key] + var data = current[key] + var nextData = next[key] var type = storeType.get(key, FieldStore.DataType.VALUE) - if type == FieldStore.DataType.VALUE: - data = "%.2f" % data - elif type == FieldStore.DataType.INTEGER: - data = "%d" % data - elif type == FieldStore.DataType.PERCENT: - data = ("%d" % (data * 100)) + "%" - elif type == FieldStore.DataType.ANGLE: - data = "%.1f°" % data - result = result.replace("$" + key, "[color=cyan]%s[/color]" % data) + data = formatValue(data, type) + nextData = formatValue(nextData, type) + result = result.replace("$" + key, "[color=cyan]%s[/color]→[color=yellow]%s[/color]" % [data, nextData]) return "[center]%s[/center]" % result func readStore(key: String, default: Variant = null): return store.get(key, default)