From 251cf715fbbc95c3f6e495fc01409cecbc0847a6 Mon Sep 17 00:00:00 2001 From: panw Date: Tue, 31 Mar 2026 15:19:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(game):=20=E7=A7=BB=E9=99=A4resolveForm?= =?UTF-8?q?ationTargetX=E4=BE=9D=E8=B5=96=E5=B9=B6=E5=86=85=E8=81=94?= =?UTF-8?q?=E9=98=B5=E5=9E=8B=E9=94=9A=E7=82=B9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简化阵型目标X坐标的计算逻辑,直接根据阵营使用预定义的锚点值,避免导入和调用额外的工具函数。 --- assets/script/game/hero/MoveComp.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 6d8e7ffa..869a30ad 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -3,7 +3,7 @@ import { HeroViewComp } from "./HeroViewComp"; import { HeroAttrsComp } from "./HeroAttrsComp"; import { smc } from "../common/SingletonModuleComp"; import { FacSet } from "../common/config/GameSet"; -import { HeroDisVal, HType, resolveFormationTargetX } from "../common/config/heroSet"; +import { HeroDisVal, HType } from "../common/config/heroSet"; import { BoxCollider2D, Node } from "cc"; @ecs.register('MoveComp') @@ -49,6 +49,8 @@ interface MoveFacConfig { export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { /** 近战判定射程(来自 heroSet) */ private readonly meleeAttackRange = HeroDisVal[HType.Melee]; + private readonly heroFrontAnchorX = -30; + private readonly monFrontAnchorX = 30; /** 常规同阵营横向最小间距 */ private readonly allySpacingX = 60; /** 纵向判定为同排的最大 Y 差 */ @@ -239,7 +241,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return a.eid - b.eid; }); const slotIndex = Math.max(0, laneAllies.findIndex(entity => entity === self)); - const frontAnchorX = resolveFormationTargetX(model.fac, HType.Melee); + const frontAnchorX = model.fac === FacSet.MON ? this.monFrontAnchorX : this.heroFrontAnchorX; const targetX = frontAnchorX - forwardDir * slotIndex * this.allySpacingX; return Math.max(moveMinX, Math.min(moveMaxX, targetX)); }