فهرست منبع

修改时间显示bug,收获触发bug

slambb 3 سال پیش
والد
کامیت
94c36ed09b

+ 9 - 9
assets/Prefabs/NBuildings/Labour/Labour_205_Holy_Farmland.prefab

@@ -661,7 +661,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 150,
+      "width": 158,
       "height": 28
     },
     "_anchorPoint": {
@@ -764,7 +764,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 140,
+      "width": 150,
       "height": 20
     },
     "_anchorPoint": {
@@ -1917,7 +1917,7 @@
       "__id__": 14
     },
     "_enabled": true,
-    "_N$totalLength": 200,
+    "_N$totalLength": 150,
     "_N$barSprite": {
       "__id__": 19
     },
@@ -2168,7 +2168,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 100,
+      "width": 102,
       "height": 25
     },
     "_anchorPoint": {
@@ -2228,8 +2228,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 95,
-      "height": 18
+      "width": 100,
+      "height": 20
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -2278,7 +2278,7 @@
     "_spriteFrame": {
       "__uuid__": "274aa6c2-366e-4a0f-9623-b640a861075c"
     },
-    "_type": 2,
+    "_type": 0,
     "_sizeMode": 0,
     "_fillType": 0,
     "_fillCenter": {
@@ -2689,12 +2689,12 @@
       "__id__": 59
     },
     "_enabled": true,
-    "_N$totalLength": 178,
+    "_N$totalLength": 100,
     "_N$barSprite": {
       "__id__": 61
     },
     "_N$mode": 0,
-    "_N$progress": 0.9,
+    "_N$progress": 1,
     "_N$reverse": false,
     "_id": ""
   },

+ 5 - 0
assets/Prefabs/UI/lease/SalePanel.prefab

@@ -2654,6 +2654,11 @@
       "__id__": 33
     },
     "inputInviteValue": 1,
