From 426fcec5c49a4b998fa0de714c9fab17aebcd20c Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 15 Mar 2026 21:47:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=88=98=E6=96=97):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=BF=91=E6=88=98=E6=94=BB=E5=87=BB=E7=8A=B6=E6=80=81=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在移动系统中,当英雄进入攻击范围时,应将 is_atking 设置为 true 以正确触发攻击状态。同时优化攻击范围计算,使用 minSpacingX 作为最大范围基准,并确保最小范围不超过最大范围减一,避免逻辑矛盾。 --- assets/script/game/hero/MoveComp.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 6a7e4787..a321644a 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -128,7 +128,9 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate const currentX = view.node.position.x; const enemyX = enemy.node.position.x; const dist = Math.abs(currentX - enemyX); - const [minRange, maxRange] = this.resolveCombatRange(model, 0, 75); + const [rawMinRange] = this.resolveCombatRange(model, 0, this.minSpacingX); + const maxRange = this.minSpacingX; + const minRange = Math.min(rawMinRange, Math.max(0, maxRange - 1)); move.direction = enemyX > currentX ? 1 : -1; @@ -140,7 +142,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } else { const speed = model.speed / 3; this.moveEntity(view, move.direction, speed); - model.is_atking = false; + model.is_atking = true; } } @@ -159,7 +161,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } else if (dist > maxRange) { const speed = model.speed / 3; this.moveEntity(view, move.direction, speed); - model.is_atking = false; + model.is_atking = true; } else { view.status_change("idle"); model.is_atking = true; @@ -181,7 +183,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } else if (dist > maxRange) { const speed = model.speed / 3; this.moveEntity(view, move.direction, speed); - model.is_atking = false; + model.is_atking = true; } else { view.status_change("idle"); model.is_atking = true;