|
|
@@ -1,106 +1,98 @@
|
|
|
-import { ProductType } from "../../data/GameData";
|
|
|
+import { ProductType, VideoAdType } from "../../data/GameData";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
@ccclass
|
|
|
-export default class FarmItem extends cc.Component{
|
|
|
+export default class FarmItem extends cc.Component {
|
|
|
|
|
|
- @property({displayName: '图标', type: cc.Sprite})
|
|
|
+ @property({ displayName: '图标', type: cc.Sprite })
|
|
|
private sp_icon: cc.Sprite = null;
|
|
|
|
|
|
- @property({displayName: '名字描述', type: cc.Label})
|
|
|
+ @property({ displayName: '名字描述', type: cc.Label })
|
|
|
private lbl_nameDes: cc.Label = null;
|
|
|
|
|
|
- @property({displayName: '描述', type: cc.Label})
|
|
|
+ @property({ displayName: '描述', type: cc.Label })
|
|
|
private lbl_des: cc.Label = null;
|
|
|
|
|
|
- @property({displayName: '领奖按钮', type: cc.Node})
|
|
|
+ @property({ displayName: '领奖按钮', type: cc.Node })
|
|
|
private node_ungetBtn: cc.Node = null;
|
|
|
|
|
|
- @property({displayName: '已领奖按钮', type: cc.Node})
|
|
|
+ @property({ displayName: '已领奖按钮', type: cc.Node })
|
|
|
private node_getBtn: cc.Node = null;
|
|
|
|
|
|
- @property({displayName: '未解锁按钮', type: cc.Node})
|
|
|
+ @property({ displayName: '未解锁按钮', type: cc.Node })
|
|
|
private node_unluckBtn: cc.Node = null;
|
|
|
|
|
|
- @property({displayName: '红点', type: cc.Node})
|
|
|
+ @property({ displayName: '红点', type: cc.Node })
|
|
|
private node_redPoint: cc.Node = null;
|
|
|
|
|
|
private data = null;
|
|
|
|
|
|
- public setItemData(data)
|
|
|
- {
|
|
|
+ public setItemData(data) {
|
|
|
this.InitUI(data);
|
|
|
}
|
|
|
|
|
|
- private async InitUI(data)
|
|
|
- {
|
|
|
+ private async InitUI(data) {
|
|
|
this.data = data;
|
|
|
let plantPath = '';
|
|
|
let namePath = '';
|
|
|
if (gData.farmMapData.chooseType == ProductType.nzw) {
|
|
|
plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
|
|
|
- namePath = 'game/coregame/texture/plant_icons/nameIcon/plant_name_';
|
|
|
+ namePath = 'game/coregame/texture/plant_icons/nameIcon/plant_name_';
|
|
|
}
|
|
|
else {
|
|
|
plantPath = 'game/coregame/texture/factory_icons/factory_';
|
|
|
namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
|
|
|
}
|
|
|
-
|
|
|
- let max = gData.farmMapData.maxUnluckValue;
|
|
|
- if(data.picture <= max)
|
|
|
- {
|
|
|
+
|
|
|
+ let max = gData.farmMapData.maxUnluckValue;
|
|
|
+ if (data.picture <= max) {
|
|
|
this.sp_icon.spriteFrame = await mk.loader.load(plantPath + data.picture, cc.SpriteFrame);
|
|
|
this.lbl_nameDes.node.active = true;
|
|
|
this.lbl_nameDes.string = `Lv.${data.level} ${data.name} ${data.time}秒成熟`;
|
|
|
this.lbl_des.string = `最高收获${data.MenuredBagCoin}红包币`;
|
|
|
-
|
|
|
+
|
|
|
let state = gData.gameData.getFarmMapRewardState(this.getIndex());
|
|
|
- if(state == 1)
|
|
|
- {
|
|
|
- this.node_getBtn.active =true;
|
|
|
+ if (state == 1) {
|
|
|
+ this.node_getBtn.active = true;
|
|
|
this.node_ungetBtn.active = false;
|
|
|
this.node_unluckBtn.active = false;
|
|
|
this.node_redPoint.active = false;
|
|
|
- }else{
|
|
|
- this.node_getBtn.active =false;
|
|
|
+ } else {
|
|
|
+ this.node_getBtn.active = false;
|
|
|
this.node_ungetBtn.active = true;
|
|
|
this.node_unluckBtn.active = false;
|
|
|
this.node_redPoint.active = true;
|
|
|
}
|
|
|
|
|
|
- }else if(data.picture -1 == max)
|
|
|
- {
|
|
|
+ } else if (data.picture - 1 == max) {
|
|
|
this.sp_icon.spriteFrame = await mk.loader.load('module/farmMap/texture/gift', cc.SpriteFrame);
|
|
|
let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
|
|
|
let plantName = gData.gameData.getProductMap(data.picture - 1).name;
|
|
|
let des = this.getDesByType();
|
|
|
this.lbl_des.string = `${des}${this.data.value}次${plantName}后解锁\n(${times}/${data.value})`;;
|
|
|
|
|
|
- this.node_getBtn.active =false;
|
|
|
+ this.node_getBtn.active = false;
|
|
|
this.node_ungetBtn.active = false;
|
|
|
this.node_unluckBtn.active = true;
|
|
|
this.lbl_nameDes.node.active = false;
|
|
|
this.node_redPoint.active = false;
|
|
|
- }else
|
|
|
- {
|
|
|
+ } else {
|
|
|
this.sp_icon.spriteFrame = await mk.loader.load('module/farmMap/texture/gift', cc.SpriteFrame);
|
|
|
this.lbl_des.string = "神秘物种,等待发现";
|
|
|
- this.node_getBtn.active =false;
|
|
|
+ this.node_getBtn.active = false;
|
|
|
this.node_ungetBtn.active = false;
|
|
|
this.node_unluckBtn.active = true;
|
|
|
this.lbl_nameDes.node.active = false;
|
|
|
this.node_redPoint.active = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- getIndex()
|
|
|
- {
|
|
|
+ getIndex() {
|
|
|
let index: any = {};
|
|
|
index.i = 0;
|
|
|
index.j = 0;
|
|
|
- switch(this.data.tab)
|
|
|
- {
|
|
|
+ switch (this.data.tab) {
|
|
|
case '农作物':
|
|
|
index.i = 0;
|
|
|
index.j = this.data.picture - 10001;
|
|
|
@@ -160,24 +152,28 @@ export default class FarmItem extends cc.Component{
|
|
|
return des;
|
|
|
}
|
|
|
|
|
|
- private clickUnGetRewardBtn(){
|
|
|
+ private clickUnGetRewardBtn() {
|
|
|
mk.audio.playEffect("button");
|
|
|
|
|
|
-
|
|
|
- gData.farmMapData.isStateChange = true;
|
|
|
- this.node_getBtn.active =true;
|
|
|
- this.node_ungetBtn.active = false;
|
|
|
- this.node_unluckBtn.active = false;
|
|
|
- this.node_redPoint.active = false;
|
|
|
- gData.gameData.setFarmMapRewardState(this.getIndex(), 1);
|
|
|
+ mk.ad.videoAdType = VideoAdType.video_init_6;
|
|
|
+ mk.ad.watchAd((success) => {
|
|
|
+ if (success) {
|
|
|
+ gData.farmMapData.isStateChange = true;
|
|
|
+ this.node_getBtn.active = true;
|
|
|
+ this.node_ungetBtn.active = false;
|
|
|
+ this.node_unluckBtn.active = false;
|
|
|
+ this.node_redPoint.active = false;
|
|
|
+ gData.gameData.setFarmMapRewardState(this.getIndex(), 1);
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
- private clickUnluckBtn(){
|
|
|
+ private clickUnluckBtn() {
|
|
|
mk.audio.playEffect("button");
|
|
|
mk.tip.pop('未解锁');
|
|
|
}
|
|
|
|
|
|
- private clickGetRewardBtn(){
|
|
|
+ private clickGetRewardBtn() {
|
|
|
mk.audio.playEffect("button");
|
|
|
mk.tip.pop('已领取');
|
|
|
}
|