|
|
@@ -1,6 +1,6 @@
|
|
|
import Util from "../../before/util/Util";
|
|
|
import JsbSystem from "../../mk/system/JsbSystem";
|
|
|
-import { RateConfig } from "../data/AdData";
|
|
|
+import { AdFun, RateConfig } from "../data/AdData";
|
|
|
import { DataEventId, GameProp, ProductType, VideoAdType } from "../data/GameData";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
@@ -121,6 +121,8 @@ export default class Game extends cc.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ this.initRefreshEvent();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
start() {
|
|
|
@@ -203,6 +205,14 @@ export default class Game extends cc.Component {
|
|
|
mk.ui.openPanel('module/speedUpUI/restoreProductTimes');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (this.startTimes) {
|
|
|
+ this.btnCD += dt;
|
|
|
+ if (this.btnCD >= 1) {
|
|
|
+ this.startTimes = false;
|
|
|
+ this.btnCD = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
lateUpdate() {
|
|
|
gData.gameData.init_head = false;
|
|
|
@@ -590,8 +600,18 @@ export default class Game extends cc.Component {
|
|
|
//图鉴部分logic
|
|
|
public initRefreshEvent() {
|
|
|
|
|
|
+ mk.event.register("initFarmMapUi", this.initFarmMapUi.bind(this), this);
|
|
|
+ mk.event.register("refreshFarmMapUI", this.refreshFarmMapUI.bind(this), this);
|
|
|
+
|
|
|
+
|
|
|
+ this.initFarmMapUi();
|
|
|
+
|
|
|
+ this.showChangePart();
|
|
|
}
|
|
|
|
|
|
+ private uiShowType = 3;
|
|
|
+ private productType = ProductType.nzw;
|
|
|
+ private productIndex = 0;
|
|
|
public async initFarmMapUi() {
|
|
|
let plantPath = '';
|
|
|
let namePath = '';
|
|
|
@@ -605,27 +625,37 @@ export default class Game extends cc.Component {
|
|
|
}
|
|
|
|
|
|
//1:有可领奖的,2:正在解锁,3:所有奖励都领取完
|
|
|
- let uiShowType = 3;
|
|
|
+ this.uiShowType = 3;
|
|
|
for (let key in ProductType) {
|
|
|
let max = gData.gameData.getMaxProduct(ProductType[key]);
|
|
|
if (max) {
|
|
|
let list_data = gData.gameData.getProductArrByType(ProductType[key]);
|
|
|
for (let i = 0; i != list_data.length; ++i) {
|
|
|
- if (list_data[i].picture <= max) {
|
|
|
- let state = gData.gameData.getFarmMapRewardState(this.getIndex(list_data[i]));
|
|
|
+ let data = list_data[i];
|
|
|
+ if (data.picture <= max) {
|
|
|
+ let state = gData.gameData.getFarmMapRewardState(this.getIndex(data));
|
|
|
if (state == 0) {
|
|
|
- uiShowType = 1;
|
|
|
-
|
|
|
- this.sp_farmMapIcon.spriteFrame = await mk.loader.load(plantPath + list_data[i].picture, cc.SpriteFrame);
|
|
|
+ this.uiShowType = 1;
|
|
|
+ this.productType = ProductType[key];
|
|
|
+ this.productIndex = i;
|
|
|
+
|
|
|
+ this.node_farmMapGetReward.active = true;
|
|
|
+ this.node_farmMapProduct.active = false;
|
|
|
+ this.node_farmMapUI.active = true;
|
|
|
+ this.sp_farmMapIcon.spriteFrame = await mk.loader.load(plantPath + data.picture, cc.SpriteFrame);
|
|
|
return;
|
|
|
}
|
|
|
- } else if (list_data[i].picture - 1 == max) {
|
|
|
- uiShowType = 2
|
|
|
-
|
|
|
- let times = gData.gameData.getProductMakeTimesById(list_data[i].picture - 1);
|
|
|
- let plantName = gData.gameData.getProductMap(list_data[i].picture - 1).name;
|
|
|
- let des = this.getDesByType(list_data[i]);
|
|
|
- this.lbl_farmMapDes.string = `${des}${list_data[i].value}次${plantName}(${times}/${list_data[i].value})`;;
|
|
|
+ } else if (data.picture - 1 == max) {
|
|
|
+ this.uiShowType = 2
|
|
|
+ this.productType = ProductType[key];
|
|
|
+ this.productIndex = i;
|
|
|
+ this.node_farmMapGetReward.active = false;
|
|
|
+ this.node_farmMapProduct.active = true;
|
|
|
+ this.node_farmMapUI.active = true;
|
|
|
+ let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
|
|
|
+ let plantName = gData.gameData.getProductMap(data.picture - 1).name;
|
|
|
+ let des = this.getDesByType(data);
|
|
|
+ this.lbl_farmMapDes.string = `${des}${data.value}次${plantName}(${times}/${data.value})`;
|
|
|
this.sp_farmMapIcon.spriteFrame = await mk.loader.load('module/farmMap/texture/gift', cc.SpriteFrame);
|
|
|
return;
|
|
|
}
|
|
|
@@ -633,14 +663,56 @@ export default class Game extends cc.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (uiShowType == 3) {
|
|
|
+ if (this.uiShowType == 3) {
|
|
|
this.node_farmMapUI.active = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public refreshFarmMapUI() {
|
|
|
+ if (this.uiShowType == 2) {
|
|
|
+ let list_data = gData.gameData.getProductArrByType(this.productType);
|
|
|
+ let data = list_data[this.productIndex];
|
|
|
+
|
|
|
+ let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
|
|
|
+ let plantName = gData.gameData.getProductMap(data.picture - 1).name;
|
|
|
+ let des = this.getDesByType(data);
|
|
|
+ this.lbl_farmMapDes.string = `${des}${data.value}次${plantName}(${times}/${data.value})`;;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private btnCD = 0;
|
|
|
+ private startTimes = false;
|
|
|
+ public clickGetFarmMapRewardBtn() {
|
|
|
+
|
|
|
+ if (!this.startTimes) {
|
|
|
+ this.startTimes = true;
|
|
|
+ this.btnCD = 0;
|
|
|
} else {
|
|
|
- if (!this.node_farmMapUI.active) {
|
|
|
- this.node_farmMapUI.active = true;
|
|
|
- }
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ mk.audio.playEffect("button");
|
|
|
+
|
|
|
+ mk.ad.videoAdType = VideoAdType.video_init_6;
|
|
|
+ mk.ad.watchAd(async (success) => {
|
|
|
+ if (success) {
|
|
|
+ await gData.adData.watchVideo(AdFun.farmMap);
|
|
|
+
|
|
|
+ if (gData.farmMapData.init_award) {
|
|
|
+
|
|
|
+ gData.farmMapData.init_award = false;
|
|
|
+ gData.reward.adData = gData.farmMapData.adData;
|
|
|
+ mk.ui.openPanel('module/reward/reward');
|
|
|
+
|
|
|
+ gData.farmMapData.isStateChange = true;
|
|
|
+ let list_data = gData.gameData.getProductArrByType(this.productType);
|
|
|
+ let data = list_data[this.productIndex];
|
|
|
+ gData.gameData.setFarmMapRewardState(this.getIndexExtra(data), 1);
|
|
|
+
|
|
|
+ this.initFarmMapUi();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
showChangePart() {
|
|
|
@@ -696,6 +768,48 @@ export default class Game extends cc.Component {
|
|
|
return index;
|
|
|
}
|
|
|
|
|
|
+ getIndexExtra(data) {
|
|
|
+ let index: any = {};
|
|
|
+ index.i = 0;
|
|
|
+ index.j = 0;
|
|
|
+ switch (data.tab) {
|
|
|
+ case '农作物':
|
|
|
+ index.i = 0;
|
|
|
+ index.j = data.picture - 10001;
|
|
|
+ break;
|
|
|
+ case '动物':
|
|
|
+ index.i = 1;
|
|
|
+ index.j = data.picture - 20001;
|
|
|
+ break;
|
|
|
+ case '爆米花厂':
|
|
|
+ index.i = 2;
|
|
|
+ index.j = data.picture - 20004;
|
|
|
+ break;
|
|
|
+ case '糕点铺':
|
|
|
+ index.i = 3;
|
|
|
+ index.j = data.picture - 20013;
|
|
|
+ break;
|
|
|
+ case '制糖厂':
|
|
|
+ index.i = 4;
|
|
|
+ index.j = data.picture - 20010;
|
|
|
+ break;
|
|
|
+ case '炼乳厂':
|
|
|
+ index.i = 5;
|
|
|
+ index.j = data.picture - 20007;
|
|
|
+ break;
|
|
|
+ case '功夫面馆':
|
|
|
+ index.i = 6;
|
|
|
+ index.j = data.picture - 20025;
|
|
|
+ break;
|
|
|
+ case '快餐店':
|
|
|
+ index.i = 7;
|
|
|
+ index.j = data.picture - 20019;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return index;
|
|
|
+ }
|
|
|
+
|
|
|
getDesByType(data) {
|
|
|
let des = ''
|
|
|
switch (data.tab) {
|