|
|
@@ -194,11 +194,29 @@ cc.Class({
|
|
|
onUnlockLand() {
|
|
|
//直接删除此节点
|
|
|
if (this.notLeased) {
|
|
|
- this.notLeased.destroy();
|
|
|
- this.notLeased = null;
|
|
|
+ this.notLeased.active = false;
|
|
|
+ // this.notLeased.destroy();
|
|
|
+ // this.notLeased = null;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 重新锁定
|
|
|
+ */
|
|
|
+ onLockLand() {
|
|
|
+ //显示按钮
|
|
|
+ if (this.notLeased) {
|
|
|
+ this.notLeased.active = true;
|
|
|
+ }
|
|
|
+ //去除提示框
|
|
|
+ this.upSliderNode.parent.active = false;
|
|
|
+ this.midSliderNode.active = false;
|
|
|
+ this.harvestNode.active = false;
|
|
|
+
|
|
|
+ //重置土地图片
|
|
|
+ let _workingBuilding = this.node.getComponent("WorkingBuilding");
|
|
|
+ _workingBuilding.onSetGrow(0, null);
|
|
|
+ },
|
|
|
//设置config的土地信息
|
|
|
setConfigLandInfo(value) {
|
|
|
this.configLandInfo = value;
|
|
|
@@ -214,28 +232,25 @@ cc.Class({
|
|
|
if (!this.leaseLandInfo) return;
|
|
|
// console.log("this.leaseLandInfo.1", this.leaseLandInfo)
|
|
|
if (1 === this.leaseLandInfo.isLease) {
|
|
|
+ // console.log("已租赁土地状态:", this.leaseLandInfo);
|
|
|
//已解锁
|
|
|
//显示剩余天数
|
|
|
this.upSliderNode.parent.active = true;
|
|
|
this.multipleLabel.string = this.leaseLandInfo.leaseMultiple;
|
|
|
//计算天数
|
|
|
- let allDay = date.datedifference(this.leaseLandInfo.createTime, this.leaseLandInfo.leaseTime);
|
|
|
+ // let allDay = date.datedifference(this.leaseLandInfo.createTime, this.leaseLandInfo.leaseTime);
|
|
|
//租赁土地的剩余天数
|
|
|
- let [_remainingLandDay, _remainingLandHour] = date.remainDayAndHour(this.leaseLandInfo.leaseTime, date.formatTime(new Date()));
|
|
|
+ // let [_remainingLandDay, _remainingLandHour] = date.remainDayAndHour(this.leaseLandInfo.leaseTime, date.formatTime(new Date()));
|
|
|
//todo 处理了
|
|
|
-
|
|
|
- this.leaseDate.string = "剩余" + _remainingLandDay + "天数,共" + allDay + "天";
|
|
|
+ this.leaseDate.string = "剩余" + this.leaseLandInfo.leaseDaysRemaining + "天数,共" + this.leaseLandInfo.leaseDays + "天";
|
|
|
let sliderProgressScript = this.upSliderNode.getComponent("slider_progress");
|
|
|
- sliderProgressScript.onSetProcgress(_remainingLandDay / allDay);
|
|
|
- //todo 到期处理土地回收
|
|
|
-
|
|
|
+ let _proccess = this.leaseLandInfo.leaseDays === 0 ? 0 : this.leaseLandInfo.leaseDaysRemaining / this.leaseLandInfo.leaseDays;
|
|
|
+ sliderProgressScript.onSetProcgress(_proccess);
|
|
|
//删除解锁图标
|
|
|
this.onUnlockLand();
|
|
|
-
|
|
|
/**
|
|
|
* 绑定生成显示信息面板,现在土地信息
|
|
|
*/
|
|
|
-
|
|
|
this.showLandInfo.on(cc.Node.EventType.TOUCH_START, () => {
|
|
|
let leasePanel = cc.instantiate(this.landInfoPrefabs);
|
|
|
let parent = cc.find('Canvas/UICamera/DAPPContainer');
|
|
|
@@ -248,21 +263,19 @@ cc.Class({
|
|
|
let { rentalExpenses, createTime, leaseTime, leaseMultiple, landDescribe } = this.leaseLandInfo;
|
|
|
leasePanelScript.setInfo(rentalExpenses, _date + "天", createTime, leaseTime, leaseMultiple + "倍", landDescribe);
|
|
|
})
|
|
|
-
|
|
|
- // console.log("this.leaseLandInfo.id", this.leaseLandInfo, " ", this.leaseLandInfo.seedInfo)
|
|
|
- if (this.leaseLandInfo.seedInfo) {
|
|
|
-
|
|
|
+ //如果是种植状态并且有返回种植信息
|
|
|
+ if (1 === this.leaseLandInfo.isPlant && this.leaseLandInfo.seedInfo) {
|
|
|
+ //种植信息
|
|
|
this.midSliderNode.active = true;
|
|
|
- let _currentDay = date.dateAddDate(this.leaseLandInfo.plantStart, this.leaseLandInfo.seedInfo.maturity)
|
|
|
- let [_remainingDay, _remainingHour] = date.remainDayAndHour(_currentDay, date.formatTime(new Date()));
|
|
|
-
|
|
|
- let _hour = _remainingHour - parseInt(_remainingHour / 24) * 24;
|
|
|
-
|
|
|
- this.midDate.string = "剩余" + _remainingDay + "天" + _hour + "小时";
|
|
|
- let _maturityHour = this.leaseLandInfo.seedInfo.maturity * 24
|
|
|
- //计算剩余时间显示
|
|
|
- this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = _remainingHour / _maturityHour;
|
|
|
-
|
|
|
+ // let _currentDay = date.dateAddDate(this.leaseLandInfo.plantStart, this.leaseLandInfo.seedInfo.maturity)
|
|
|
+ // let [_remainingDay, _remainingHour] = date.remainDayAndHour(_currentDay, date.formatTime(new Date()));
|
|
|
+ // let _hour = _remainingHour - parseInt(_remainingHour / 24) * 24;
|
|
|
+ this.midDate.string = "剩余" + this.leaseLandInfo.plantDaysRemaining + "天" + this.leaseLandInfo.plantHoursRemaining + "小时";
|
|
|
+ let _maturityAllHour = this.leaseLandInfo.seedInfo.maturity * 24
|
|
|
+ let _remainAllHour = this.leaseLandInfo.plantDaysRemaining * 24 + this.leaseLandInfo.plantHoursRemaining;
|
|
|
+ //计算剩余时间显示(进度条)
|
|
|
+ let _midProccess = _maturityAllHour === 0 ? 0 : _remainAllHour / _maturityAllHour;
|
|
|
+ this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = _midProccess;
|
|
|
/**
|
|
|
* 绑定生成显示信息面板,种植信息
|
|
|
*/
|
|
|
@@ -286,10 +299,6 @@ cc.Class({
|
|
|
leasePanelScript.setInfo(priceCnt, maturity + "天", this.leaseLandInfo.plantStart, _harvest, seedDescribe);
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -297,22 +306,25 @@ cc.Class({
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 场景有多个收获预制时候,用GameData限制
|
|
|
* 点击之后,重置土地信息, 并且收入进仓库果实列表中去
|
|
|
+ * 需要防多次触发
|
|
|
*/
|
|
|
onShowHarvest() {
|
|
|
this.harvestNode.active = true;
|
|
|
|
|
|
this.harvestNode.on(cc.Node.EventType.TOUCH_START, () => {
|
|
|
- console.log("点击收获");
|
|
|
//限制点击多次
|
|
|
- if (this.isHarvest) return;
|
|
|
- this.isHarvest = true;
|
|
|
-
|
|
|
+ // if (this.isHarvest) return;
|
|
|
+ // this.isHarvest = true;
|
|
|
+ if (GlobalD.GameData.isOnAddFruit) return;
|
|
|
+ console.log("点击收获");
|
|
|
+ GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获中..", 5);
|
|
|
let data = { landId: this.leaseLandInfo.configLandId };
|
|
|
//果实收入仓库,重置土地种植信息
|
|
|
GlobalD.GameData.onAddFruit(data, (res, value) => {
|
|
|
// console.log(value);
|
|
|
- if (value.code === 0) {
|
|
|
+ if (0 === value.code) {
|
|
|
//收成后处理相关状态
|
|
|
this.harvestNode.active = false;
|
|
|
this.midSliderNode.active = false
|
|
|
@@ -322,16 +334,17 @@ cc.Class({
|
|
|
let BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
|
|
|
BuildingView.onUpdateList();
|
|
|
// "收获成功!"
|
|
|
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获成功!", 2, () => {
|
|
|
- console.log("finish toast!");
|
|
|
- });
|
|
|
+ GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获成功!", 1);
|
|
|
+ } else if (706 === value.code) {
|
|
|
+ //土地到期,没有更新刷新的处理刷新
|
|
|
+ GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
|
|
|
+ //重置锁定状态显示
|
|
|
+ this.onLockLand();
|
|
|
} else {
|
|
|
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 2, () => {
|
|
|
- console.log("finish toast!");
|
|
|
- });
|
|
|
+ GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
|
|
|
}
|
|
|
//处理信息后开放
|
|
|
- this.isHarvest = false;
|
|
|
+ // this.isHarvest = false;
|
|
|
});
|
|
|
})
|
|
|
|