| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- import { GameProp, VideoAdType } from "../../data/GameData";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class ProductReward extends cc.Component {
- @property({ type: cc.Label, displayName: "文本" })
- lbl_times: cc.Label = null;
- @property({ type: cc.Label, displayName: "文本2" })
- lbl_times2: cc.Label = null;
- @property({ type: cc.Label, displayName: '任务次数' })
- lbl_taskTimes: cc.Label = null;
- @property({ type: cc.Label, displayName: '进度文本' })
- lbl_progress: cc.Label = null;
- @property({ type: cc.Sprite, displayName: '进度条' })
- sp_taskProgress: cc.Sprite = null;
- @property({ type: cc.Node, displayName: '完成节点' })
- node_complete: cc.Node = null;
- @property({ type: cc.Node, displayName: '未完成节点' })
- node_Uncomplete: cc.Node = null;
- @property({ type: cc.Node, displayName: '节点1' })
- node_1: cc.Node = null;
- @property({ type: cc.Node, displayName: '节点2' })
- node_2: cc.Node = null;
- private btnCanClick = true;
- onEnable() {
- this.lbl_times.string = `生产次数+${gData.gameData.configs.ServerConfig.ProductionAd}`;
- this.lbl_times2.string = `生产次数+${gData.gameData.configs.ServerConfig.ProductionAd}`;
- gData.gameData.init_productTask = false;
- let id = gData.gameData.getProp(GameProp.guideID);
- if (gData.gameData.playerProp.userFarmTaskInfo && id >= 11) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- if ((count - com) <= 10) {
- if (count > com) {
- this.lbl_taskTimes.string = (count - com).toString();
- this.node_Uncomplete.active = true;
- this.node_complete.active = false;
- } else {
- this.node_Uncomplete.active = false;
- this.node_complete.active = true;
- }
- let per = com / count;
- cc.tween(this.sp_taskProgress).delay(0.2).to(0.3, { fillRange: per }, {
- onUpdate: () => {
- let num = Math.round(this.sp_taskProgress.fillRange * count);
- this.lbl_progress.string = `${num}/${count}`;
- }
- }).call(() => {
- this.lbl_progress.string = `${com}/${count}`;
- }).start();
- } else {
- this.node_1.active = false;
- this.node_2.active = true;
- }
- }
- //if (id >= 11)
- {
- mk.ad.showNative();
- }
- // else {
- // this.btnCanClick = false;
- // this.lbl_taskTimes.string = "1";
- // this.node_Uncomplete.active = true;
- // this.node_complete.active = false;
- // this.sp_taskProgress.fillRange = 0.99;
- // this.lbl_progress.string = "99%";
- // this.scheduleOnce(() => {
- // this.btnCanClick = true;
- // let data = gData.gameData.playerProp.orderData;
- // let orderData = data.orderTaskList;
- // let copyData = gData.gameData.playerProp.copyOrderData;
- // if (data && orderData && copyData) {
- // let num = 0;
- // for (let i = 0; i != orderData.length; ++i) {
- // num += (orderData[i].taskCount - copyData[i])
- // }
- // if (gData.gameData.funOpenData[11] == "1") {
- // let curDes = `<color=8A4312>再生产${num}次,就可以收获\n啦,完成订单立即<color=ff0000>提现</color>!</color>`;
- // mk.guide.open(11, curDes);
- // }
- // }
- // }, 0.2)
- // }
- }
- update(dt) {
- if (gData.gameData.init_productTask) {
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- if (count <= 10) {
- if (count > com) {
- this.lbl_taskTimes.string = (count - com).toString();
- this.node_Uncomplete.active = true;
- this.node_complete.active = false;
- } else {
- this.node_Uncomplete.active = false;
- this.node_complete.active = true;
- }
- this.lbl_progress.string = `${com}/${count}`;
- this.sp_taskProgress.fillRange = com / count;
- } else {
- this.node_1.active = false;
- this.node_2.active = true;
- }
- }
- gData.gameData.init_productTask = false;
- }
- }
- private clickVideoBtn() {
- mk.audio.playEffect("button");
- if(!this.btnCanClick)
- {
- return;
- }
- mk.ui.closePanel(this.node.name);
- mk.ad.videoAdType = VideoAdType.video_init_16;
- mk.ad.watchAd((success: boolean) => {
- if (success) {
- gData.adData.watchVideo(null);
- let rewardData = [{ rewardType: 4, rewardNum: parseInt(gData.gameData.configs.ServerConfig.ProductionAd) }];
- gData.reward.data = rewardData;
- gData.reward.callback = this.addTimes;
- mk.ui.openPanel('module/reward/reward');
- let value = mk.storage.getStorage('guide_production');
- if (!value) {
- mk.storage.setStorage('guide_production', 1);
- mk.data.sendXYEvent('guide_production', '首次领取生产次数');
- }
- }
- })
- }
- addTimes() {
- let add = parseInt(gData.gameData.configs.ServerConfig.ProductionAd);
- gData.gameData.changeLeftTimes(add);
- gData.gameData.gameStyle.playAdd(add, 2);
- }
- onDisable() {
- mk.ad.destroyNativeAd();
- }
- private clickCloseBtn() {
- mk.audio.playEffect("button");
- mk.ui.closePanel(this.node.name);
- }
- }
|