| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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.RichText})
- private rt_task_des: cc.RichText = null;
- @property({displayName: '任务进度条', type: cc.Sprite})
- private sp_taskProgress: cc.Sprite = null;
- @property({displayName: '任务进度文本', type: cc.Label})
- private lbl_taskProgress: cc.Label = 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;
- start(){
- mk.ad.showBanner();
-
- this.initTaskProgressUI();
- this.initCashOutStyle(gData.gameData.gameData.redMoney);
- this.showChangePart();
- }
- update(dt){
- if (gData.reward.add_redbag_value) {
- this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
- }
- }
- private initTaskProgressUI()
- {
- cc.tween(this.sp_taskProgress).to(0.2, {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()
- {
-
- }
-
- /**
- * 提现操作
- */
- private clickCashOut() {
- mk.audio.playEffect("button");
- gData.reward.addReward();
- mk.ui.closePanel(this.node.name);
- // let path = 'module/redBagCash/redBagCash';
- // mk.ui.openPanel(path);
- }
- private clickCloseBtn(){
- mk.audio.playEffect("closeButton");
- }
- }
|