wuwangdong 4 år sedan
förälder
incheckning
bcc59d4a54

+ 2 - 2
assets/resources/game/prefab/crop.prefab

@@ -55,8 +55,8 @@
         0,
         0,
         1,
-        0.5,
-        0.5,
+        0.4,
+        0.4,
         1
       ]
     },

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 215 - 152
assets/resources/game/prefab/game.prefab


+ 5 - 5
assets/resources/game/prefab/uiPanel/HarvestPanel.prefab

@@ -2553,7 +2553,7 @@
     "asset": {
       "__uuid__": "04dd6ff2-c365-488b-9c49-8994289ce473"
     },
-    "fileId": "f9thIMQw1BP6RO+BATbRFG",
+    "fileId": "53XjU167tFdonAJIUfz8yJ",
     "sync": false
   },
   {
@@ -2664,7 +2664,7 @@
     "asset": {
       "__uuid__": "04dd6ff2-c365-488b-9c49-8994289ce473"
     },
-    "fileId": "a4+zjptnRMEYkueFXA/4wA",
+    "fileId": "4d9TjEuqhEXYs7tTS5+AwJ",
     "sync": false
   },
   {
@@ -2775,7 +2775,7 @@
     "asset": {
       "__uuid__": "04dd6ff2-c365-488b-9c49-8994289ce473"
     },
-    "fileId": "baL+7FGXhIFI6f7i2GQyTJ",
+    "fileId": "b4b4F0whdG96kvFzNzS5Ny",
     "sync": false
   },
   {
@@ -3134,8 +3134,8 @@
     "_isSystemFontUsed": true,
     "_spacingX": 0,
     "_batchAsBitmap": false,
-    "_styleFlags": 0,
-    "_underlineHeight": 0,
+    "_styleFlags": 4,
+    "_underlineHeight": 2,
     "_N$horizontalAlign": 1,
     "_N$verticalAlign": 1,
     "_N$fontFamily": "Arial",

+ 3 - 1
assets/script/before/main/FactoryIcon.ts

@@ -142,6 +142,7 @@ export class FactoryIcon extends cc.Component {
 
             gData.gameData.isProducting = false;
 
+            gData.gameData.updateOrderTaskCopyData(this.data.productID);
             gData.gameData.nextMake = null;
             gData.gameData.setNextProduct(false);
 
@@ -175,7 +176,7 @@ export class FactoryIcon extends cc.Component {
         gData.gameData.setFactoryDataMap(this.configID, this.data, sendToServer);
     }
 
-    public onHarvest(): void {
+    public async onHarvest(){
         this.countDown.cleanRiped();
         this.clean();
         gData.factorySystem.currSelectFactory = null;
@@ -184,6 +185,7 @@ export class FactoryIcon extends cc.Component {
         this.data.productID = 0;
         this.data.growSpan = 0;
         gData.gameData.setFactoryDataMap(this.configID, this.data);
+        await gData.gameData.gameStyle.doCropFlyLogic(this.data.productID, this.node);
         gData.gameData.setNextProduct(false);
 
         if (gData.harvestData.getType == 0) {

+ 2 - 1
assets/script/before/main/FactorySystem.ts

@@ -34,6 +34,7 @@ export default class FactorySystem {
     public nextFactory(out?: any) {
 
         let data = gData.gameData.playerProp.orderData;
+        let copyData = gData.gameData.playerProp.copyOrderData
         if (data && data.orderTaskList) {
             if(out.state == 1)
             {
@@ -41,7 +42,7 @@ export default class FactorySystem {
                 let productJson = gData.gameData.configs.Product;
                 for (let index = 0; index != orderData.length; ++index) {
                     let dataE = orderData[index];
-                    if (dataE.completeCount < dataE.taskCount && dataE.Id <= productJson.length) {
+                    if (copyData[index] < dataE.taskCount && dataE.Id <= productJson.length) {
                         let productData = productJson[dataE.Id - 1];
     
                         let len = this.factoryIcons.length;

+ 3 - 3
assets/script/before/main/FarmIcon.ts

@@ -143,7 +143,7 @@ export class FarmIcon extends cc.Component {
         }
     }
 
-    public onHarvest(): void {
+    public async onHarvest(){
         this.countDown.cleanRiped();
         this.process.cleanProcess();
         gData.farmSystem.currSelectFarm = null;
@@ -152,6 +152,7 @@ export class FarmIcon extends cc.Component {
         this.data.productID = 0;
         this.data.growSpan = 0;
         gData.gameData.setFarmDataMap(this.configID, this.data);
+        await gData.gameData.gameStyle.doCropFlyLogic(this.plantID, this.node, true);
         gData.gameData.setNextProduct(false);
 
         if (gData.harvestData.getType == 0) {
@@ -163,8 +164,6 @@ export class FarmIcon extends cc.Component {
 
         let child = this.node.getChildByName('hb');
         this.node.removeChild(child);
-
-        gData.gameData.gameStyle.doCropFlyLogic(this.plantID, this.node);
     }
 
     public async plant(id: number) {
@@ -182,6 +181,7 @@ export class FarmIcon extends cc.Component {
             gData.gameData.addProductMakeTimesById(this.plantID);
 
             gData.gameData.nextMake = null;
+            gData.gameData.updateOrderTaskCopyData(id);
             gData.gameData.setNextProduct(false);
 
             this.plantIcon.spriteFrame = await mk.loader.load("game/coregame/texture/plant_icons/plantIcon_" + this.plantID, cc.SpriteFrame);

+ 3 - 1
assets/script/before/main/PastureIcon.ts

@@ -228,6 +228,7 @@ export default class PastureIcon extends cc.Component {
 
             gData.gameData.isProducting = false;
 
+            gData.gameData.updateOrderTaskCopyData(this.data.productID);
             gData.gameData.nextMake = null;
             gData.gameData.setNextProduct(false);
             
@@ -272,13 +273,14 @@ export default class PastureIcon extends cc.Component {
         gData.gameData.setPastureDataMap(this.configID, this.data, sendToServer);
     }
 
-    public onHarvest(): void {
+    public async onHarvest(){
         this.countDown.cleanRiped();
         this.clean();
 
         this.data.state = PastureState.Empty;
         this.data.growSpan = 0;
         gData.gameData.setPastureDataMap(this.configID, this.data);
+        await gData.gameData.gameStyle.doCropFlyLogic(this.data.productID, this.node);
         gData.gameData.setNextProduct(false);
 
         if (gData.harvestData.getType == 0) {

+ 2 - 1
assets/script/before/main/PastureSystem.ts

@@ -30,12 +30,13 @@ export default class PastureSystem {
     /** 下一个空置饲养场 */
     nextPasture(out?: any) {
         let data = gData.gameData.playerProp.orderData;
+        let copyData = gData.gameData.playerProp.copyOrderData
         if (data && data.orderTaskList) {
             let orderData = data.orderTaskList;
             let productJson = gData.gameData.configs.Product;
             for (let index = 0; index != orderData.length; ++index) {
                 let dataE = orderData[index];
-                if (dataE.completeCount < dataE.taskCount && dataE.Id <= productJson.length) {
+                if (copyData[index] < dataE.taskCount && dataE.Id <= productJson.length) {
                     let productData = productJson[dataE.Id - 1];
 
                     let len = this.pastureIcons.length;

+ 89 - 58
assets/script/game/data/GameData.ts

@@ -1,6 +1,7 @@
 import Util from "../../before/util/Util";
 import FunBtns from "../game/FunBtns";
 import Game from "../game/Game";
+import { StorageKey } from "./StorageData";
 
 /**
  * @description 游戏核心玩法数据
@@ -211,6 +212,7 @@ export class GameData {
         this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
         this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
         this.playerProp.orderData = res_data.userOrderTaskInfo;
+        this.cloneOrderData();
 
         mk.data.setTAUserID(gData.loginData.uin);
         mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
@@ -242,6 +244,42 @@ export class GameData {
         // this.playerProp.completeFarmTaskTimes = 3;
     }
 
+    public cloneOrderData(isRefresh = false) {
+
+        let value = mk.storage.getStorage(StorageKey.copyOrderData);
+        if (value && !isRefresh) {
+            this.playerProp.copyOrderData = value;
+        } else {
+            if (this.playerProp.orderData) {
+                this.playerProp.copyOrderData = [];
+                let len = this.playerProp.orderData.orderTaskList.length;
+                for (let i = 0; i != len; ++i) {
+                    this.playerProp.copyOrderData.push(this.playerProp.orderData.orderTaskList[i].completeCount);
+                }
+                mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
+            }
+        }
+    }
+
+    public updateOrderTaskCopyData(id: number) {
+        if (this.playerProp.orderData) {
+            let productJson = this.configs.Product;
+            let orderData = this.playerProp.orderData.orderTaskList;
+            let len = orderData.length;
+            for (let i = 0; i != len; ++i) {
+                let dataE = orderData[i];
+                if (dataE.Id <= productJson.length) {
+                    let productData = productJson[dataE.Id - 1];
+                    if (productData.picture == id) {
+                        this.playerProp.copyOrderData[i]++;
+                        mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * 保存单个数据
      */
@@ -446,69 +484,63 @@ export class GameData {
     public needFreshArr = [];
 
     /** 随机获取可种植物品 */
-    getRandomPlantConfig(out?:any) {
+    getRandomPlantConfig(out?: any) {
         let id = 0;
         let isNoHaveCurTab = true;
         let isNoAllComplete = false;
         let isOrderDataInvalid = false;
+        let isMatchSuccess = false;
         let productType = [];
         let animalId = [];
-        let data = gData.gameData.playerProp.orderData;
-        let orderData =  data.orderTaskList;
-        if(data && orderData)
-        {
-            let productJson = gData.gameData.configs.Product;
-            for(let i = 0; i != orderData.length; ++i)
-            {
+        let data = this.playerProp.orderData;
+        let orderData = data.orderTaskList;
+        if (data && orderData) {
+            let productJson = this.configs.Product;
+            for (let i = 0; i != orderData.length; ++i) {
                 let dataE = orderData[i];
-                if (dataE.completeCount < dataE.taskCount && dataE.Id <= productJson.length) {
-                    
-                    isNoAllComplete = true;
-                    let productData = productJson[dataE.Id - 1];
-                    if(productData.tab == ProductType.nzw)
-                    {
-                        let max = gData.gameData.getMaxProduct(ProductType.nzw);
-                        if(productData.picture <= max)
-                        {
-                            id = productData.picture;
-                            isNoHaveCurTab = false;
-                            mk.console.logSingle("getRandomPlantConfig=>", id);
-                            break;
-                        }            
-                    }else if(productData.tab == ProductType.dw)
-                    {
-                        animalId.push(productData.picture);
-                    }else{
-                        productType.push(productData.tab);
+                if (this.playerProp.copyOrderData[i] < dataE.taskCount) {
+                    if (dataE.Id <= productJson.length) {
+                        isNoAllComplete = true;
+                        let productData = productJson[dataE.Id - 1];
+                        if (productData.tab == ProductType.nzw) {
+                            let max = this.getMaxProduct(ProductType.nzw);
+                            if (productData.picture <= max) {
+                                id = productData.picture;
+                                isNoHaveCurTab = false;
+                                isMatchSuccess = true;
+                                mk.console.logSingle("getRandomPlantConfig=>", id);
+                                break;
+                            }
+                        } else if (productData.tab == ProductType.dw) {
+                            animalId.push(productData.picture);
+                        } else {
+                            productType.push(productData.tab);
+                        }
+                    } else {
+                        isOrderDataInvalid = true;
+                        console.log("订单数据有问题,随机id");
+                        break;
                     }
-                    
-                }else{
-                    isOrderDataInvalid = true;
-                    id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
-                    console.log("订单数据有问题,随机id");
-                    break;
                 }
             }
 
-            id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
-            console.log("订单数据没有合适的物品");
-        }else{
+            if (!isMatchSuccess) {
+                id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
+                console.log("订单数据没有匹配成功");
+            }
+        } else {
             isOrderDataInvalid = true;
             id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
             console.log("订单数据为null");
         }
 
-        if(isOrderDataInvalid)
-        {
+        if (isOrderDataInvalid) {
             return this.getProductMap(id);
-        }else{
-            if(isNoHaveCurTab)
-            {
-                if(isNoAllComplete)
-                {
+        } else {
+            if (isNoHaveCurTab) {
+                if (isNoAllComplete) {
                     let isHaveEmpty = false;
-                    for(let i = 0; i != productType.length; ++i)
-                    {
+                    for (let i = 0; i != productType.length; ++i) {
                         let factoryIcon = gData.factorySystem.factoryIcons;
                         let len = factoryIcon.length;
                         for (var j = 0; j < len; j++) {
@@ -516,19 +548,17 @@ export class GameData {
                             if (tab == productType[j] && factoryIcon[j].data.state == FactroyState.Empty) {
                                 isHaveEmpty = true;
                                 out.state = 1;
-                               break;
+                                break;
                             }
                         }
                     }
 
-                    if(!isHaveEmpty)
-                    {
-                        for(let i = 0; i != animalId.length; ++i)
-                        {
+                    if (!isHaveEmpty) {
+                        for (let i = 0; i != animalId.length; ++i) {
                             let pastureIcon = gData.pastureSystem.pastureIcons;
                             let len = pastureIcon.length;
                             for (var j = 0; j < len; j++) {
-                                if (pastureIcon[j].data.productID ==animalId[i] && pastureIcon[j].data.state == PastureState.Empty) {
+                                if (pastureIcon[j].data.productID == animalId[i] && pastureIcon[j].data.state == PastureState.Empty) {
                                     isHaveEmpty = true;
                                     out.state = 2;
                                     break;
@@ -537,19 +567,18 @@ export class GameData {
                         }
                     }
 
-                    if(isHaveEmpty)
-                    {
+                    if (isHaveEmpty) {
                         return null;
 
-                    }else{
+                    } else {
                         return this.getProductMap(id);
                     }
-                }else{
+                } else {
                     return this.getProductMap(id);
                 }
-            }else{
+            } else {
                 return this.getProductMap(id);
-            }    
+            }
         }
 
         //id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
@@ -583,7 +612,7 @@ export class GameData {
             return;
         }
         //-1无效,1:工厂有空位,2:饲养厂有空位
-        let haveEmpty = {state: -1};
+        let haveEmpty = { state: -1 };
         let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
         if (!next) {
             let next1 = gData.pastureSystem.nextPasture(haveEmpty);
@@ -1490,6 +1519,8 @@ class PlayerProp {
 
     /** 订单数据 */
     orderData = null;
+    /** 临时订单数据, 只用于种植优先选择作用 */
+    copyOrderData = null;
 }
 
 /**

+ 1 - 0
assets/script/game/data/StorageData.ts

@@ -23,4 +23,5 @@ export enum StorageKey{
     nickname = 'nickname',
     isAuth = 'isAuth',
     avatar = 'avatar',
+    copyOrderData = 'copyOrderData',
 }

+ 2 - 1
assets/script/game/data/module/LineUpUIData.ts

@@ -22,12 +22,13 @@ export class LineUpUIData extends Data {
         super.setAdData(data);
 
         this.redMoney = 0;
-        let rewardData = gData.lineUpUIData.adData.videoRedMoney.videoRewardList;
+        let rewardData = this.adData.videoRedMoney.videoRewardList;
         for(let i = 0; i != rewardData.length; ++i)
         {
             if(rewardData[i].rewardType == RewardType.redBag)
             {
                 this.redMoney = rewardData[i].rewardNum;
+                gData.gameData.playerProp.redMoney += this.redMoney;
                 break;
             }
         }

+ 31 - 15
assets/script/game/game/Game.ts

@@ -863,6 +863,8 @@ export default class Game extends cc.Component {
     private orderPicIdArray = [];
     private isGray = true;
     public async initOrderUI() {
+        this.orderPicIdArray = [];
+        this.isGray = true;
         let productJson = gData.gameData.configs.Product;
         let data = gData.gameData.playerProp.orderData;
         if (data) {
@@ -923,7 +925,7 @@ export default class Game extends cc.Component {
 
     public clickGetOrderRewardBtn() {
         if (this.isGray) {
-            mk.tip.pop("订未完成");
+            mk.tip.pop("订未完成");
         } else {
             this.getOrderReward();
         }
@@ -935,7 +937,15 @@ export default class Game extends cc.Component {
         if (response.errcode != 0) {
             return null;
         }
+        gData.gameData.playerProp.orderData = response.data.userOrderTaskInfo;
+        gData.gameData.cloneOrderData(true);
+
+        gData.reward.adData = {videoRedMoney: {videoRewardList:null}};
+        gData.reward.adData.videoRedMoney.videoRewardList = [{ rewardType: 1, rewardNum: response.data.redMoneyAddition }]
+        //gData.reward.adData = response.data.redMoneyAddition;
+        mk.ui.openPanel('module/reward/reward');
 
+        this.initOrderUI();
     }
 
     async doCropFlyLogic(plantId: number, farmNode: cc.Node, isNzw = false) {
@@ -953,24 +963,18 @@ export default class Game extends cc.Component {
                     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);
-                    });
+                    await this.updataOrderProgress(this.orderPicIdArray[i].ID);
+                    mk.fly.playFlyAniExtra(farmNode, this.sp_cropIcon[i].node, crop, 0.6, ()=>{
+                        this.doFlyOrderAni(i);
+                    });       
                 }
                 break;
             }
         }
     }
 
-    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;
-
+    public doFlyOrderAni(index)
+    {
         let orderData = gData.gameData.playerProp.orderData;
         if (orderData) {
             let isComplete = true;
@@ -986,7 +990,9 @@ export default class Game extends cc.Component {
             if (isComplete) {
                 this.isGray = false;
                 this.node_getOrderReward.setGray(false, true);
-            } else {
+            } 
+            
+            {
                 let dataE = orderData.orderTaskList[index];
                 if(dataE)
                 {       
@@ -998,11 +1004,21 @@ export default class Game extends cc.Component {
                         
                         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();
+                        cc.tween(this.lbl_progress[index].node).to(0.1, { scale: 1.4 }).to(0.05, { scale: 1 }).start();
                     }
                 }
             }
         }
     }
+
+    public async updataOrderProgress(id) {
+        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;
+    }
 }
 

Vissa filer visades inte eftersom för många filer har ändrats