+    "fruitInfo": null,
+    "upTarget": null,
+    "inputContainer": {
+      "__id__": 46
+    },
     "_id": ""
   },
   {

+ 8 - 4
assets/Script/Lease/LeaseGrantInfo.js

@@ -64,7 +64,7 @@ cc.Class({
         this.node.destroy();
     },
 
-    //确定销售果实
+    //确定增送果实
     onLeaseGrantFruit() {
         //todo 判断一下amount
         console.log(this.inputInviteValue);
@@ -79,10 +79,14 @@ cc.Class({
         GlobalD.GameData.onGrantFruit({ fruitId: this.fruitInfo.id, amount: Number(this.amount.string), address: this.inputInviteValue }, (res, value) => {
             // console.log(value);
             if (value.code === 0) {
-                let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
+                // let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
                 //这里只隐藏
-                this.upTarget.active = false;
-                NumLabel.string = 0;
+                // this.upTarget.active = false;
+                // NumLabel.string = 0;
+
+                var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
+                BuildingView.onUpdateList();
+
                 this.saleAmount.string = 0;
 
                 GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {

+ 19 - 8
assets/Script/Lease/LeaseSaleInfo.js

@@ -28,6 +28,11 @@ cc.Class({
             type: cc.Node,
             tooltip: "把当前操作的ui按钮传进来"
         },
+        inputContainer: {
+            default: null,
+            type: cc.Node,
+            tooltip: "inputEditbox"
+        },
 
     },
     inputValue(value, e) {
@@ -69,14 +74,20 @@ cc.Class({
         GlobalD.GameData.onSaleFruit({ fruitId: this.fruitInfo.id, amount: this.inputInviteValue }, (res, value) => {
             // console.log(value);
             if (value.code === 0) {
-                let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
-                if (parseInt(NumLabel.string) <= 1) {
-                    //这里只隐藏
-                    this.upTarget.active = false;
-                } else {
-                    NumLabel.string = parseInt(NumLabel.string) - this.inputInviteValue;
-                    this.saleAmount.string = parseInt(this.saleAmount.string) - this.inputInviteValue;
-                }
+                // let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
+                // if (parseInt(NumLabel.string) <= this.inputInviteValue) {
+                //     //这里只隐藏
+                //     this.upTarget.active = false;
+                // } else {
+                //     NumLabel.string = parseInt(NumLabel.string) - this.inputInviteValue;
+                //     this.saleAmount.string = parseInt(this.saleAmount.string) - this.inputInviteValue;
+                // }
+                GlobalD.GameData.SetSNB(GlobalD.GameData.GetSNB() + (this.inputInviteValue*this.fruitInfo.priceSnb));
+
+                var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
+                BuildingView.onUpdateList();
+                this.saleAmount.string = parseInt(this.saleAmount.string) - this.inputInviteValue;
+    
                 GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "成功售卖了!", 2, () => {
                     console.log("finish toast!");
                 });

+ 24 - 18
assets/Script/Network/dapp.js

@@ -12,7 +12,7 @@ cc.Class({
     onLoad() {
         // cc.view.enableAutoFullScreen(false);
         cc.game.addPersistRootNode(this.node);
-    
+
         async function dappInit() {
             console.log("初始化 dappInit");
             let dapp = GlobalD.dapp = new Dapp()
@@ -88,31 +88,37 @@ cc.Class({
                                 //记录读取的数据到内存里面
                                 // 正常游戏
                                 userData.readData = _playerData;
-                                //跳转游戏
-                                cc.find("Canvas").getComponent("Login").loginButton();
 
                                 // utils.init(GlobalD.Dapp.UserInfo.id, (data) => {
                                 //     console.log('utils ws:' + data);
                                 // }, _self);
-                            })
-                            //需要提前拉取一下土地配置,用于初始化地图土地
-                            utils.get(utils.api.landConfig, {}, (res, value) => {
-                                if (0 === value.code) {
-                                    GlobalD.ConfigLand = value.data;
-                                } else {
-                                    console.warn("未能读取到config土地?");
-                                }
-                            })
 
-                            utils.get(utils.api.userLandList, {}, (res, value) => {
-                                if (0 === value.code) {
-                                    GlobalD.UserLeaseLand = value.data;
-                                } else {
-                                    console.warn("读取到用户的土地错误?");
-                                }
+                                //需要提前拉取一下土地配置,用于初始化地图土地
+                                utils.get(utils.api.landConfig, {}, (res, value) => {
+                                    if (0 === value.code) {
+                                        GlobalD.ConfigLand = value.data;
+                                        
+                                        utils.get(utils.api.userLandList, {}, (res, value) => {
+                                            if (0 === value.code) {
+                                                GlobalD.UserLeaseLand = value.data;
+
+                                                //跳转游戏
+                                                cc.find("Canvas").getComponent("Login").loginButton();
+
+                                            } else {
+                                                console.warn("读取到用户的土地错误?");
+                                            }
+                                        })
+                                    } else {
+                                        console.warn("未能读取到config土地?");
+                                    }
+                                })
                             })
 
 
+
+
+
                         } else {
                             console.log(res, value);
                         }

+ 6 - 0
assets/Script/UI/BuildingView.js

@@ -127,10 +127,16 @@ cc.Class({
         //先判断container下面是否存在Seed
         // this.Seed.destroyAllChildren;
         // console.log("this.Seed.children:", this.Seed.children);
+         //清除种子的预制
         let _children = this.Seed.children;
         for (let i = _children.length - 1; i > 0; i--) {
             _children[i].destroy();
         }
+        //清除仓库的预制
+        let _fruitChildren = this.Fruit.children;
+        for (let i = _fruitChildren.length - 1; i > 0; i--) {
+            _fruitChildren[i].destroy();
+        }
         // console.log("this.Seed.children2:", this.Seed.children);
 
         //获取种子和果实

+ 9 - 5
assets/Script/UI/ManageBuildings.js

@@ -544,14 +544,18 @@ cc.Class({
                         // let _plantStart = Date.parse(_leaseLandInfo.plantStart.replace(/-/g, '/'))
                         // let _currentDay = _plantStart.getTime() - new Date().getTime(); //date.datedifference(date.formatTime(new Date()), _leaseLandInfo.plantStart);
                         //种植日期加成熟期
-                        let _endMilli = date.addDayTranMillisecond(_leaseLandInfo.plantStart, _leaseLandInfo.seedInfo.maturity);
-                        let _currentMilli = new Date().getTime();
-                        let _ratio = _currentMilli / _endMilli;
-                        if (_ratio <= 0.3) {
+                        // let _endMilli = date.addDayTranMillisecond(_leaseLandInfo.plantStart, _leaseLandInfo.seedInfo.maturity);
+                        // let _currentMilli = new Date().getTime();
+                        let _currentDay = date.dateAddDate(_leaseLandInfo.plantStart, _leaseLandInfo.seedInfo.maturity)
+                        let [_remainingDay, _remainingHour] = date.remainDayAndHour(_currentDay, date.formatTime(new Date()));
+                        let _maturityHour = _leaseLandInfo.seedInfo.maturity * 24
+                        let _ratio = _remainingHour / _maturityHour;
+                        // console.log("生成的:" + _ratio);
+                        if (_ratio > 0.6) {
                             _workingBuilding.onSetGrow(1, _spriteFrame);
                             //测试,后面删除
                             // leaseFarmlandInfoScript.onShowHarvest();
-                        } else if (_ratio < 1) {
+                        } else if (_ratio > 0) {
                             _workingBuilding.onSetGrow(2, _spriteFrame);
                         } else {
                             //成熟阶段

+ 4 - 4
assets/Script/UI/ManageSeedNode.js

@@ -198,17 +198,17 @@ cc.Class({
                 BuildingView.onUpdateList();
 
                 //把种子的信息存储到当前的土地 plantInfo 上;
-                _leaseFarmlandInfo.plantInfo = value.data.seedInfo;
-                _leaseFarmlandInfo.updateLandState();
+                _leaseFarmlandInfo.setLeaseLandInfo(value.data);
+
                 //开始种植,给一个初始的状态
                 this.targetBuildingsInfo.onInitHolyFarmlandSeedFromGrow(1, this.fruitSpriteFrame);
 
-                GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "已成功种植!", 2, () => {
+                GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "已成功种植!", 1, () => {
                     console.log("finish toast!");
                 });
             } else if (value.code == 704) {
                 //土地已经种植了
-                GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 2, () => {
+                GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1, () => {
                     console.log("finish toast!");
                 });
             }

+ 45 - 39
assets/Script/Unit/date.js

@@ -37,10 +37,10 @@ const datedifference = (sDate1, sDate2) => { //sDate1和sDate2是2006-12-18格
 	return iDays
 };
 
-const getDays =(date1, date2)=> {
-    const dateTime = 1000 * 60 * 60 * 24; //每一天的毫秒数
-    const minusDays = Math.floor(((date2.getTime() - date1.getTime()) / dateTime));//计算出两个日期的天数差
-    return Math.abs(minusDays);
+const getDays = (date1, date2) => {
+	const dateTime = 1000 * 60 * 60 * 24; //每一天的毫秒数
+	const minusDays = Math.floor(((date2.getTime() - date1.getTime()) / dateTime));//计算出两个日期的天数差
+	return Math.abs(minusDays);
 }
 
 /**
@@ -49,76 +49,82 @@ const getDays =(date1, date2)=> {
  * @param  {[int]} dayCount [增加的天数]
  * @return {[string]}[增加n天后的日期字符串]
  */
-const dateAddDays=(dateStr,dayCount) => {
-    var tempDate=new Date(dateStr.replace(/-/g,"/"));//把日期字符串转换成日期格式
-    var resultDate=new Date((tempDate/1000+(86400*dayCount))*1000);//增加n天后的日期
-    var resultDateStr=resultDate.getFullYear()+"-"+(resultDate.getMonth()+1)+"-"+(resultDate.getDate());//将日期转化为字符串格式
-    return resultDateStr;
+const dateAddDays = (dateStr, dayCount) => {
+	var tempDate = new Date(dateStr.replace(/-/g, "/"));//把日期字符串转换成日期格式
+	var resultDate = new Date((tempDate / 1000 + (86400 * dayCount)) * 1000);//增加n天后的日期
+	var resultDateStr = resultDate.getFullYear() + "-" + (resultDate.getMonth() + 1) + "-" + (resultDate.getDate());//将日期转化为字符串格式
+	return resultDateStr;
 }
 
 
 /**
  * 根据newDate 来获取加的日期
  */
-const addDaysFromNewDate=(tempDate,dayCount) => {
-    var resultDate=new Date((tempDate/1000+(86400*dayCount))*1000);//增加n天后的日期
- //    var resultDateStr=resultDate.getFullYear()+"/"+(resultDate.getMonth()+1)+"/"+(resultDate.getDate());//将日期转化为字符串格式
+const addDaysFromNewDate = (tempDate, dayCount) => {
+	var resultDate = new Date((tempDate / 1000 + (86400 * dayCount)) * 1000);//增加n天后的日期
+	//    var resultDateStr=resultDate.getFullYear()+"/"+(resultDate.getMonth()+1)+"/"+(resultDate.getDate());//将日期转化为字符串格式
 	// return resultDateStr;
-	
+
 	const year = resultDate.getFullYear();
 	const month = resultDate.getMonth() + 1;
 	const day = resultDate.getDate();
-	
+
 	return [year, month, day].map(formatNumber).join('/')
-	
+
 }
 
 const getWeightDate = date => {
 	var timearr = date.replace(" ", ":").replace(/\:/g, "-").split("-");
 	var timestr = "" + timearr[1] + "/" + timearr[2]
-	return timestr 
+	return timestr
 }
 
 
 
 
-const dateAddDate=(dateStr,dayCount) => {
-    var tempDate=new Date(dateStr.replace(/-/g,"/"));//把日期字符串转换成日期格式
-    var resultDate=new Date((tempDate/1000+(86400*dayCount))*1000);//增加n天后的日期
+const dateAddDate = (dateStr, dayCount) => {
+	var tempDate = new Date(dateStr.replace(/-/g, "/"));//把日期字符串转换成日期格式
+	var resultDate = new Date((tempDate / 1000 + (86400 * dayCount)) * 1000);//增加n天后的日期
 
 	const year = resultDate.getFullYear()
-	const month = resultDate.getMonth()+1
+	const month = resultDate.getMonth() + 1
 	const day = resultDate.getDate()
 
 	const hour = resultDate.getHours()
 	const minute = resultDate.getMinutes()
 	const second = resultDate.getSeconds()
-    //将日期转化为字符串格式
-    return [year, month, day].map(formatNumber).join('/')  + ' ' + [hour, minute, second].map(formatNumber).join(':');
+	//将日期转化为字符串格式
+	return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
 }
 
 
-const addDayTranMillisecond=(dateStr,dayCount) => {
-    var tempDate=new Date(dateStr.replace(/-/g,"/"));//把日期字符串转换成日期格式
-    var resultDate=new Date((tempDate/1000+(86400*dayCount))*1000);//增加n天后的日期
-    //将日期转化为字符串格式
-    return resultDate.getTime();
+const addDayTranMillisecond = (dateStr, dayCount) => {
+	var tempDate = new Date(dateStr.replace(/-/g, "/"));//把日期字符串转换成日期格式
+	var resultDate = new Date((tempDate / 1000 + (86400 * dayCount)) * 1000);//增加n天后的日期
+	//将日期转化为字符串格式
+	return resultDate.getTime();
 }
 
-
-const dayAndHour = (sDate1, sDate2) => { //sDate1和sDate2是2006-12-18格式 
+//计算剩余时间
+const remainDayAndHour = (sDate1, currentDate) => { //sDate1和sDate2是2006-12-18格式 
 	var dateSpan,
 		tempDate,
 		iDays;
 	sDate1 = Date.parse(sDate1.replace(/-/g, '/'));
-	sDate2 = Date.parse(sDate2.replace(/-/g, '/'));
-	dateSpan = sDate2 - sDate1;
-	dateSpan = Math.abs(dateSpan);
-	iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
-
-	//  计算小时数
-	var hours = Math.floor(dateSpan / (60 * 60 * 1000));
-	return [iDays,hours];
+	currentDate = Date.parse(currentDate.replace(/-/g, '/'));
+	dateSpan = currentDate - sDate1;
+	// console.log(dateSpan);
+
+	if (dateSpan < 0) {
+		dateSpan = Math.abs(dateSpan);
+		iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
+		//  计算小时数
+		var hours = Math.floor(dateSpan / (60 * 60 * 1000));
+		// console.log(iDays,hours);
+		return [iDays, hours];
+	} else {
+		return [0, 0];
+	}
 };
 
 export default {
@@ -129,9 +135,9 @@ export default {
 	dateAddDays,
 	addDaysFromNewDate,
 	getWeightDate,
-	
+
 	dateAddDate,
-	dayAndHour,
+	remainDayAndHour,
 
 	addDayTranMillisecond
 }

+ 19 - 10
assets/Script/build/LeaseFarmlandInfo.js

@@ -191,11 +191,11 @@ cc.Class({
      */
     onUnlockLand() {
         //直接删除此节点
-        if(this.notLeased){
+        if (this.notLeased) {
             this.notLeased.destroy();
             this.notLeased = null;
         }
-  
+
     },
     //设置config的土地信息
     setConfigLandInfo(value) {
@@ -210,18 +210,22 @@ cc.Class({
 
     updateLandState() {
         if (!this.leaseLandInfo) return;
+        // console.log("this.leaseLandInfo.1", this.leaseLandInfo)
         if (1 === this.leaseLandInfo.isLease) {
             //已解锁
             //显示剩余天数
             this.upSliderNode.parent.active = true;
             this.multipleLabel.string = this.leaseLandInfo.leaseMultiple;
             //计算天数
-            let day1 = date.datedifference(date.formatTime(new Date()), this.leaseLandInfo.leaseTime);
             let allDay = date.datedifference(this.leaseLandInfo.createTime, this.leaseLandInfo.leaseTime);
-            this.leaseDate.string = "剩余" + day1 + "天数,共" + allDay + "天";
+            //租赁土地的剩余天数
+            let [_remainingLandDay, _remainingLandHour] = date.remainDayAndHour(this.leaseLandInfo.leaseTime, date.formatTime(new Date()));
+            //todo 处理了
+
+            this.leaseDate.string = "剩余" + _remainingLandDay + "天数,共" + allDay + "天";
             let sliderProgressScript = this.upSliderNode.getComponent("slider_progress");
-            sliderProgressScript.onSetProcgress(day1 / allDay);
-            //todo 到期处理
+            sliderProgressScript.onSetProcgress(_remainingLandDay / allDay);
+            //todo 到期处理土地回收
 
             //删除解锁图标
             this.onUnlockLand();
@@ -243,14 +247,19 @@ cc.Class({
                 leasePanelScript.setInfo(rentalExpenses, _date + "天", createTime, leaseTime, leaseMultiple + "倍", landDescribe);
             })
 
+            // console.log("this.leaseLandInfo.id", this.leaseLandInfo, " ", this.leaseLandInfo.seedInfo)
             if (this.leaseLandInfo.seedInfo) {
+
                 this.midSliderNode.active = true;
-                this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = 0.5;
                 let _currentDay = date.dateAddDate(this.leaseLandInfo.plantStart, this.leaseLandInfo.seedInfo.maturity)
-
-                // console.log(_currentDay,date.formatTime(new Date()));
-                let [_remainingDay, _remainingHour] = date.dayAndHour(_currentDay, date.formatTime(new Date()));
+                let [_remainingDay, _remainingHour] = date.remainDayAndHour(_currentDay, date.formatTime(new Date()));
+                if (_remainingHour == 24)
+                    _remainingHour = 0;
                 this.midDate.string = "剩余" + _remainingDay + "天" + _remainingHour + "小时";
+                let _maturityHour = this.leaseLandInfo.seedInfo.maturity * 24
+                //计算剩余时间显示
+                this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = _remainingHour / _maturityHour;
+
                 /**
                   * 绑定生成显示信息面板,种植信息
                   */