You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
|
3 weeks ago
|
import { Node, Vec3 } from 'cc';
|
||
|
|
import { SkillTransformDriver } from './SkillTransformDriver';
|
||
|
|
|
||
|
|
export interface TornadoOrbitOptions {
|
||
|
|
node: Node;
|
||
|
|
anchorWorld: Readonly<Vec3>;
|
||
|
|
orbitRadiusPx: number;
|
||
|
|
durationSec: number;
|
||
|
|
/** 绕落点一圈所需秒数(默认约 5s,与旧版折线总时长接近) */
|
||
|
|
loopDurationSec?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 龙卷风在落点附近平滑曲线游走(匀速,无折线转角停顿)。
|
||
|
|
* 伤害圆心由调用方每 tick 读 node.worldPosition。
|
||
|
|
*/
|
||
|
|
export class TornadoOrbitDriver {
|
||
|
|
private _node: Node | null = null;
|
||
|
|
private _alive = false;
|
||
|
|
|
||
|
|
start(opts: TornadoOrbitOptions): void {
|
||
|
|
this.stop();
|
||
|
|
const node = opts.node;
|
||
|
|
if (!node?.isValid) return;
|
||
|
|
|
||
|
|
this._node = node;
|
||
|
|
this._alive = true;
|
||
|
|
|
||
|
|
node.setWorldPosition(opts.anchorWorld);
|
||
|
|
SkillTransformDriver.animateSmoothOrbit({
|
||
|
|
node,
|
||
|
|
anchorWorld: opts.anchorWorld,
|
||
|
|
radiusPx: opts.orbitRadiusPx,
|
||
|
|
loopDurationSec: opts.loopDurationSec ?? 5,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
stop(): void {
|
||
|
|
this._alive = false;
|
||
|
|
if (this._node?.isValid) {
|
||
|
|
SkillTransformDriver.cancelNode(this._node);
|
||
|
|
}
|
||
|
|
this._node = null;
|
||
|
|
}
|
||
|
|
}
|