From 33e675896568ef95a885201ca6bac9429c177d64 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, 23 Nov 2025 06:51:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Bullet):=20=E7=A7=BB=E9=99=A4ChickSpri?= =?UTF-8?q?nt=E7=9A=84atk=E5=8F=98=E9=87=8F=E5=B9=B6=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E4=BC=A4=E5=AE=B3=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整Cat角色的攻击冷却时间和冲刺倍数 为BulletBase添加speedScale属性和setupCuttable方法 将Volcano的animator速度设置移至ai方法并应用speedScale --- scripts/Contents/Bullets/ChickSprint.gd | 4 +--- scripts/Contents/Bullets/Volcano.gd | 3 ++- scripts/Contents/Characters/Cat.gd | 8 +++----- scripts/Statemachine/BulletBase.gd | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/Contents/Bullets/ChickSprint.gd b/scripts/Contents/Bullets/ChickSprint.gd index 7b8115a..461313a 100644 --- a/scripts/Contents/Bullets/ChickSprint.gd +++ b/scripts/Contents/Bullets/ChickSprint.gd @@ -1,13 +1,11 @@ extends BulletBase class_name ChickSprint -var atk: float = 1 - func register(): speed = 0 penerate = 1 func ai(): - baseDamage = launcher.velocity.length() / 500.0 * atk + baseDamage = launcher.velocity.length() / 500.0 PresetBulletAI.lockLauncher(self, launcher, true) if !launcher.sprinting: tryDestroy() diff --git a/scripts/Contents/Bullets/Volcano.gd b/scripts/Contents/Bullets/Volcano.gd index a4356b6..ac2d6ec 100644 --- a/scripts/Contents/Bullets/Volcano.gd +++ b/scripts/Contents/Bullets/Volcano.gd @@ -10,8 +10,9 @@ var dmg5: float = 0 var splitAngle: float = 10 func register(): - animator.speed_scale = launcher.fields.get(FieldStore.Entity.ATTACK_SPEED) + setupCuttable(0.1) func ai(): + animator.speed_scale = launcher.fields.get(FieldStore.Entity.ATTACK_SPEED) * speedScale PresetBulletAI.lockLauncher(self, launcher, true) rotation = lerp_angle( rotation, diff --git a/scripts/Contents/Characters/Cat.gd b/scripts/Contents/Characters/Cat.gd index c7c461a..9a884e4 100644 --- a/scripts/Contents/Characters/Cat.gd +++ b/scripts/Contents/Characters/Cat.gd @@ -4,16 +4,14 @@ class_name Maodie func register(): fields[FieldStore.Entity.MAX_HEALTH] = 75 fields[FieldStore.Entity.MOVEMENT_SPEED] = randf_range(0.5, 0.8) - attackCooldownMap[0] = randi_range(2500, 6000) - sprintMultiplier = randf_range(10, 35) + attackCooldownMap[0] = randi_range(5000, 8000) + sprintMultiplier = randf_range(5, 15) func ai(): PresetEntityAI.follow(self, currentFocusedBoss) tryAttack(0, true) func attack(type: int): if type == 0: - for bullet in BulletBase.generate(ComponentManager.getBullet("ChickSprint"), self, position, 0): - if bullet is ChickSprint: - bullet.atk = 0.01 + BulletBase.generate(ComponentManager.getBullet("ChickSprint"), self, position, 0) trySprint() return true func sprint(): diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 2f9f465..fc4c6cc 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -33,6 +33,7 @@ var isChildSplit: bool = false var isChildRefract: bool = false var initialSpeed: float = 0 var initialDamage: float = 0 +var speedScale: float = 1 func _ready(): initialSpeed = speed @@ -86,6 +87,19 @@ func _physics_process(_delta: float) -> void: else: tryDestroy() +func setupCuttable(cutSpeed: float): + body_entered.connect( + func(body): + var entity = EntityTool.fromHurtbox(body) + if entity: + speedScale = cutSpeed + ) + body_exited.connect( + func(body): + var entity = EntityTool.fromHurtbox(body) + if entity: + speedScale = 1 + ) func getDamage(): return initialDamage * damageMultipliers[usingDamageMultiplier] func hit(target: Node):