import Util from "../../../before/util/Util"; const { ccclass, property } = cc._decorator; @ccclass export default class RedBagTask extends cc.Component { @property({ displayName: '数字组', type: cc.Label }) private lbl_value: cc.Label[] = []; @property({ displayName: '任务进度条', type: cc.Sprite }) private sp_taskProgress: cc.Sprite = null; @property({ displayName: '任务进度文本', type: cc.Label }) private lbl_taskProgress: cc.Label = null; @property({ displayName: '按钮动画', type: cc.Animation }) private openBtn_ani: cc.Animation = null; @property(cc.Label) private lbl_reward_value: cc.Label = null; @property(cc.Sprite) private spr_cash_out: cc.Sprite = null; @property(cc.Label) private lbl_progress: cc.Label = null; @property(cc.Animation) private node_cash: cc.Animation = null; @property({type: cc.Node, displayName: '显示金额节点'}) private node_value: cc.Node = null; @property({type: cc.Node, displayName: '任务节点'}) private node_task: cc.Node = null; @property({type: cc.Label, displayName: '动画显示文字'}) private lbl_Ani: cc.Label = null; @property({type: cc.Label, displayName: '任务数量'}) private lbl_taskNum: cc.Label = null; @property({type: cc.Label, displayName: '任务描述'}) private lbl_taskDes: cc.Label = null; private isShowNewTask = false; private num = 0; private delayTime = 0; private times = 0; start() { mk.ad.showBanner(); if(this.isShowNewTask) { this.node_value.active = false; this.node_task.active = false; this.node_cash.node.active = false; this.lbl_Ani.node.active = true; }else{ //this.node_value.active = true; //this.node_task.active = true; //this.node_cash.node.active = true; this.initTaskProgressUI(); this.showChangePart(); } this.initCashOutStyle(gData.gameData.gameData.redMoney); } onEnable() { mk.ad.showBanner(); } onDisable() { mk.ad.destoryBanner(); } update(dt) { if (gData.reward.add_redbag_value) { this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value); } if(this.isShowNewTask) { if(this.delayTime <= 0.6) { this.delayTime += dt; }else { this.times +=1; if(this.times == 2) { this.times = 0; this.num +=1; this.lbl_Ani.string = this.num.toString(); if(this.num == 14) { this.isShowNewTask = false; this.lbl_Ani.node.color = new cc.Color(255, 218, 49); let clone = cc.instantiate(this.lbl_Ani.node); clone.parent = this.lbl_Ani.node.parent; cc.tween(clone).to(1.2, {scale: 4.0, opacity: 0}).call(()=>{ clone.active = false; let worldPos = this.lbl_taskNum.node.parent.convertToWorldSpaceAR(this.lbl_taskNum.node.position); let pos = this.lbl_taskNum.node.parent.parent.convertToNodeSpaceAR(worldPos); cc.tween(this.lbl_Ani).to(0.6, {fontSize: 40}).start(); cc.tween(this.lbl_Ani.node).to(0.6,{position: pos}, cc.easeSineOut()).call(()=>{ this.lbl_Ani.node.active = false; this.node_task.active = true; cc.tween(this.node_task).by(0.16, {y: -6}).by(0.1, {y: 6}).start(); }).start(); this.node_value.active = true; this.node_value.scale = 0; cc.tween(this.node_value).to(0.76, {scale: 1.3}, cc.easeSineOut()).to(0.1, {scale: 1}).start(); }).start(); } } } } } private initTaskProgressUI() { cc.tween(this.sp_taskProgress).delay(0.2).to(0.3, { fillRange: 0.4 }, { onUpdate: () => { let str = this.sp_taskProgress.fillRange * 100; this.lbl_taskProgress.string = str.toFixed(0) + "%"; } }).start(); cc.tween(this) } showChangePart() { //this.changePart.active = true let len = this.lbl_value.length; this.schedule(() => { for (var i = 0; i < len; i++) { let ran = Util.rnd(0, 9); this.lbl_value[i].string = `${ran}`; } }, 0.1) } /** * 底部提现相关样式 */ private initCashOutStyle(redMoney: number = 0) { const cash_bar = gData.redBagCash.cash_bar; let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar); if (!cash_data) return; const newRedMoney = redMoney > cash_data.type_value ? cash_data.type_value : redMoney; this.lbl_reward_value.string = cash_data.money / 100 + '元'; this.lbl_progress.string = newRedMoney + '/' + cash_data.type_value; const fillRange = newRedMoney / cash_data.type_value >= 1 ? 1 : newRedMoney / cash_data.type_value; // this.spr_cash_out.fillRange = fillRange; cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start(); if (redMoney >= cash_data.type_value) { this.node_cash.play(); } else { this.node_cash.stop(); } } private clickVideoBtn() { } private clickGetRewardBtn() { //gData.receiptNotice.receip_rmb = gData.blessingBag.rbNum; //mk.ui.openPanel('module/newNotice/newNotice'); } /** * 提现操作 */ private clickCashOut() { mk.audio.playEffect("button"); gData.reward.addReward(); //mk.ui.closePanel(this.node.name); let path = 'module/newCashUI/walletCashOut'; mk.ui.openPanel(path); } private clickCloseBtn() { mk.audio.playEffect("closeButton"); } }