rp_10012/assets/Game/scripts/game/FeatureBuy.ts
TJH 4124b6821f
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m25s
添加音效
2025-10-09 10:50:55 +08:00

55 lines
1.8 KiB
TypeScript

import { _decorator, Component, Label, Node, sp } from 'cc';
import { gold2cash } from 'db://assets/Loading/scripts/comm';
import { AudioManager } from 'db://assets/Loading/scripts/manager/AudioManager';
import { NodePoolManager } from 'db://assets/Loading/scripts/manager/NodePoolManager';
const { ccclass, property } = _decorator;
@ccclass('FeatureBuy')
export class FeatureBuy extends Component {
@property(sp.Skeleton)
spine: sp.Skeleton = null;
@property(Label)
private costLabel: Label = null;
private closeCallBack: Function = null;
private isClick: boolean = false;
show(cost: number, buyMul: number, closeCallback: Function): void {
this.isClick = false;
this.spine.clearTracks();
// this.spine.setAnimation(0, 'in', false);
// this.spine.setCompleteListener(() => {
this.spine.setAnimation(0, 'animation', true);
// })
this.costLabel.string = gold2cash(cost * buyMul)
this.closeCallBack = closeCallback;
}
onBtnStart() {
if (this.isClick) return;
AudioManager.instance.playSFX('Feature_Buy_Sound');
this.isClick = true;
this.spine.clearTracks();
// this.spine.setAnimation(0, 'out', true);
// this.spine.setCompleteListener(() => {
NodePoolManager.instance.putNodeToPool("FeatureBuy", this.node);
this.closeCallBack && this.closeCallBack();
// })
}
onBtnCancel() {
if (this.isClick) return;
AudioManager.instance.playSFX('Feature_Buy_Sound');
this.isClick = true;
this.spine.clearTracks();
// this.spine.setAnimation(0, 'out', true);
// this.spine.setCompleteListener(() => {
NodePoolManager.instance.putNodeToPool("FeatureBuy", this.node);
// })
}
}