From e1298bfe96f84503d195d34dceff9387b70b22ce Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 30 Mar 2026 15:29:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(hero):=20=E8=B0=83=E6=95=B4=E8=BF=91?= =?UTF-8?q?=E6=88=98=E8=8B=B1=E9=9B=84=E6=94=BB=E5=87=BB=E8=B7=9D=E7=A6=BB?= =?UTF-8?q?=E5=B9=B6=E7=AE=80=E5=8C=96=E7=A7=BB=E5=8A=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 HeroDisVal 中近战英雄的攻击距离从 150 调整为 360,以改善战斗体验。 移除 `processMeleeLogic` 中的独立逻辑,改为复用 `processRangedFormationCombat` 方法,统一移动与攻击行为,提升代码可维护性。 --- assets/script/game/common/config/heroSet.ts | 2 +- assets/script/game/hero/MoveComp.ts | 23 +-------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 6d5698ef..95c246d1 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -26,7 +26,7 @@ export const FormationPointX = { } as const; export const HeroDisVal: Record = { - [HType.Melee]: 150, + [HType.Melee]: 360, [HType.Mid]: 400, [HType.Long]: 720, } diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 9c729b40..3aa74986 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -200,28 +200,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } private processMeleeLogic(e: ecs.Entity, move: MoveComp, view: HeroViewComp, model: HeroAttrsComp, enemy: HeroViewComp) { - const currentX = view.node.position.x; - const enemyX = enemy.node.position.x; - const dist = Math.abs(currentX - enemyX); - const maxRange = this.meleeAttackRange; - const minRange = Math.min(this.meleeMinEnemyDistanceX, maxRange); - - /** 近战目标点 = 敌人位置 - 朝向 * minRange,确保能贴近但不穿模 */ - move.direction = enemyX > currentX ? 1 : -1; - move.targetX = enemyX - move.direction * minRange; - - if (dist <= minRange) { - view.status_change("idle"); - model.is_atking = true; - } else if (dist <= maxRange) { - const speed = model.speed / 3; - this.moveEntity(view, move.direction, speed, move.targetX); - model.is_atking = true; - } else { - const speed = model.speed / 3; - this.moveEntity(view, move.direction, speed); - model.is_atking = true; - } + this.processRangedFormationCombat(move, view, model); } private processMidLogic(e: ecs.Entity, move: MoveComp, view: HeroViewComp, model: HeroAttrsComp, enemy: HeroViewComp) {