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.
AdLike2048/assets/script/ui/BattleGame/BossWarnSpine.ts

67 lines
1.7 KiB

3 weeks ago
import { _decorator, Component, Node, sp } from 'cc';
import { BattleSpinePlayback } from 'db://assets/script/battle/presentation/BattleSpinePlayback';
const { ccclass, property } = _decorator;
export enum BossWarnType{
/** boss警告 */
Boss = 0,
/** 中期boss警告 */
MidBoss = 1,
/**最后一波警告 */
LastWave = 2,
/**大波怪物来袭警告 */
LargeWave = 3,
/**空降兵 */
Paratroops = 4,
/**开场 */
StartBattle = 5,
}
@ccclass('BossWarnSpine')
export class BossWarnSpine extends Component {
@property({type: [Node]})
spineNode: Node[] = []
start() {
}
/** 播放警告动画 */
playWarnAnim(warnType: BossWarnType){
let spineNode = this.spineNode[warnType]
if(!spineNode){
return
}else{
spineNode.active = true
}
let spine = spineNode.getComponent(sp.Skeleton)
const animName = spine?.animation ?? '';
if (!spine?.isValid || !animName) {
spineNode.destroy();
this.node.destroy();
return;
}
BattleSpinePlayback.play(spine, animName, {
loop: false,
onComplete: () => {
spineNode.destroy();
this.node.destroy();
},
});
}
public playSpine(spine: sp.Skeleton, callback: Function = null, timeScale = 1, loop = false) {
const spineName = spine.animation;
if (!spineName) {
callback?.();
return;
}
BattleSpinePlayback.play(spine, spineName, {
loop,
timeScale,
onComplete: callback ? () => callback() : undefined,
});
}
}