fix: 修正英雄移动逻辑中距离判断条件
将原条件 `dist < minRange` 改为 `dist >= minRange`,并与阵型移动需求结合。原逻辑在距离过近时也会触发移动,导致英雄可能无法保持在有效攻击范围内。新逻辑确保仅在距离足够且需要调整阵型位置时才移动。
This commit is contained in:
@@ -198,8 +198,8 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
const [minRange, maxRange] = this.resolveCombatRange(model, defaultMin, defaultMax);
|
||||
const dist = Math.abs(currentX - enemyX);
|
||||
const needMoveToFormation = Math.abs(currentX - targetX) > 5;
|
||||
const shouldKeepDistance = dist < minRange;
|
||||
if (needMoveToFormation || shouldKeepDistance) {
|
||||
|
||||
if (dist >= minRange && needMoveToFormation) {
|
||||
const dir = targetX > currentX ? 1 : -1;
|
||||
move.direction = dir;
|
||||
const speed = model.speed / 3;
|
||||
|
||||
Reference in New Issue
Block a user