rp_11001/assets/Game/scripts/game/FeatureBuy.ts
TJH f466306084
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m19s
代码整理
2025-12-22 16:17:40 +08:00

39 lines
1.2 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(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.costLabel.string = gold2cash(cost * buyMul)
this.closeCallBack = closeCallback;
}
onBtnStart() {
if (this.isClick) return;
AudioManager.instance.playSFX('Feature_Buy_Start_Sound');
this.isClick = true;
NodePoolManager.instance.putNodeToPool("FeatureBuy", this.node);
this.closeCallBack && this.closeCallBack();
}
onBtnCancel() {
if (this.isClick) return;
AudioManager.instance.playSFX('Feature_Buy_Cancel_Sound');
this.isClick = true;
NodePoolManager.instance.putNodeToPool("FeatureBuy", this.node);
}
}