| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import { 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: '任务次数' })
- 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;
- onEnable() {
- this.scheduleOnce(() => {
- mk.guide.open(4);
- }, 0.5)
- this.lbl_times.string = `生产次数x${gData.gameData.configs.ServerConfig.ProductionAd}`;
- gData.gameData.init_productTask = false;
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- 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;
- }
- }
- 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 > 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;
- }
- gData.gameData.init_productTask = false;
- }
- }
- private clickVideoBtn() {
- mk.audio.playEffect("button");
- 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');
- }
- })
- }
- addTimes() {
- gData.gameData.changeLeftTimes(parseInt(gData.gameData.configs.ServerConfig.ProductionAd));
- }
- private clickCloseBtn() {
- mk.audio.playEffect("closeButton");
- mk.ui.closePanel(this.node.name);
- }
- }
|