From 762dc91a11278bceb87edf81b09fa570a516cc79 Mon Sep 17 00:00:00 2001 From: pan Date: Wed, 12 Aug 2026 11:16:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(hero&move):=20=E8=B0=83=E6=95=B4=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E5=9F=BA=E7=A1=80=E7=A7=BB=E9=80=9F=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=BF=91=E6=88=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将默认移速从800改为100,重构近战战斗移动逻辑: 1. 增加敌人存在校验,无敌人时恢复原编队战斗逻辑 2. 新增近战接触距离常量,让英雄贴近敌人后再停下攻击 3. 优化移动速度和停止位置计算,确保近战贴脸输出 --- assets/script/game/hero/Hero.ts | 2 +- assets/script/game/hero/MoveComp.ts | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 99f62d72..e2e5c635 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -156,7 +156,7 @@ export class Hero extends ecs.Entity { model.hp = model.hp_max = base_hp; } - model.speed = hero.speed ?? 800; + model.speed = hero.speed ?? 100; // 构建技能表并注入运行时冷却字段 ccd model.skills = {}; diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 7d7308aa..025c766f 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -200,8 +200,33 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } } + /** + * 近战交战:有怪物时向右推进,贴近到固定接触距离后停下攻击。 + * Why: 近战手短需主动逼近;停止判定用固定接触距离(非攻击距离 dis), + * 使英雄进入攻击范围后仍继续贴近,直到贴上目标才站稳输出。 + * 怪物 y 与英雄同在 GAME_LINE 附近(微调也在攻击范围内),无需管 Y 轴。 + */ private processMeleeLogic(e: ecs.Entity, move: MoveComp, view: HeroViewComp, model: HeroAttrsComp, enemy: HeroViewComp) { - this.processFormationCombat(e, move, view, model); + if (!enemy?.node) { + this.processFormationCombat(e, move, view, model); + return; + } + const selfX = view.node.position.x; + const enemyX = enemy.node.position.x; + const dist = Math.abs(selfX - enemyX); + // 已贴近到固定接触距离:停下攻击 + if (dist <= MoveSystem.MELEE_ENGAGE_X) { + model.is_atking = true; + if (view.status !== "atk") view.status_change("idle"); + return; + } + // 未贴近:向怪物方向推进(攻击范围内也继续移动),于接触距离处停下 + const dir = enemyX > selfX ? 1 : -1; + move.direction = dir; + const stopX = enemyX - dir * MoveSystem.MELEE_ENGAGE_X; + const speed = model.speed / 3; + this.moveEntity(view, dir, speed, stopX); + model.is_atking = false; } private processMidLogic(e: ecs.Entity, move: MoveComp, view: HeroViewComp, model: HeroAttrsComp, enemy: HeroViewComp) { @@ -263,6 +288,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate private static readonly FORMATION_RIGHT_X = 100; /** 固定步进间距(人数较少时按此从左侧逐位右排) */ private static readonly FORMATION_STEP_X = 60; + /** 近战贴近怪物的固定接触距离:小于攻击距离 dis,使英雄进攻击范围后仍继续贴近到此间距才停 */ + private static readonly MELEE_ENGAGE_X = 60; /** * 计算某个槽位的目标 X。