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, 'loop', true); }) this.costLabel.string = gold2cash(cost * buyMul) this.closeCallBack = closeCallback; } onBtnStart() { if (this.isClick) return; AudioManager.instance.playSFX('Feature_Buy_Start_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_Cancel_Sound'); this.isClick = true; this.spine.clearTracks(); this.spine.setAnimation(0, 'out', true); this.spine.setCompleteListener(() => { NodePoolManager.instance.putNodeToPool("FeatureBuy", this.node); }) } }