diff --git a/assets/script/game/skill/SMoveComp.ts b/assets/script/game/skill/SMoveComp.ts index 88ff0582..0f057ceb 100644 --- a/assets/script/game/skill/SMoveComp.ts +++ b/assets/script/game/skill/SMoveComp.ts @@ -90,27 +90,6 @@ export class SMoveDataComp extends ecs.Comp { this.autoDestroy = true; } - /** - * 重新计算位置(用于线性移动的延长) - */ - rePos(originalStart: Vec3) { - if (!originalStart) { - return; - } - - // 计算方向向量 - const direction = new Vec3(); - Vec3.subtract(direction, this.targetPos, originalStart); - direction.normalize(); - - // 延长720像素 - const extendedTarget = new Vec3(); - Vec3.scaleAndAdd(extendedTarget, originalStart, direction, 720); - - this.startPos.set(originalStart); - this.targetPos.set(extendedTarget); - } - /** * 开始移动 */ diff --git a/assets/script/game/skill/SMoveSystem.ts b/assets/script/game/skill/SMoveSystem.ts index 571abba0..9d866c95 100644 --- a/assets/script/game/skill/SMoveSystem.ts +++ b/assets/script/game/skill/SMoveSystem.ts @@ -103,8 +103,22 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate node.setPosition(moveComp.targetPos.x > 360 ? 300 : moveComp.targetPos.x, node.position.y, 0); break; case RType.bezier: - // - return + const bezierStartPos = v3( + moveComp.startPos.x + moveComp.atk_x, + moveComp.startPos.y + moveComp.atk_y, + moveComp.startPos.z + ); + const bezierTargetPos = v3( + moveComp.targetPos.x + moveComp.atk_x, + moveComp.targetPos.y + moveComp.atk_y, + moveComp.targetPos.z + ); + const horizonY = bezierStartPos.y; + const finalX = this.resolveBezierFinalXByHorizon(bezierStartPos, bezierTargetPos, horizonY); + moveComp.startPos.set(bezierStartPos); + moveComp.targetPos.set(finalX, horizonY, bezierTargetPos.z); + node.setPosition(bezierStartPos); + break; default: // 其他类型(包括bezier):根据atk_x和atk_y调整起始位置 if (moveComp.atk_x !== 0 || moveComp.atk_y !== 0) { @@ -119,6 +133,15 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate break; } } + + private resolveBezierFinalXByHorizon(startPos: Vec3, targetPos: Vec3, horizonY: number): number { + const deltaY = targetPos.y - startPos.y; + if (Math.abs(deltaY) < 0.0001) { + return targetPos.x; + } + const t = (horizonY - startPos.y) / deltaY; + return startPos.x + (targetPos.x - startPos.x) * t; + } update(entity: ecs.Entity): void { if(!smc.mission.play ) return;