LeaseFarmlandInfo.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. import date from "../Unit/date.js"
  2. import gameToast from "../Network/gameToast"
  3. /**
  4. * 操作租赁土地的相关业务
  5. */
  6. cc.Class({
  7. extends: cc.Component,
  8. properties: {
  9. leasePanelPrefabs: {
  10. default: null,
  11. type: cc.Prefab,
  12. serializable: true,
  13. },
  14. //主信息面板
  15. infoBox: cc.Node,
  16. //时间计算对象
  17. showTimeOut: null,
  18. /**
  19. * 显示天数部分
  20. */
  21. upSliderNode: {
  22. default: null,
  23. type: cc.Node,
  24. serializable: true,
  25. },
  26. multipleLabel: {
  27. default: null,
  28. type: cc.Label,
  29. serializable: true,
  30. toolTip: "显示的倍数"
  31. },
  32. leaseDate: {
  33. default: null,
  34. type: cc.Label,
  35. serializable: true,
  36. toolTip: "剩余天数/总天数"
  37. },
  38. /**
  39. * 成熟期部分
  40. */
  41. midSliderNode: {
  42. default: null,
  43. type: cc.Node,
  44. serializable: true,
  45. },
  46. midDate: {
  47. default: null,
  48. type: cc.Label,
  49. serializable: true,
  50. toolTip: "剩余天数/总天数"
  51. },
  52. midSliderProgressNode: {
  53. default: null,
  54. type: cc.Node,
  55. serializable: true,
  56. toolTip: "进度条"
  57. },
  58. notLeased: {
  59. default: null,
  60. type: cc.Node,
  61. serializable: true,
  62. },
  63. //初始化时候对应的土地的id
  64. initConfigLandId: -1,
  65. // configLandId: 1
  66. // createTime: "2022-01-10 21:25:30"
  67. // id: 1
  68. // isLease: 1
  69. // isPlant: 0
  70. // landDescribe: "土地1xxx"
  71. // leaseMultiple: 1
  72. // leaseTime: "2022-01-10 21:25:17"
  73. // name: "土地1"
  74. // plantMature: 0
  75. // plantStart: "2022-01-10 21:25:22"
  76. // updateTime: "2022-01-10 21:25:33"
  77. // userId: "4"
  78. // 已经租赁的土地信息
  79. leaseLandInfo: {
  80. default: null,
  81. visible: false
  82. },
  83. // createTime: "2022-01-10 21:25:30"
  84. // id: 4
  85. // initMultiple: 1
  86. // isInit: 1
  87. // isLease: 0
  88. // isPlant: 0
  89. // landDescribe: "一倍土地"
  90. // leaseMultiple: 1
  91. // leaseTime: "2022-01-10 21:25:17"
  92. // name: "土地4"
  93. // plantMature: 0
  94. // plantStart: "2022-01-10 21:25:22"
  95. // posX: 19
  96. // posY: 10
  97. // sizeX: 2
  98. // sizeY: 2
  99. // updateTime: "2022-01-10 21:25:33"
  100. // 未初始化时候的土地信息
  101. configLandInfo: {
  102. default: null,
  103. visible: false
  104. },
  105. showLandInfo: {
  106. default: null,
  107. type: cc.Node,
  108. serializable: true,
  109. toolTip: "显示土地信息"
  110. },
  111. landInfoPrefabs: {
  112. default: null,
  113. type: cc.Prefab,
  114. serializable: true,
  115. },
  116. // 已经种植的作物信息
  117. plantInfo: {
  118. default: null,
  119. visible: false
  120. },
  121. showPlantInfo: {
  122. default: null,
  123. type: cc.Node,
  124. serializable: true,
  125. toolTip: "显示种植信息"
  126. },
  127. plantInfoPrefabs: {
  128. default: null,
  129. type: cc.Prefab,
  130. serializable: true,
  131. },
  132. //收获阶段
  133. harvestNode: {
  134. default: null,
  135. type: cc.Node,
  136. serializable: true,
  137. },
  138. stealHarvestNode: {
  139. default: null,
  140. type: cc.Node,
  141. serializable: true,
  142. },
  143. isHarvest: false,
  144. /**
  145. * 成熟时候显示的图片
  146. */
  147. harvestSprite: {
  148. default: null,
  149. type: cc.SpriteFrame,
  150. },
  151. _workingBuilding: null,
  152. //时间计算对象
  153. timeInterval: null,
  154. //是否显示showHarvest
  155. isShowHarvest: false,
  156. isShowIndex: 0,
  157. //检查土地是否到期
  158. isCheckLandState: false,
  159. _buildingView: null,
  160. //是否是自己的土地,记录一下
  161. bSelfLand:true,
  162. },
  163. // LIFE-CYCLE CALLBACKS:
  164. onLoad() {
  165. this._workingBuilding = this.node.getComponent("WorkingBuilding");
  166. this._buildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
  167. },
  168. start() {
  169. this.harvestNode.on(cc.Node.EventType.TOUCH_START, () => {
  170. if (GlobalD.GameData.isOnAddFruit) return;
  171. console.log("点击收获");
  172. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获中..", 5);
  173. let data = { landId: this.leaseLandInfo.configLandId };
  174. //果实收入仓库,重置土地种植信息
  175. GlobalD.GameData.onAddFruit(data, (value) => {
  176. // console.log(value);
  177. if (0 === value.code) {
  178. //收成后处理相关状态
  179. this.harvestNode.active = false;
  180. this.midSliderNode.active = false
  181. this._workingBuilding.onSetGrow(0, null);
  182. //更新仓库列表
  183. this._buildingView.onUpdateList();
  184. // "收获成功!"
  185. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获成功!", 1);
  186. this.isShowHarvest = false;
  187. this.isShowIndex = 0;
  188. if (this.timeInterval) {
  189. clearInterval(this.timeInterval);
  190. this.timeInterval = null;
  191. }
  192. } else if (706 === value.code) {
  193. //土地到期,没有更新刷新的处理刷新
  194. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
  195. //重置锁定状态显示
  196. this.onLockLand();
  197. } else {
  198. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
  199. }
  200. });
  201. })
  202. this.stealHarvestNode.on(cc.Node.EventType.TOUCH_START, () => {
  203. if (!this.bSelfLand){
  204. console.log("点击偷菜按钮收取");
  205. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "请点击偷菜按钮收取!", 1);
  206. return;
  207. }
  208. if (GlobalD.GameData.isOnAddFruit) return;
  209. console.log("点击收获");
  210. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获中..", 5);
  211. let data = { otherLandId: this.leaseLandInfo.configLandId, otherUserId: GlobalD.GameData.OtherUserInfo.userId };
  212. //果实收入仓库,重置土地种植信息
  213. GlobalD.GameData.onStealFruit(data, (value) => {
  214. console.log(value);
  215. if (0 === value.code) {
  216. //收成后处理相关状态
  217. this.stealHarvestNode.active = false;
  218. //更新仓库列表
  219. this._buildingView.onUpdateList();
  220. // "收获成功!"
  221. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "收获成功!", 1);
  222. this.isShowHarvest = false;
  223. this.isShowIndex = 0;
  224. if (this.timeInterval) {
  225. clearInterval(this.timeInterval);
  226. this.timeInterval = null;
  227. }
  228. } else if (706 === value.code) {
  229. //土地到期,没有更新刷新的处理刷新
  230. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
  231. //重置锁定状态显示
  232. this.onLockLand();
  233. } else {
  234. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
  235. }
  236. });
  237. })
  238. },
  239. onSpawnLeasePanel() {
  240. let leasePanel = cc.instantiate(this.leasePanelPrefabs);
  241. let parent = cc.find('Canvas/UICamera/DAPPContainer');
  242. leasePanel.parent = parent;
  243. leasePanel.setPosition(0, 0);
  244. // leasePanel.zIndex = 999;
  245. //把操作对象传入
  246. let leasePanelScript = leasePanel.getComponent("LeaseInfo");
  247. leasePanelScript.leaseFarmlandInfoNode = this;
  248. /**
  249. * 初始化两个操作。一个是续约,续约的话,不给操作,只有续约按钮可点,相当于原来配置再购买一次
  250. *
  251. * this.leaseLandInfo 如果购买了土地,这个参数不为空
  252. */
  253. if (this.leaseLandInfo) {
  254. //续约时候拦截输入,固定倍数
  255. leasePanelScript.blockInput.active = true;
  256. //传入当前计算倍数
  257. leasePanelScript.onInitLeaseInfo(this.leaseLandInfo.leaseMultiple);
  258. } else if (0 === this.configLandInfo.initMultiple) {
  259. // 固定土地开启,限制输入,设置默认值是1
  260. leasePanelScript.blockInput.active = true;
  261. leasePanelScript.onInitLeaseInfo(1);
  262. } else {
  263. //多倍土地,可以自己输入
  264. leasePanelScript.onInitLeaseInfo(this.configLandInfo.initMultiple);
  265. }
  266. },
  267. /**
  268. * 解锁土地操作
  269. */
  270. onUnlockLand() {
  271. //直接删除此节点
  272. if (this.notLeased) {
  273. this.notLeased.active = false;
  274. // this.notLeased.destroy();
  275. // this.notLeased = null;
  276. }
  277. },
  278. /**
  279. * 获取锁定状态
  280. */
  281. onGetUnlockLandState() {
  282. return this.notLeased.active;
  283. },
  284. /**
  285. * 重新锁定
  286. */
  287. onLockLand() {
  288. //显示按钮
  289. if (this.notLeased) {
  290. this.notLeased.active = true;
  291. }
  292. //清除当前租赁数据
  293. this.leaseLandInfo = null;
  294. this.isShowHarvest = false;
  295. this.isShowIndex = 0;
  296. if (this.timeInterval) {
  297. clearInterval(this.timeInterval);
  298. this.timeInterval = null;
  299. }
  300. //去除提示框
  301. this.upSliderNode.parent.active = false;
  302. this.midSliderNode.active = false;
  303. this.harvestNode.active = false;
  304. this.stealHarvestNode.active = false;
  305. //重置土地图片
  306. this._workingBuilding.onSetGrow(0, null);
  307. this.onSetInfoBoxActive(false);
  308. },
  309. //设置config的土地信息
  310. setConfigLandInfo(value) {
  311. this.configLandInfo = value;
  312. },
  313. /**
  314. * 设置其他用户租赁的土地信息
  315. * 比如去其他用户家里偷取物品,目前统一在这处理
  316. */
  317. setLeaseLandInfo(value, bSelf) {
  318. console.log("土地信息是,bSelf:", bSelf);
  319. if (!value) {
  320. console.log("已租赁土地状态为空:", value);
  321. return;
  322. }
  323. this.onSetInfoBoxActive(false);
  324. //设置意思显示相关
  325. this.isShowHarvest = false;
  326. this.isShowIndex = 0;
  327. //重新设置租赁检测状态
  328. this.isCheckLandState = false;
  329. this.leaseLandInfo = value;
  330. //先解绑一下信息
  331. this.showLandInfo.off(cc.Node.EventType.TOUCH_START, this._showLandInfo, this);
  332. this.showPlantInfo.off(cc.Node.EventType.TOUCH_START, this._showPlantInfo, this);
  333. //每个作物直接实时计算时间
  334. if (this.timeInterval) {
  335. clearInterval(this.timeInterval);
  336. this.timeInterval = null;
  337. }
  338. //删除解锁图标
  339. this.onUnlockLand();
  340. this.bSelfLand = bSelf;
  341. //更新一下土地信息
  342. this.updateLandState(bSelf);
  343. },
  344. updateLandState(bSelf) {
  345. //显示剩余天数
  346. this.upSliderNode.parent.active = bSelf;
  347. this.multipleLabel.string = this.leaseLandInfo.leaseMultiple;
  348. // 进去条按天算
  349. let sliderProgressScript = this.upSliderNode.getComponent("slider_progress");
  350. let _proccess = this.leaseLandInfo.leaseDays === 0 ? 0 : this.leaseLandInfo.leaseDaysRemaining / this.leaseLandInfo.leaseDays;
  351. sliderProgressScript.onSetProcgress(_proccess);
  352. /**
  353. * 绑定生成显示信息面板,现在土地信息
  354. */
  355. this.showLandInfo.on(cc.Node.EventType.TOUCH_START, this._showLandInfo, this);
  356. //如果是种植状态并且有返回种植信息
  357. if (1 === this.leaseLandInfo.isPlant && this.leaseLandInfo.seedInfo) {
  358. //种植信息
  359. //如果土地是租赁转态并且同时种植了 ,这里处理土地状态,显示种植信息
  360. let _spriteFrame;
  361. switch (this.leaseLandInfo.seedInfo.picture) {
  362. case "Cabbage":
  363. _spriteFrame = this._buildingView.fruitSpriteFrame[0];
  364. break;
  365. case "Potato":
  366. _spriteFrame = this._buildingView.fruitSpriteFrame[1];
  367. break;
  368. case "Carrot":
  369. _spriteFrame = this._buildingView.fruitSpriteFrame[2];
  370. break;
  371. case "Broccoli":
  372. _spriteFrame = this._buildingView.fruitSpriteFrame[3];
  373. break;
  374. case "Tomato":
  375. _spriteFrame = this._buildingView.fruitSpriteFrame[4];
  376. break;
  377. case "Squash":
  378. _spriteFrame = this._buildingView.fruitSpriteFrame[5];
  379. break;
  380. case "Eggplant":
  381. _spriteFrame = this._buildingView.fruitSpriteFrame[6];
  382. break;
  383. case "Pepper":
  384. _spriteFrame = this._buildingView.fruitSpriteFrame[7];
  385. break;
  386. case "Lentil":
  387. _spriteFrame = this._buildingView.fruitSpriteFrame[8];
  388. break;
  389. default:
  390. break;
  391. }
  392. //设置一个收获时候的图片
  393. this.harvestSprite = _spriteFrame;
  394. this.midSliderNode.active = bSelf;
  395. // 进度条按小时计算
  396. let _maturityAllHour = this.leaseLandInfo.seedInfo.maturity * 24
  397. let _remainAllHour = this.leaseLandInfo.plantDaysRemaining * 24 + this.leaseLandInfo.plantHoursRemaining;
  398. //计算剩余时间显示(进度条)
  399. let _midProccess = _maturityAllHour === 0 ? 0 : _remainAllHour / _maturityAllHour;
  400. this.midSliderProgressNode.getComponent(cc.ProgressBar).progress = _midProccess;
  401. /**
  402. * 绑定生成显示信息面板,种植信息
  403. */
  404. this.showPlantInfo.on(cc.Node.EventType.TOUCH_START, this._showPlantInfo, this);
  405. }
  406. let lastUpdateTime = Date.now();
  407. let elapsedTime = 0;
  408. let updateFrequency = 1; //ms
  409. this.timeInterval = setInterval(() => {
  410. let currentTime = Date.now();
  411. let deltaTime = currentTime - lastUpdateTime;
  412. elapsedTime += deltaTime;
  413. if (elapsedTime >= updateFrequency) {
  414. elapsedTime -= updateFrequency;
  415. let _leaseDaysMill = this.leaseLandInfo.leaseDaysMill - elapsedTime;
  416. let _plantDaysMill = this.leaseLandInfo.plantDaysMill - elapsedTime;
  417. lastUpdateTime = currentTime;
  418. // 更新计时显示
  419. let [_lDay, _lHour, _lMinutes, _lSeconds] = date.remainFromMillisecond(_leaseDaysMill);
  420. //todo 处理了 this.leaseLandInfo.leaseDaysRemaining
  421. if (0 !== _lDay) {
  422. this.leaseDate.string = "剩" + _lDay + "天/" + this.leaseLandInfo.leaseDays + "天";
  423. } else if (0 !== _lHour) {
  424. this.leaseDate.string = "剩" + _lHour + "时/" + this.leaseLandInfo.leaseDays + "天";
  425. } else if (0 !== _lMinutes) {
  426. this.leaseDate.string = "剩" + _lMinutes + "分/" + this.leaseLandInfo.leaseDays + "天";
  427. } else {
  428. this.leaseDate.string = "剩" + _lSeconds + "秒/" + this.leaseLandInfo.leaseDays + "天";
  429. }
  430. //todo 如果租赁时间到了,重新锁定
  431. //重置锁定状态显示
  432. if (!this.isCheckLandState) {
  433. if (_leaseDaysMill <= 0) {
  434. this.isCheckLandState = true;
  435. //检查一次土地
  436. this.onCheckLand(this.leaseLandInfo.configLandId);
  437. }
  438. }
  439. if (1 === this.leaseLandInfo.isPlant && this.leaseLandInfo.seedInfo) {
  440. //获得服务器种植日期毫秒
  441. let [_pDay, _pHour, _pMinutes, _pSeconds] = date.remainFromMillisecond(_plantDaysMill);
  442. //todo 处理了 this.leaseLandInfo.plantDaysRemaining
  443. if (0 !== _pDay) {
  444. //否则显示天和小时
  445. this.midDate.string = "剩" + _pDay + "天" + _pHour + "时";
  446. } else if (0 !== _pHour) {
  447. this.midDate.string = "剩" + _pHour + "时" + _pMinutes + "分";
  448. } else {
  449. this.midDate.string = "剩" + _pMinutes + "分" + _pSeconds + "秒";
  450. }
  451. if (!this.isShowHarvest) {
  452. if (_plantDaysMill <= 0) {
  453. this.isShowHarvest = true;
  454. this.isShowIndex = 3;
  455. //如果传回的毫秒是小于零,说明成熟了
  456. //成熟阶段
  457. this._workingBuilding.onSetGrow(3, this.harvestSprite);
  458. // console.log("土地:", _userLeaseLand[j].configLandId, "已经成熟,可以操作收取果实了!!");
  459. //如果是自己的,显示收成
  460. if (bSelf) {
  461. this.onShowHarvest();
  462. } else {
  463. this.onShowStealHarvest();
  464. }
  465. } else {
  466. let _maturityHour = this.leaseLandInfo.seedInfo.maturity * 24
  467. let _ratio = (_pDay * 24 + _pHour) / _maturityHour;
  468. if (_ratio > 0.5 && 1 !== this.isShowIndex) {
  469. this.isShowIndex = 1;
  470. this._workingBuilding.onSetGrow(1, this.harvestSprite);
  471. console.log("_ratio:" + _ratio + "=" + this.leaseLandInfo.configLandId + ",状态:" + this.isShowIndex);
  472. } else if (_ratio <= 0.5 && _ratio >= 0 && 2 !== this.isShowIndex) {
  473. this.isShowIndex = 2;
  474. this._workingBuilding.onSetGrow(2, this.harvestSprite);
  475. console.log("_ratio:" + _ratio + "=" + this.leaseLandInfo.configLandId + ",状态:" + this.isShowIndex);
  476. }
  477. }
  478. }
  479. }
  480. }
  481. });
  482. },
  483. _showLandInfo() {
  484. let leasePanel = cc.instantiate(this.landInfoPrefabs);
  485. let parent = cc.find('Canvas/UICamera/DAPPContainer');
  486. leasePanel.parent = parent;
  487. leasePanel.setPosition(0, 0);
  488. let leasePanelScript = leasePanel.getComponent("LandInfo");
  489. let _date = date.datedifference(this.leaseLandInfo.createTime, this.leaseLandInfo.leaseTime);
  490. let { configLandId, rentalExpenses, createTime, leaseTime, leaseMultiple, landDescribe } = this.leaseLandInfo;
  491. leasePanelScript.setInfo(configLandId, rentalExpenses, _date + "天", createTime, leaseTime, leaseMultiple + "倍", landDescribe);
  492. },
  493. _showPlantInfo() {
  494. let leasePanel = cc.instantiate(this.plantInfoPrefabs);
  495. let parent = cc.find('Canvas/UICamera/DAPPContainer');
  496. leasePanel.parent = parent;
  497. leasePanel.setPosition(0, 0);
  498. // leasePanel.zIndex = 999;
  499. let leasePanelScript = leasePanel.getComponent("PlantInfo");
  500. let _harvest = 0;
  501. if (this.leaseLandInfo.leaseDate === 1) {
  502. _harvest = this.leaseLandInfo.seedInfo.harvest1;
  503. } else if (this.leaseLandInfo.leaseDate === 2) {
  504. _harvest = this.leaseLandInfo.seedInfo.harvest2;
  505. } else if (this.leaseLandInfo.leaseDate === 3) {
  506. _harvest = this.leaseLandInfo.seedInfo.harvest3;
  507. }
  508. //price,maturity,plantStart,harvestQuantity,describe
  509. let { name, priceCnt, maturity, seedDescribe } = this.leaseLandInfo.seedInfo;
  510. leasePanelScript.setInfo(name, priceCnt, maturity + "天", this.leaseLandInfo.plantStart, _harvest, seedDescribe);
  511. },
  512. //更新收获的状态
  513. updateHarvest() {
  514. //todo 后续看看如何刷新,现在走的是开始刷新一次
  515. // let _workingBuilding = housingTemp_farmland.getComponent("WorkingBuilding");
  516. // //获得服务器种植日期毫秒
  517. // let [_day, _hour, _minutes, _seconds] = date.remainFromMillisecond(_leaseLandInfo.plantDaysMill);
  518. // let _maturityHour = _leaseLandInfo.seedInfo.maturity * 24
  519. // let _ratio = _hour / _maturityHour;
  520. // // console.log("生成的:" + _ratio);
  521. // if (_ratio > 0.5) {
  522. // _workingBuilding.onSetGrow(1, _spriteFrame);
  523. // } else if (_ratio >= 0) {
  524. // _workingBuilding.onSetGrow(2, _spriteFrame);
  525. // }else if (_leaseLandInfo.plantDaysMill <= 0) {
  526. // //如果传回的毫秒是小于零,说明成熟了
  527. // //成熟阶段
  528. // _workingBuilding.onSetGrow(3, _spriteFrame);
  529. // //todo,如果时间小的,走收获,收获成果实
  530. // // console.log("土地:", _userLeaseLand[j].configLandId, "已经成熟,可以操作收取果实了!!");
  531. // //todo 土地可收获状态
  532. // leaseFarmlandInfoScript.onShowHarvest();
  533. // }
  534. },
  535. //检查土地状态
  536. onCheckLand(configLandId) {
  537. GlobalD.GameData.getLandState({
  538. landId: configLandId,
  539. callback: (value) => {
  540. console.log("检查土地数据:" + JSON.stringify(value.msg));
  541. //这里只判断土地是否过期
  542. if (706 === value.code) {
  543. //土地到期,没有更新刷新的处理刷新
  544. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), configLandId + "号," + value.msg, 2);
  545. //重置锁定状态显示
  546. this.onLockLand();
  547. }
  548. }
  549. });
  550. },
  551. /**
  552. * 场景有多个收获预制时候,用GameData限制
  553. * 点击之后,重置土地信息, 并且收入进仓库果实列表中去
  554. * 需要防多次触发
  555. */
  556. onShowHarvest() {
  557. this.harvestNode.active = true;
  558. },
  559. /**
  560. * 场景有多个收获预制时候,用GameData限制
  561. * 点击之后,偷取果实
  562. * 需要防多次触发
  563. */
  564. onShowStealHarvest() {
  565. this.stealHarvestNode.active = true;
  566. },
  567. /**
  568. * 设置总体信息面板显示
  569. * @param {boolean} bActive
  570. */
  571. onSetInfoBoxActive(bActive) {
  572. if(!this.bSelfLand){
  573. // console.log("其他用户的不用显示面板");
  574. return;
  575. }
  576. if (this.leaseLandInfo){
  577. this.infoBox.active = bActive;
  578. if(bActive)
  579. {
  580. if(this.showTimeOut){
  581. clearTimeout(this.showTimeOut);
  582. this.showTimeOut = null;
  583. }
  584. //自动隐藏面板
  585. this.showTimeOut = setTimeout(()=>{
  586. this.infoBox.active = false;
  587. },5000)
  588. }
  589. }
  590. },
  591. onDestroy() {
  592. if (this.timeInterval) {
  593. clearInterval(this.timeInterval);
  594. this.timeInterval = null;
  595. }
  596. if(this.showTimeOut){
  597. clearTimeout(this.showTimeOut);
  598. this.showTimeOut = null;
  599. }
  600. }
  601. });