import { _decorator, Component, Label, Node, Sprite, tween, Vec3 } from 'cc'; import { SYS_GIFT } from './Define'; import { GameDataManager } from '../../Main/Scripts/managers/GameDataManager'; import { LocalizedSprite } from '../../Main/Scripts/i18n/LocalizedSprite'; const { ccclass, property } = _decorator; @ccclass('SysGift') export class SysGift extends Component { @property(Node) info: Node = null; @property(Node) confirm: Node = null; @property(Node) settle: Node = null; @property(Node) bg: Node = null; fixedBet: number = -1; totalWin: number = -1; onLoad(): void { // let sp_win = this.info.getChildByName("sysgift_win"); // sp_win.getComponent(LocalizedSprite).updateSprite(); // let scale = 116 / sp_win.getComponent(Sprite).spriteFrame.width; // sp_win.setScale(scale, scale, scale); // this.bg = this.node.getChildByName("bg"); // this.hideAll(); } hideAll() { this.node.active = true; this.bg.active = false; this.confirm.active = false this.settle.active = false this.info.active = false } /**确认领取free spin, 下注额固定其他控件半透明且不可交互*/ onClickContinue() { this.hide(this.confirm) let frb = GameDataManager.instance.frb if (!frb) return; let txt_spin_num = this.info.getChildByName("count") txt_spin_num.getComponent(Label).string = (frb.Ongoing.Frn.toLocaleString()) let txt_win = this.info.getChildByName("win") let num = Math.round(frb.Ongoing.Fra * 100 + 1e-6) / 100; txt_win.getComponent(Label).string = num.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) this.info.active = true; this.node.emit(SYS_GIFT.CLICK_CONTINUE, this.fixedBet); } onClickConfirm() { this.hide(this.settle); this.node.emit(SYS_GIFT.SETTLE_CONTINUE); } /** 打开confirm的弹窗 */ showOngingPopup() { if (this.confirm.active) return; let frb = GameDataManager.instance.frb; if (!frb) return; this.fixedBet = frb.Ongoing.Bet if (frb.Ongoing.Popup) { this.confirm.getChildByName("count").getComponent(Label).string = frb.Ongoing.Frn.toLocaleString() this.show(this.confirm); } } /** 打开settle的win */ showSysFreeWinSettle() { let frb = GameDataManager.instance.frb; if (!frb) return; if (frb.Finished?.Popup) { let win = this.settle.getChildByName('win'); let num = Math.round(frb.Finished.Fra * 100 + 1e-6) / 100; win.getComponent(Label).string = num.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) this.show(this.settle); this.info.active = false; } } /** 设置info的count */ handleSysInfoFreeCount(countNum: number) { let frb = GameDataManager.instance.frb; if (!frb) return; if (frb.Finished == null) { let count = this.info.getChildByName('count'); count.getComponent(Label).string = (countNum).toLocaleString(); this.show(count); } } /** 设置info的win */ handleSysInfoFreeWin() { let frb = GameDataManager.instance.frb; if (!frb) return; if (frb.Finished == null && frb.Ongoing?.Popup == false) { let win = this.info.getChildByName("win") let num = Math.round(frb.Ongoing.Fra * 100 + 1e-6) / 100 win.getComponent(Label).string = num.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) this.show(win); this.info.active = true; } } show(node: Node, scale: number = 1) { node.active = true if (node != this.settle && node != this.confirm) { this.bg.active = false; } else { this.bg.active = true; } tween(node).to(0.1, { scale: new Vec3(0.8, 0.8, 1) }) .to(0.2, { scale: new Vec3(1.1, 1.1, 1) }) .to(0.1, { scale: new Vec3(scale, scale, scale) }) .start() } hide(node) { this.bg.active = false; tween(node).to(0.1, { scale: new Vec3(1.1, 1.1, 1) }) .to(0.2, { scale: new Vec3(0.8, 0.8, 1) }) .call(() => { node.active = false node.scale = new Vec3(1, 1, 1) }) .start() } }