diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index 09f202a8..4be6f117 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -68,8 +68,8 @@ export enum SkillRange { /** 距离类型的标准数值定义 */ export const SkillDisVal: Record = { - [SkillRange.Melee]: 120, - [SkillRange.Mid]: 360, + [SkillRange.Melee]: 150, + [SkillRange.Mid]: 400, [SkillRange.Long]: 720 }; diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index c0479d6c..6a7e4787 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -42,8 +42,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { offset: -30, lineName: "LINE3" }, // { offset: 30, lineName: "LINE4" }, ]; - private readonly samePointXThreshold = 12; - private readonly samePointYThreshold = 3; + private readonly minSpacingX = 50; + private readonly minSpacingY = 30; private readonly facConfigs: Record = { [FacSet.HERO]: { @@ -81,7 +81,10 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return; } - this.applyLineAndY(e, view, move, view.node.position.x); + const snappedY = this.applyLineAndY(e, view, move, view.node.position.x); + if (snappedY !== null && view.node.position.y !== snappedY) { + view.node.setPosition(view.node.position.x, snappedY, 0); + } this.updateRenderOrder(e); const nearestEnemy = this.findNearestEnemy(e); if (nearestEnemy) { @@ -212,7 +215,9 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate this.moveEntity(view, dir, speed); const newX = view.node.position.x; if ((dir === 1 && newX > targetX) || (dir === -1 && newX < targetX)) { - view.node.setPosition(targetX, view.node.position.y, 0); + if (!this.hasAnyActorTooClose(e, targetX, view.node.position.y)) { + view.node.setPosition(targetX, view.node.position.y, 0); + } } } else { view.status_change("idle"); @@ -260,16 +265,20 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } newX = Math.max(moveMinX, Math.min(moveMaxX, newX)); const newY = this.applyLineAndY(view.ent, view, move, newX); + if (newY === null) { + view.status_change("idle"); + return; + } view.node.setPosition(newX, newY, 0); view.status_change("move"); } - private applyLineAndY(entity: ecs.Entity, view: HeroViewComp, move: MoveComp, x: number): number { + private applyLineAndY(entity: ecs.Entity, view: HeroViewComp, move: MoveComp, x: number): number | null { if (!view.node) return 0; const baseY = move.baseY; for (const slot of this.ySlots) { const y = baseY + slot.offset; - if (!this.hasTeammateAtPoint(entity, x, y)) { + if (!this.hasAnyActorTooClose(entity, x, y)) { const lineNode = this.getLineNode(slot.lineName); if (lineNode && view.node.parent !== lineNode) { view.node.parent = lineNode; @@ -277,12 +286,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return y; } } - const fallback = this.ySlots[0]; - const fallbackNode = this.getLineNode(fallback.lineName); - if (fallbackNode && view.node.parent !== fallbackNode) { - view.node.parent = fallbackNode; - } - return baseY + fallback.offset; + return null; } private getLineNode(lineName: string) { @@ -292,17 +296,15 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return layerRoot.getChildByName(lineName); } - private hasTeammateAtPoint(self: ecs.Entity, x: number, y: number): boolean { - const myAttrs = self.get(HeroAttrsComp); - if (!myAttrs) return false; + private hasAnyActorTooClose(self: ecs.Entity, x: number, y: number): boolean { return ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp)).some(e => { if (e === self) return false; const attrs = e.get(HeroAttrsComp); - if (!attrs || attrs.fac !== myAttrs.fac || attrs.is_dead) return false; + if (!attrs || attrs.is_dead) return false; const view = e.get(HeroViewComp); if (!view || !view.node) return false; - return Math.abs(view.node.position.x - x) <= this.samePointXThreshold - && Math.abs(view.node.position.y - y) <= this.samePointYThreshold; + return Math.abs(view.node.position.x - x) < this.minSpacingX + && Math.abs(view.node.position.y - y) < this.minSpacingY; }); }