46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import SpineAnimationHandler from '../Base/SpineAnimationHandler';
|
|
import BoosterType from '../Enum/BoosterType';
|
|
import AudioManager from '../Manager/AudioManager';
|
|
import { BoosterBase } from './BoosterBase';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('CumulativeBooster')
|
|
export class CumulativeBooster extends BoosterBase {
|
|
@property(SpineAnimationHandler)
|
|
private animationHandler: SpineAnimationHandler;
|
|
|
|
public readonly type: BoosterType = BoosterType.CumulativeBar;
|
|
|
|
protected onLoad(): void {
|
|
super.onLoad();
|
|
this.animationHandler?.setNodeActive(false);
|
|
}
|
|
|
|
public async collect(collector: Node): Promise<void> {
|
|
super.collect(collector);
|
|
AudioManager.setPlayRateBGM(1.5);
|
|
await this.animationHandler?.setAnimationAsync('active');
|
|
this.animationHandler?.setNodeActive(false);
|
|
}
|
|
|
|
public end(): void {
|
|
super.end();
|
|
AudioManager.setPlayRateBGM(1);
|
|
}
|
|
|
|
async onGet(): Promise<void> {
|
|
await super.onGet();
|
|
if (this.animationHandler) {
|
|
this.animationHandler.setNodeActive(true);
|
|
this.animationHandler.setAnimation('idle', { loop: true });
|
|
this.sprite.setNodeActive(false);
|
|
}
|
|
}
|
|
|
|
onRelease(): void {
|
|
super.onRelease();
|
|
this.animationHandler?.setNodeActive(false);
|
|
}
|
|
}
|