From 12b815a6f3e5cc18ae285d3286cdb2d13eca3f43 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, 21 Sep 2025 22:36:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(ChainGun):=20=E4=B8=BA=E9=93=BE=E5=BC=8F?= =?UTF-8?q?=E6=9C=BA=E6=9E=AA=E6=B7=BB=E5=8A=A0=E5=AD=90=E5=BC=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=B1=9E=E6=80=A7=E5=B9=B6=E8=B0=83=E6=95=B4=E5=AD=90?= =?UTF-8?q?=E5=BC=B9=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改链式机枪的武器脚本、场景配置和子弹脚本,新增count属性控制子弹数量 子弹生成时根据count值调整位置分布,同时更新UI描述文本 --- components/Weapons/ChainGun.tscn | 10 ++++++++-- scripts/Contents/Bullets/ChainGun.gd | 11 ++++++++--- scripts/Contents/Weapons/ChainGun.gd | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/Weapons/ChainGun.tscn b/components/Weapons/ChainGun.tscn index 5763536..cf994f1 100644 --- a/components/Weapons/ChainGun.tscn +++ b/components/Weapons/ChainGun.tscn @@ -10,8 +10,14 @@ avatarTexture = ExtResource("2_ghn43") displayName = "链式机枪" costBeachball = 400 store = { -"atk": 5 +"atk": 5, +"count": 1 } +storeType = { +"atk": 1, +"count": 1 +} +descriptionTemplate = "发射$count个[b]微型水晶[/b],可造成$atk点伤害。" needEnergy = 1.0 cooldown = 66.0 @@ -28,4 +34,4 @@ text = "400" displayName = "链式机枪" [node name="description" parent="container" index="2"] -text = "[center]造成[color=cyan]4[/color]→[color=yellow]6[/color]点伤害。[/center]" +text = "[center]发射[color=cyan]2[/color]→[color=yellow]2[/color]个[b]微型水晶[/b],可造成[color=cyan]5[/color]→[color=yellow]7[/color]点伤害。[/center]" diff --git a/scripts/Contents/Bullets/ChainGun.gd b/scripts/Contents/Bullets/ChainGun.gd index 9d4b646..a30c2db 100644 --- a/scripts/Contents/Bullets/ChainGun.gd +++ b/scripts/Contents/Bullets/ChainGun.gd @@ -1,9 +1,14 @@ extends BulletBase +var count: int = 1 + @onready var anchor: Node2D = $"%anchor" func spawn(): - for i in BulletBase.generate(ComponentManager.getBullet("PurpleCrystalSmall"), launcher, anchor.global_position, rotation): - i.damage = damage + for j in count: + for i in BulletBase.generate(ComponentManager.getBullet("PurpleCrystalSmall"), launcher, anchor.global_position, rotation): + i.damage = damage + var dir = Vector2.from_angle(i.rotation).rotated(deg_to_rad(-90)) + i.global_position += dir * (count - j * 2) * 20 / 2 func ai(): - PresetBulletAI.lockLauncher(self, launcher, true) \ No newline at end of file + PresetBulletAI.lockLauncher(self, launcher, true) diff --git a/scripts/Contents/Weapons/ChainGun.gd b/scripts/Contents/Weapons/ChainGun.gd index 2322881..7fdb5b2 100644 --- a/scripts/Contents/Weapons/ChainGun.gd +++ b/scripts/Contents/Weapons/ChainGun.gd @@ -3,7 +3,9 @@ extends Weapon func update(to, origin, _entity): origin["atk"] += 2 * to * soulLevel + origin["count"] += 0.25 * to * soulLevel return origin func attack(entity: EntityBase): for i in BulletBase.generate(ComponentManager.getBullet("ChainGun"), entity, entity.texture.global_position, (get_global_mouse_position() - entity.texture.global_position).angle()): i.damage = readStore("atk") + i.count = floor(readStore("count"))