From b1de068892b670edbe8cecf55bcc50fa977d63a6 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: Mon, 8 Sep 2025 22:27:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor(EntityBase):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=A1=BA=E5=BA=8F=E4=BB=A5=E6=8F=90=E9=AB=98?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将getSprintInitialDisplace和getSprintProgress方法移动到move方法附近,使相关功能代码更集中 --- scripts/Statemachine/EntityBase.gd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 7dac41c..678aca6 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -160,10 +160,6 @@ func _physics_process(_delta: float) -> void: trailParticle.emitting = trailing # 通用方法 -func getSprintInitialDisplace(): - return displace(velocity) * sprintMultiplier -func getSprintProgress(): - return velocity.length() / getSprintInitialDisplace().length() func applyLevel(): fields[FieldStore.Entity.MAX_HEALTH] *= (1 + GameRule.entityHealthIncreasePerWave * (GameRule.difficulty + 1)) ** level fields[FieldStore.Entity.DAMAGE_MULTIPILER] *= (1 + GameRule.entityDamageIncreasePerWave * (GameRule.difficulty + 1)) ** level @@ -174,6 +170,10 @@ func move(direction: Vector2, isSprinting: bool = false): var currentDirection = sign(direction.x) if currentDirection != 0: lastDirection = currentDirection +func getSprintInitialDisplace(): + return displace(velocity) * sprintMultiplier +func getSprintProgress(): + return velocity.length() / getSprintInitialDisplace().length() func takeDamage(bullet: BulletBase, crit: bool): hurtAnimator.play("hurt") var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)