|
|
@@ -1,5 +1,6 @@
|
|
|
import Util from "../../before/util/Util";
|
|
|
import JsbSystem from "../../mk/system/JsbSystem";
|
|
|
+import SetGray from "../component/SetGray";
|
|
|
import { AdFun, RateConfig } from "../data/AdData";
|
|
|
import { DataEventId, GameProp, ProductType, VideoAdType } from "../data/GameData";
|
|
|
|
|
|
@@ -92,7 +93,21 @@ export default class Game extends cc.Component {
|
|
|
lbl_value: cc.Label[] = [];
|
|
|
|
|
|
//订单部分
|
|
|
-
|
|
|
+ @property({ displayName: '农作物图标', type: cc.Sprite })
|
|
|
+ sp_cropIcon: cc.Sprite[] = [];
|
|
|
+ @property({ displayName: '农作物名字', type: cc.Label })
|
|
|
+ lbl_cropName: cc.Label[] = [];
|
|
|
+ @property({ displayName: '农作物进度', type: cc.Label })
|
|
|
+ lbl_progress: cc.Label[] = [];
|
|
|
+ @property({ displayName: '进度完成对勾', type: cc.Sprite })
|
|
|
+ sp_mark: cc.Sprite[] = [];
|
|
|
+
|
|
|
+ @property({ displayName: '订单红包币数字组', type: cc.Label })
|
|
|
+ lbl_redMoneyValue: cc.Label[] = [];
|
|
|
+ @property({ displayName: '领奖按钮', type: SetGray })
|
|
|
+ node_getOrderReward: SetGray = null;
|
|
|
+
|
|
|
+
|
|
|
posY = 0;
|
|
|
/** 是否开始增加次数倒计时 */
|
|
|
private lastTimeSpan = 0;
|
|
|
@@ -123,6 +138,7 @@ export default class Game extends cc.Component {
|
|
|
|
|
|
this.initRefreshEvent();
|
|
|
|
|
|
+ this.initOrderUI();
|
|
|
}
|
|
|
|
|
|
start() {
|
|
|
@@ -201,7 +217,7 @@ export default class Game extends cc.Component {
|
|
|
if (!this.isShowAddProductTimesUI) {
|
|
|
this.isShowAddProductTimesUI = true;
|
|
|
if (add > 0) {
|
|
|
- add = add > gData.gameData.maxTimes ? gData.gameData.maxTimes :add;
|
|
|
+ add = add > gData.gameData.maxTimes ? gData.gameData.maxTimes : add;
|
|
|
gData.gameData.restoreProductTimes = add;
|
|
|
mk.ui.openPanel('module/speedUpUI/restoreProductTimes');
|
|
|
}
|
|
|
@@ -719,11 +735,20 @@ export default class Game extends cc.Component {
|
|
|
showChangePart() {
|
|
|
//this.changePart.active = true
|
|
|
let len = this.lbl_value.length;
|
|
|
+ let len2 = this.lbl_redMoneyValue.length;
|
|
|
this.schedule(() => {
|
|
|
+ //图鉴部分
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
let ran = Util.rnd(0, 9);
|
|
|
this.lbl_value[i].string = `${ran}`;
|
|
|
}
|
|
|
+
|
|
|
+ //订单部分
|
|
|
+ for (var i = 0; i < len2; i++) {
|
|
|
+ let ran = Util.rnd(0, 9);
|
|
|
+ this.lbl_redMoneyValue[i].string = `${ran}`;
|
|
|
+ }
|
|
|
+
|
|
|
}, 0.1)
|
|
|
}
|
|
|
|
|
|
@@ -835,20 +860,149 @@ export default class Game extends cc.Component {
|
|
|
|
|
|
//订单部分
|
|
|
|
|
|
- async doCropFlyLogic(plantId:number, farmNode: cc.Node)
|
|
|
- {
|
|
|
- let crop = await mk.pool.getPrefab('game/prefab/crop');
|
|
|
- let sf = await mk.loader.load("game/coregame/texture/plant_icons/plantIcon_" + plantId, cc.SpriteFrame);
|
|
|
- crop.getComponent(cc.Sprite).spriteFrame = sf;
|
|
|
- mk.fly.playFlyAniExtra(farmNode, this.node_taskHb, crop, 1);
|
|
|
+ private orderPicIdArray = [];
|
|
|
+ private isGray = true;
|
|
|
+ public async initOrderUI() {
|
|
|
+ let productJson = gData.gameData.configs.Product;
|
|
|
+ let data = gData.gameData.playerProp.orderData;
|
|
|
+ if (data) {
|
|
|
+ let len = data.orderTaskList.length;
|
|
|
+ if (len == 3) {
|
|
|
+ let completeCount = 0;
|
|
|
+ for (let i = 0; i != len; ++i) {
|
|
|
+ let dataE = data.orderTaskList[i];
|
|
|
+ if (dataE.Id <= productJson.length) {
|
|
|
+ let productData = productJson[dataE.Id - 1];
|
|
|
+
|
|
|
+ let plantPath = '';
|
|
|
+ let namePath = '';
|
|
|
+ if (productData.tab == ProductType.nzw) {
|
|
|
+ plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
|
|
|
+ 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_';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dataE.completeCount == dataE.taskCount) {
|
|
|
+ this.lbl_progress[i].node.active = false;
|
|
|
+ this.sp_mark[i].node.active = true;
|
|
|
+ ++completeCount;
|
|
|
+ } else {
|
|
|
+ this.lbl_progress[i].node.active = true;
|
|
|
+ this.sp_mark[i].node.active = false;
|
|
|
+ this.lbl_progress[i].string = `${dataE.completeCount}/${dataE.taskCount}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.orderPicIdArray.push({ "ID": dataE.Id, "picID": productData.picture });
|
|
|
+ this.lbl_cropName[i].string = productData.name;
|
|
|
+ this.sp_cropIcon[i].spriteFrame = await mk.loader.load(plantPath + productData.picture, cc.SpriteFrame);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('订单数据错误');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (completeCount >= 3) {
|
|
|
+ this.isGray = false;
|
|
|
+ this.node_getOrderReward.setGray(false, true);
|
|
|
+ } else {
|
|
|
+ this.isGray = true;
|
|
|
+ this.node_getOrderReward.setGray(true, true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('订单数据错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('订单数据错误');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public clickGetOrderRewardBtn() {
|
|
|
+ if (this.isGray) {
|
|
|
+ mk.tip.pop("订未完成");
|
|
|
+ } else {
|
|
|
+ this.getOrderReward();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public async getOrderReward() {
|
|
|
+ let data = {};
|
|
|
+ let response = await mk.http.sendData('orderTask/receiveReward', data);
|
|
|
+ if (response.errcode != 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ async doCropFlyLogic(plantId: number, farmNode: cc.Node, isNzw = false) {
|
|
|
+ for (let i = 0; i != this.orderPicIdArray.length; ++i) {
|
|
|
+ if (plantId == this.orderPicIdArray[i].picID) {
|
|
|
+ let data = gData.gameData.playerProp.orderData.orderTaskList[i];
|
|
|
+ if (data.completeCount < data.taskCount) {
|
|
|
+ let plantPath = '';
|
|
|
+ if (isNzw) {
|
|
|
+ plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ plantPath = 'game/coregame/texture/factory_icons/factory_';
|
|
|
+ }
|
|
|
+ let crop = await mk.pool.getPrefab('game/prefab/crop');
|
|
|
+ let sf = await mk.loader.load(plantPath + plantId, cc.SpriteFrame);
|
|
|
+ crop.getComponent(cc.Sprite).spriteFrame = sf;
|
|
|
+ mk.fly.playFlyAniExtra(farmNode, this.node_taskHb, crop, 1, () => {
|
|
|
+ this.updataOrderProgress(this.orderPicIdArray[i].ID, i);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- async cloneCropFuc(plantId: number)
|
|
|
- {
|
|
|
-
|
|
|
- //iconPath = "game/coregame/texture/plant_icons/plantIcon_";
|
|
|
-
|
|
|
- //this.icon_plantName.spriteFrame = await mk.loader.load(namePath + gData.gameData.nextCanProduct.picture, cc.SpriteFrame);
|
|
|
+ public async updataOrderProgress(id, index) {
|
|
|
+ let data = { "id": id };
|
|
|
+ let response = await mk.http.sendData('orderTask/updateUserOrderTaskInfo', data);
|
|
|
+ if (response.errcode != 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ gData.gameData.playerProp.orderData = response.data.userOrderTaskInfo;
|
|
|
+
|
|
|
+ let orderData = gData.gameData.playerProp.orderData;
|
|
|
+ if (orderData) {
|
|
|
+ let isComplete = true;
|
|
|
+ let len = orderData.orderTaskList.length;
|
|
|
+ for (let i = 0; i != len; ++i) {
|
|
|
+ let dataE = orderData.orderTaskList;
|
|
|
+ if (dataE[i].completeCount < dataE[i].taskCount) {
|
|
|
+ isComplete = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isComplete) {
|
|
|
+ this.isGray = false;
|
|
|
+ this.node_getOrderReward.setGray(false, true);
|
|
|
+ } else {
|
|
|
+ let dataE = orderData.orderTaskList[index];
|
|
|
+ if(dataE)
|
|
|
+ {
|
|
|
+ if(dataE.completeCount == dataE.taskCount)
|
|
|
+ {
|
|
|
+ this.lbl_progress[index].node.active = false;
|
|
|
+ this.sp_mark[index].node.active = true;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ this.lbl_progress[index].string = `${dataE.completeCount}/${dataE.taskCount}`;
|
|
|
+ cc.Tween.stopAllByTarget(this.lbl_progress[index].node);
|
|
|
+ cc.tween(this.lbl_progress[index].node).to(0.1, { scale: 1.2 }).to(0.05, { scale: 1 }).start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|