From acaa6125c2a079d4fb1230414f676e0cbe4c9475 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 16 Mar 2026 15:20:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=A7=BB=E5=8A=A8):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E6=88=98=E6=96=97=E4=BC=98=E5=85=88=E7=BA=A7=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=90=8C=E9=98=B5=E8=90=A5=E8=8B=B1=E9=9B=84=E7=9A=84=E6=A8=AA?= =?UTF-8?q?=E5=90=91=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在clampXByAllies方法中增加战斗优先级判断,高优先级英雄不会因低优先级盟友而调整横向位置。新增getCombatPriority方法根据英雄类型和射程类型计算优先级,近战>中程>远程。 --- assets/script/game/hero/MoveComp.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index 271d95ed..01fab085 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -267,6 +267,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } private clampXByAllies(self: ecs.Entity, fac: number, baseY: number, currentX: number, proposedX: number, direction: number): number { + const selfAttrs = self.get(HeroAttrsComp); + const selfPriority = selfAttrs ? this.getCombatPriority(selfAttrs) : 0; let nearestAheadX = Infinity; let nearestBehindX = -Infinity; ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp, MoveComp)).forEach(e => { @@ -276,6 +278,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (!attrs || !view?.node || attrs.is_dead) return; if (attrs.fac !== fac) return; if (Math.abs(view.node.position.y - baseY) >= this.minSpacingY) return; + const allyPriority = this.getCombatPriority(attrs); + if (allyPriority < selfPriority) return; const x = view.node.position.x; if (x > currentX && x < nearestAheadX) nearestAheadX = x; if (x < currentX && x > nearestBehindX) nearestBehindX = x; @@ -290,6 +294,22 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return proposedX; } + private getCombatPriority(model: HeroAttrsComp): number { + let rangeType = model.rangeType; + if (rangeType === undefined || rangeType === null) { + if (model.type === HType.warrior || model.type === HType.assassin) { + rangeType = SkillRange.Melee; + } else if (model.type === HType.remote) { + rangeType = SkillRange.Long; + } else { + rangeType = SkillRange.Mid; + } + } + if (rangeType === SkillRange.Melee) return 3; + if (rangeType === SkillRange.Mid) return 2; + return 1; + } + private hasAnyActorTooClose(self: ecs.Entity, x: number, y: number): boolean { const myAttrs = self.get(HeroAttrsComp); if (!myAttrs) return false;