import { _decorator, Component, Label, Node, sp, Tween, tween, Vec3 } from 'cc'; import { UIManager } from '../../Main/Scripts/managers/UIManager'; import { gold2cash, gold2cash2 } from '../../Main/Scripts/main/comm'; import { AudioManager } from '../../Main/Scripts/managers/AudioManager'; const { ccclass, property } = _decorator; @ccclass('TotalWinSpine') export class TotalWinSpine extends Component { @property(Node) mainNode: Node = null; @property(Node) fsTotalWinSpineNode: Node = null; @property(Node) totalWinCount: Node = null; @property(Node) collectBtn: Node = null; totalWinCountValue: number = 0; labelController: any = null; hasClickBtn: boolean = false; closeCallBack: () => void = null; showTotalWinSpine(totalWinCount: number, cb) { this.closeCallBack = cb; this.totalWinCountValue = totalWinCount; this.totalWinCount.getComponent(Label).string = '0.00'; this.collectBtn.active = false; this.hasClickBtn = false; this.node.getChildByName('grayBg').once(Node.EventType.TOUCH_START, this.onClickGrayBg, this); tween(this.fsTotalWinSpineNode) .set({ scale: new Vec3(1.1, 1.1, 1.1) }) .to(5, { scale: new Vec3(1, 1, 1) }) .call(() => { this.collectBtn.active = true; }) .start(); tween(this.mainNode) .set({ scale: new Vec3(0, 0, 0) }) .to(0.5, { scale: new Vec3(1, 1, 1) }, { easing: 'bounceOut' }) .start(); AudioManager.instance.playSFX('Gold_Up'); this.labelController = UIManager.instance.tweenScorelinear(0, totalWinCount, 2) .onUpdate((v: number) => { this.totalWinCount.getComponent(Label).string = gold2cash(v); }) .onComplete(() => { AudioManager.instance.playBGM('Total_Win_Last_Bgm'); this.collectBtn.active = true; this.totalWinCount.getComponent(Label).string = gold2cash(totalWinCount); this.scheduleOnce(() => { this.onClickCollectBtn(); }, 5); }) .start(); } onClickGrayBg() { AudioManager.instance.playBGM('Total_Win_Last_Bgm'); this.node.getChildByName('grayBg').off(Node.EventType.TOUCH_START, this.onClickGrayBg, this); Tween.stopAllByTarget(this.labelController.holder); AudioManager.instance.stopSFX('Gold_Up'); this.collectBtn.active = true; this.totalWinCount.getComponent(Label).string = gold2cash(this.totalWinCountValue); } onClickCollectBtn() { if (this.hasClickBtn) return; this.hasClickBtn = true; AudioManager.instance.playSFX('Click_Small_Game_Start'); tween(this.collectBtn) .to(0.1, { scale: new Vec3(1.1, 1.1, 1.1) }) .to(0.1, { scale: new Vec3(1, 1, 1) }) .call(() => { this.unscheduleAllCallbacks(); this.closeCallBack(); }) .start(); } }