ManageUI.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. // const constants = require('Constants');
  2. // var reGameStates = require('GameStates');
  3. var AConfig = require('../Config')
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. //左上角按钮列表
  8. LeftMenu: cc.Node,
  9. //编辑建筑物时候的ui显示
  10. EditorialBuildings: cc.Node,
  11. //记录编辑按钮的父对象
  12. _thisEditBuildingsParent: cc.Node,
  13. _Cancellation: cc.Button,
  14. _Comfirmation: cc.Button,
  15. _buildTarget: cc.Node,
  16. //显示建筑的详细信息
  17. //建筑面板
  18. BuildingInfoView: cc.Node,
  19. //ui Mask 对应的touch
  20. UITouch: {
  21. default: null,
  22. type: cc.Node,
  23. },
  24. //设置面板
  25. SettingInfoView: cc.Node,
  26. //建筑面板
  27. //建筑物列表.后面根据数据动态添加content的内容。
  28. //todo..
  29. BuildView: cc.Node,
  30. StoreView: cc.Node,
  31. BuildContent_Button: { default: null, type: cc.Button, visible: false },
  32. BuildContent_OldButton: { default: null, type: cc.Button, visible: false },
  33. BuildContent_Normal_Sprite: cc.SpriteFrame,
  34. BuildContent_Pressed_Sprite: cc.SpriteFrame,
  35. ButtonSelectedFrame: cc.Node,
  36. //建筑版面的介绍模板
  37. BuildContent_Name: cc.Label,
  38. BuildContent_Price: cc.Label,
  39. BuildContent_Synopsis: cc.Label,
  40. //人才面板
  41. PersonnelView: cc.Node,
  42. //股票面板
  43. StockView: cc.Node,
  44. //幸运转盘
  45. LuckView: cc.Node,
  46. // 底部的菜单栏
  47. BottomView: cc.Node,
  48. // 其他农场用户的界面节点
  49. OtherFarmerMask: cc.Node,
  50. Evn: cc.Node,
  51. Seed: cc.Node,
  52. EveryDaySignView: cc.Node,
  53. //提示面板
  54. TipView: cc.Node,
  55. //提示面板预制
  56. TipViewPrefab: cc.Prefab,
  57. ShowRewards: cc.Node,
  58. BuildingFrameArray: {
  59. default: [],
  60. type: [cc.Node],
  61. serializable: true,
  62. },
  63. Goldenlabel: cc.Node,
  64. Diamondlabel: cc.Node,
  65. CNTlabel: cc.Node,
  66. SNBlabel: cc.Node,
  67. Strengthlabel: cc.Node,
  68. Luckylabel: cc.Node,
  69. //显示的库存总量,人才界面
  70. cropContent: cc.Label,
  71. woodContent: cc.Label,
  72. mineContent: cc.Label,
  73. //钻石兑换金币
  74. DiamondGapView: cc.Node,
  75. DiamondNowlabel: cc.Label,
  76. ExchangeBtn: cc.Button,
  77. //钻石足够获得种子
  78. DiamondSeedsView: cc.Node,
  79. LightRotate: cc.Node,
  80. DiamondSeeds_SureBtn: cc.Button,
  81. inviteNode: cc.Node,
  82. listUserInfoNode: cc.Node,
  83. //商店面的介绍模板
  84. mallContent_Name: cc.Label,
  85. mallContent_Price: cc.Label,
  86. mallContent_Mature: cc.Label,
  87. mallContent_Synopsis: cc.Label,
  88. //偷取成功生成一个提示
  89. StealViewSuccessPrefab: cc.Prefab,
  90. },
  91. onLoad() {
  92. cc.game.setFrameRate(30)
  93. cc.director.preloadScene('Login', function () { }.bind(this))
  94. if (this.EditorialBuildings) {
  95. this._thisEditBuildingsParent = this.EditorialBuildings.parent
  96. this._Cancellation = this.EditorialBuildings.getChildByName(
  97. 'Cancellation'
  98. ).getComponent(cc.Button)
  99. this._Comfirmation = this.EditorialBuildings.getChildByName(
  100. 'Confirmation'
  101. ).getComponent(cc.Button)
  102. }
  103. task.managerUi = this
  104. var data1 = {
  105. name: 'Whoareyou',
  106. openId: userData.openId,
  107. }
  108. UtilsWX.postMessage(data1)
  109. UtilsWX.shareMenu()
  110. UtilsWX.initWXSubContextView(cc.find('Canvas/UICamera/wx'))
  111. UtilsWX.openWXSubContextView(false)
  112. },
  113. isGame: function () {
  114. this.times = 0
  115. cc.game.on(
  116. cc.game.EVENT_HIDE,
  117. function () {
  118. console.log('游戏进入后台', this.getTime())
  119. if (UtilsWX.shareTag == 0) {
  120. // this.onHideGame();//处理游戏切到后台时的事件
  121. this.times = this.getTime()
  122. task.onLoad()
  123. // this.onShowGame();//处理游戏切回前台时的事件
  124. cc.director.loadScene(
  125. 'Login',
  126. function () {
  127. task.showPointerNode = null
  128. }.bind(this)
  129. )
  130. }
  131. },
  132. this
  133. )
  134. cc.game.on(
  135. cc.game.EVENT_SHOW,
  136. function () {
  137. console.log('重新返回游戏', this.getTime())
  138. // if (this.getTime()-this.times>=30000) {
  139. if (UtilsWX.shareTag == 0) {
  140. }
  141. UtilsWX.setShareTag(0)
  142. // }
  143. },
  144. this
  145. )
  146. },
  147. getTime: function () {
  148. return new Date().getTime()
  149. },
  150. // InitTask(BFirstLoadGame) {
  151. // // todo 新手教学 初始化
  152. // console.log("初始化真的假的", BFirstLoadGame);
  153. // if (!BFirstLoadGame) {
  154. // //首次初始化
  155. // task.onLoad();
  156. // //创建员工
  157. // cc.find('GameNode/ManageWorker').getComponent('ManageWorker').onRecruit();
  158. // cc.find('GameNode/ManageWorker').getComponent('ManageWorker').onRecruit();
  159. // } else {
  160. // task._init();
  161. // task.addSeneceTaskIcon();
  162. // task.onLoadno();
  163. // }
  164. // this.Init();
  165. // },
  166. start() {
  167. /*
  168. 其中第一个参数为捕捉的时间名,在官方文档中给出了几个选择,我们主要列举下触碰时间
  169. cc.Node.EventType.TOUCH_START 当手按下时触发
  170. cc.Node.EventType.TOUCH_END 当手抬起时候
  171. cc.Node.EventType.TOUCH_MOVE 当手按下滑动时
  172. cc.Node.EventType.TOUCH_CANCEL 当手按下滑动后 抬起时
  173. */
  174. if (this._Cancellation)
  175. this._Cancellation.node.on(
  176. cc.Node.EventType.TOUCH_END,
  177. this.onCancellationEditor,
  178. this
  179. )
  180. if (this._Comfirmation)
  181. this._Comfirmation.node.on(
  182. cc.Node.EventType.TOUCH_END,
  183. this.onConfirmationEditor,
  184. this
  185. )
  186. },
  187. Init() {
  188. this._setLockBuildingColor()
  189. let BuildingStateArray = GlobalD.GameData.GetBuildingLockStateArray()
  190. for (let i = 0; i < BuildingStateArray.length; i++) {
  191. if (BuildingStateArray[i] == 1) {
  192. if (this.BuildingFrameArray[i]) this.OpenBuildingUILock(i, false)
  193. }
  194. if (this.BuildingFrameArray[i])
  195. this.BuildingFrameArray[i]
  196. .getChildByName('Lock')
  197. .getChildByName('PriceBG')
  198. .getChildByName('label')
  199. .getComponent(cc.Label).string = this.FormatMoney(
  200. AConfig.BuildingUnlockMoneyArray[i]
  201. )
  202. }
  203. // *********** todo *************
  204. //初始化,面板信息
  205. //运营费用数组
  206. let _runningCostArray = AConfig.RunningCostArray
  207. for (let i = 0; i < _runningCostArray.length; i++) {
  208. if (this.BuildingFrameArray[i]) {
  209. let _contentButton =
  210. this.BuildingFrameArray[i].getComponent('Content_Button')
  211. _contentButton.Price = AConfig.RunningCostArray[i] //运营费用
  212. //设置新的钻石价格
  213. let _DiamondNumArray = GlobalD.GameData.GetDiamondNumArray()
  214. _contentButton.DiamondPrice = _DiamondNumArray[i] //钻石费用
  215. }
  216. }
  217. //如果用户未租赁过土地且未用钻石兑换过种子,则显示
  218. GlobalD.GameData.getPlayerExchangeState((res, value) => {
  219. //warn 这里需要增加对结果的判断
  220. if (0 === value.code) {
  221. //没有兑换过和没有租赁过
  222. if (!value.data.isExchange && !value.data.isLeased) {
  223. this.DiamondGapViewShow()
  224. }
  225. }
  226. })
  227. },
  228. _setLockBuildingColor() {
  229. let BuildingStateArray = GlobalD.GameData.GetBuildingLockStateArray()
  230. for (let index = 0; index < BuildingStateArray.length; index++) {
  231. if (this.BuildingFrameArray[index] && BuildingStateArray[index] == 0) {
  232. this.BuildingFrameArray[index].color = new cc.Color(150, 150, 150, 150)
  233. this.BuildingFrameArray[index].getChildByName(
  234. 'New Sprite(Splash)'
  235. ).color = new cc.Color(0, 0, 0, 255)
  236. this.BuildingFrameArray[index].getChildByName('Name').active = false
  237. }
  238. }
  239. },
  240. OpenBuildingUILock(Index, BLock) {
  241. let Lock = (this.BuildingFrameArray[Index].getChildByName('Lock').active =
  242. BLock)
  243. let BuildingStateArray = GlobalD.GameData.GetBuildingLockStateArray()
  244. if (!BLock && BuildingStateArray[Index] == 0) {
  245. BuildingStateArray[Index] = 1
  246. this.BuildingFrameArray[Index].color = new cc.Color(255, 255, 255, 255)
  247. this.BuildingFrameArray[Index].getChildByName(
  248. 'New Sprite(Splash)'
  249. ).color = new cc.Color(255, 255, 255, 255)
  250. this.BuildingFrameArray[Index].getChildByName('Name').active = true
  251. GlobalD.GameData.SetBuildingLockStateArray(BuildingStateArray)
  252. }
  253. },
  254. OnUnLockBuilding(event, CustomEventData, callback) {
  255. cc.loader.loadRes(
  256. 'prefab/UnlockBuiding',
  257. function (err, texture) {
  258. this.UnlockBuildingDialogView = cc.instantiate(texture)
  259. this.BuildView.addChild(this.UnlockBuildingDialogView)
  260. {
  261. //CloseBtn
  262. let close = this.UnlockBuildingDialogView.getChildByName('close')
  263. let clickEventHandler = new cc.Component.EventHandler()
  264. clickEventHandler.target = this.node
  265. clickEventHandler.component = 'ManageUI'
  266. clickEventHandler.handler = 'onClickCloseInUnlockBuilding'
  267. let button = close.getComponent(cc.Button)
  268. button.clickEvents.push(clickEventHandler)
  269. }
  270. {
  271. //NoBtn
  272. let NoBTN = this.UnlockBuildingDialogView.getChildByName('NoBTN')
  273. let clickEventHandler = new cc.Component.EventHandler()
  274. clickEventHandler.target = this.node
  275. clickEventHandler.component = 'ManageUI'
  276. clickEventHandler.handler = 'onClickNoBTNInUnlockBuilding'
  277. let button = NoBTN.getComponent(cc.Button)
  278. button.clickEvents.push(clickEventHandler)
  279. }
  280. {
  281. //YesBtn
  282. let YesBTN = this.UnlockBuildingDialogView.getChildByName('YesBTN')
  283. let clickEventHandler = new cc.Component.EventHandler()
  284. clickEventHandler.target = this.node
  285. clickEventHandler.component = 'ManageUI'
  286. clickEventHandler.handler = 'onClickYesBTNInUnlockBuilding'
  287. clickEventHandler.customEventData = CustomEventData
  288. let button = YesBTN.getComponent(cc.Button)
  289. button.clickEvents.push(clickEventHandler)
  290. }
  291. //Close
  292. if (callback != null) {
  293. callback(this.UnlockBuildingDialogView)
  294. }
  295. }.bind(this)
  296. )
  297. },
  298. onClickCloseInUnlockBuilding(event) {
  299. this.UnlockBuildingDialogView.destroy()
  300. },
  301. onClickNoBTNInUnlockBuilding(event) {
  302. this.UnlockBuildingDialogView.destroy()
  303. },
  304. onClickYesBTNInUnlockBuilding(event, CustomEventData) {
  305. this.UnlockBuildingDialogView.destroy()
  306. let Index = parseInt(CustomEventData)
  307. let CostCoin = AConfig.BuildingUnlockMoneyArray[Index]
  308. if (
  309. GlobalD.GameData.GetDiamond() > CostCoin ||
  310. GlobalD.GameData.GetDiamond() == CostCoin
  311. ) {
  312. GlobalD.GameData.PlusDiamond(-CostCoin)
  313. this.OpenBuildingUILock(Index, false)
  314. cc.loader.loadRes(
  315. 'prefab/show',
  316. function (err, texture) {
  317. this.ShowRewardsView = cc.instantiate(texture)
  318. this.BuildView.addChild(this.ShowRewardsView)
  319. let Rewards =
  320. this.ShowRewardsView.getChildByName('GivePrize').getChildByName(
  321. 'Rewards'
  322. )
  323. Rewards.getComponent(cc.Sprite).spriteFrame = this.BuildingFrameArray[
  324. Index
  325. ].getChildByName('New Sprite(Splash)').getComponent(
  326. cc.Sprite
  327. ).spriteFrame
  328. var Sunshine =
  329. this.ShowRewardsView.getChildByName('GivePrize').getChildByName(
  330. 'Sunshine'
  331. )
  332. var GivePrize = this.ShowRewardsView.getChildByName('GivePrize')
  333. Sunshine.scaleX = 0
  334. Sunshine.scaleY = 0
  335. GivePrize.scaleX = 0
  336. GivePrize.scaleY = 0
  337. Sunshine.stopAllActions()
  338. GivePrize.stopAllActions()
  339. this.scheduleOnce(function () {
  340. var sc2 = cc.scaleTo(0.5, 0.8, 0.8)
  341. Sunshine.runAction(sc2)
  342. var sc3 = cc.scaleTo(0.5, 1.3, 1.3)
  343. GivePrize.runAction(sc3)
  344. var repeat = cc.repeatForever(cc.rotateBy(5.0, 360))
  345. Sunshine.runAction(repeat)
  346. }, 0.1)
  347. //CloseBtn
  348. let close = this.ShowRewardsView.getChildByName('close')
  349. let clickEventHandler = new cc.Component.EventHandler()
  350. clickEventHandler.target = this.node
  351. clickEventHandler.component = 'ManageUI'
  352. clickEventHandler.handler = 'OnShowRewardsViewClose'
  353. let button = close.getComponent(cc.Button)
  354. button.clickEvents.push(clickEventHandler)
  355. }.bind(this)
  356. )
  357. return
  358. }
  359. //No Enough Diamond
  360. cc.loader.loadRes(
  361. 'prefab/ShowNoMoney',
  362. function (err, texture) {
  363. this.ShowNoMoneyView = cc.instantiate(texture)
  364. this.BuildView.addChild(this.ShowNoMoneyView)
  365. let DetailLabel = this.ShowNoMoneyView.getChildByName('DetailLabel')
  366. DetailLabel.getComponent(cc.Label).string = '钻石不够!'
  367. this.scheduleOnce(
  368. function () {
  369. this.ShowNoMoneyView.destroy()
  370. }.bind(this),
  371. 1
  372. )
  373. }.bind(this)
  374. )
  375. },
  376. OnShowRewardsViewClose(event, CustomEventData) {
  377. this.ShowRewardsView.destroy()
  378. },
  379. //弹出购买提示
  380. onPurchaseTips(_contentButton) {
  381. // cc.log('是否用钻石购买建筑', _contentButton.node.name);
  382. if (this.TipViewPrefab) {
  383. let _TipView
  384. _TipView = cc.instantiate(this.TipViewPrefab)
  385. _TipView.parent = this.TipView
  386. _TipView.setPosition(cc.v2(0, 0))
  387. _TipView
  388. .getComponent('TipView')
  389. .onShowTip({ ContentButton: _contentButton, TipViewNode: this.TipView })
  390. // cc.log(_TipView.name);
  391. }
  392. },
  393. //点击了建造列表里面的按钮时候改变样式
  394. onSetButtonState(Data, Synopsis) {
  395. cc.Component.EventHandler.emitEvents(Data.Target.clickEvents)
  396. },
  397. onSetButtonInfoState(Data, Synopsis) {
  398. if (Synopsis) {
  399. this.onSetButtonInfo(Synopsis.Name, Synopsis.Price, Synopsis.Synopsis)
  400. }
  401. },
  402. //设置介绍信息
  403. onSetButtonInfo(_Name, _Price, _Synopsis) {
  404. this.BuildContent_Name.string = _Name
  405. this.BuildContent_Price.string = _Price
  406. this.BuildContent_Synopsis.string = _Synopsis.replace(/\n|\r/g, '')
  407. },
  408. /**
  409. * 设置商城信息
  410. * @param {}} Data
  411. * @param {*} Synopsis
  412. */
  413. onSetMallInfoState(Data, Synopsis) {
  414. if (Synopsis) {
  415. this.onSetMallInfo(
  416. Synopsis.Name,
  417. Synopsis.Mature,
  418. Synopsis.Price,
  419. Synopsis.Synopsis
  420. )
  421. }
  422. },
  423. //设置介绍信息
  424. onSetMallInfo(_Name, _mature, _Price, _Synopsis) {
  425. this.mallContent_Name.string = _Name
  426. this.mallContent_Price.string = _Price
  427. this.mallContent_Mature.string = _mature
  428. this.mallContent_Synopsis.string = _Synopsis.replace(/\n|\r/g, '')
  429. },
  430. //编辑对应的建筑
  431. onEditorialBuildings(mUI_buildTarget) {
  432. if (!this.EditorialBuildings) {
  433. cc.warn('EditorialBuildings is Null!')
  434. return
  435. }
  436. this.EditorialBuildings.active = true
  437. //重置上一个编辑建筑的状态
  438. if (this._buildTarget && this._buildTarget.getComponent('buildingsTouch')) {
  439. this._buildTarget.getComponent('buildingsTouch').onCancelEdit()
  440. }
  441. this._buildTarget = mUI_buildTarget
  442. this.EditorialBuildings.parent = mUI_buildTarget
  443. this.EditorialBuildings.setPosition(cc.v2(0, 0))
  444. },
  445. //取消编辑
  446. onCancellationEditor() {
  447. //获取建筑物上的组件
  448. let buildTouch = this._buildTarget.getComponent('buildingsTouch')
  449. let isTaskNext = buildTouch.onTaskBuild()
  450. if (!isTaskNext) return
  451. if (task.isMushBuildState) {
  452. cc.loader.loadRes(
  453. 'resUI/ShowNotEnoughMoney',
  454. function (err, texture) {
  455. var prefab = cc.instantiate(texture)
  456. prefab.getComponent('ShowNotEnoughMoney').Text("请点击'√'号")
  457. this._buildTarget.addChild(prefab)
  458. }.bind(this)
  459. )
  460. return
  461. }
  462. // if (buildTouch) {
  463. buildTouch.onCancelEdit()
  464. // }
  465. this.EditorialBuildings.active = false
  466. this.EditorialBuildings.parent = this._thisEditBuildingsParent
  467. this.EditorialBuildings.setPosition(cc.v2(10000, 100))
  468. this._buildTarget = null
  469. },
  470. //确定编辑(创建建筑物 对号)
  471. onConfirmationEditor() {
  472. //获取建筑物上的组件
  473. let buildTouch = this._buildTarget.getComponent('buildingsTouch')
  474. let isTaskNext = buildTouch.onTaskBuild()
  475. if (!isTaskNext) return
  476. // if (buildTouch) {
  477. buildTouch.onFinishEdit()
  478. // }
  479. this.EditorialBuildings.active = false
  480. this.EditorialBuildings.parent = this._thisEditBuildingsParent
  481. this.EditorialBuildings.setPosition(cc.v2(10000, 100))
  482. this._buildTarget = null
  483. },
  484. //如果相等的话返回true
  485. verctor3IsEqual(vector1, vector2) {
  486. let isEqual = false
  487. let out = new cc.Vec3()
  488. out.x = vector2.x - vector1.x
  489. out.y = vector2.y - vector1.y
  490. out.z = vector2.z - vector1.z
  491. if (out.x == 0 && out.y == 0 && out.z == 0) {
  492. isEqual = true
  493. }
  494. return isEqual
  495. },
  496. //收起全部菜单
  497. onHideMenu() {
  498. // if (this.BuildView) {
  499. // this.BuildView.active = false;
  500. // }
  501. //音效设置界面
  502. if (this.SettingInfoView.active)
  503. this.onSetTouchStatus(this.SettingInfoView, false)
  504. //建造界面
  505. if (this.BuildView.active) this.onSetTouchStatus(this.BuildView, false)
  506. //人才界面
  507. if (this.PersonnelView.active)
  508. this.onSetTouchStatus(this.PersonnelView, false)
  509. //股票界面
  510. if (this.StockView.active) this.onSetTouchStatus(this.StockView, false)
  511. //转盘界面
  512. if (this.LuckView.active) this.onSetTouchStatus(this.LuckView, false)
  513. //商城界面
  514. if (this.StoreView.active) this.onSetTouchStatus(this.StoreView, false)
  515. },
  516. //底部菜单栏
  517. onBottomMenuView(isActive) {
  518. if (this.BottomView) {
  519. this.BottomView.active = isActive
  520. }
  521. // cc.log('不能显示面板信息:');
  522. GlobalD.GameControl._isBuildingCanEdit = !isActive
  523. },
  524. //农场界面相关菜单
  525. onOtherFarmerView(isActive) {
  526. if (this.OtherFarmerMask) {
  527. this.OtherFarmerMask.active = isActive
  528. }
  529. },
  530. //开启信息显示
  531. onShowBuildingInfo(buildingInfo) {
  532. this.BuildingInfoView.active = true
  533. if (!this._buildingInfoViewScript)
  534. this._buildingInfoViewScript =
  535. this.BuildingInfoView.getComponent('buildingInfoView')
  536. //显示房屋信息
  537. this._buildingInfoViewScript.onSetBuildingInfoView(buildingInfo)
  538. },
  539. //关闭信息显示
  540. onCloseBuildingInfo() {
  541. this.BuildingInfoView.active = false
  542. },
  543. //进入编辑模式,
  544. onEnterEditing() { },
  545. onSetTouchStatus(target, isActive) {
  546. target.active = isActive
  547. if (this.UITouch) {
  548. this.UITouch.active = isActive
  549. }
  550. },
  551. /**
  552. * 绑定邀请
  553. */
  554. onInvite_Open() {
  555. this.inviteNode.getComponent('inviteInfo').onOpenInviteInfo()
  556. },
  557. onListUserInfo_Open() {
  558. this.listUserInfoNode.getComponent('userListInfo').onOpen()
  559. },
  560. onListUserInfo_Close() {
  561. this.listUserInfoNode.getComponent('userListInfo').onClose()
  562. },
  563. //点击钻石兑换
  564. onButtonEvent_Exchange() {
  565. this.DiamondGapView.active = true
  566. // this.onSetTouchStatus(this.DiamondGapView, true)
  567. //判断钻石数量是否大于等于3万个
  568. if (GlobalD.GameData.GetDiamond() < 30000) {
  569. this.ExchangeBtn.interactable = false
  570. // GlobalD.GameData.showToast(
  571. // cc.find('Canvas/UICamera'),
  572. // '钻石数量不够,累积到30000个钻石即可免费兑换一包辣椒种子。',
  573. // 2
  574. // )
  575. return
  576. } else {
  577. this.ExchangeBtn.interactable = true
  578. }
  579. },
  580. //点击取消钻石兑换
  581. onButtonEvent_ExchangeCancel() {
  582. this.DiamondGapView.active = false
  583. },
  584. //点击确认钻石兑换辣椒种子
  585. onButtonEvent_ExchangeChili() {
  586. let diamonAmount = 30000
  587. //调用兑换接口
  588. GlobalD.GameData.exchangeSeed(diamonAmount, (value) => {
  589. return
  590. //兑换成功
  591. if (0 === value.code) {
  592. var BuildingView = cc
  593. .find('Canvas/UICamera/BuildingContainer/BuildingView')
  594. .getComponent('BuildingView')
  595. BuildingView.onUpdateList()
  596. this.DiamondGapView.active = false
  597. this.DiamondSeedsView.active = true
  598. //光芒旋转
  599. var rotate = cc.repeatForever(cc.rotateBy(2, -100, 0))
  600. this.LightRotate.runAction(rotate)
  601. } else {
  602. //兑换失败
  603. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2)
  604. }
  605. })
  606. },
  607. //点击钻石兑换的确认按钮
  608. onButtonEvent_DiamondSure() {
  609. this.DiamondSeedsView.active = false
  610. //停止光芒旋转
  611. this.LightRotate.stopAllActions()
  612. },
  613. //音效设置界面
  614. onButtonEvent_Setting_OPen() {
  615. this.onHideMenu()
  616. this.onSetTouchStatus(this.SettingInfoView, true)
  617. },
  618. onButtonEvent_Setting_Close() {
  619. this.onSetTouchStatus(this.SettingInfoView, false)
  620. },
  621. //建造界面
  622. onButtonEvent_Building_OPen() {
  623. this.onHideMenu()
  624. this.onSetTouchStatus(this.BuildView, true)
  625. this.BuildView.getComponent('BuildingView').onSwitchBuildingContent(
  626. this.Evn.getComponent(cc.Button),
  627. 4
  628. )
  629. },
  630. //商城界面
  631. onButtonEvent_Store_OPen() {
  632. this.onHideMenu()
  633. this.onSetTouchStatus(this.StoreView, true)
  634. this.StoreView.getComponent('StoreView').onSwitchBuildingContent(
  635. this.Seed.getComponent(cc.Button),
  636. 0
  637. )
  638. },
  639. novice: function () {
  640. var BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView')
  641. task.removeTaskNode(task.taskCursorName[2]) //左上
  642. task.addTaskTips(
  643. BuildingView,
  644. task.taskPrefab[1],
  645. -180,
  646. 180,
  647. task.taskCursorName[2],
  648. function (nodePrefabs) {
  649. //手指
  650. this.nodePrefabs = nodePrefabs
  651. }.bind(this)
  652. )
  653. },
  654. novice1: function () {
  655. var BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView')
  656. task.addTaskTips(
  657. BuildingView,
  658. task.novice[1],
  659. 0,
  660. 50,
  661. task.taskCursorName[3],
  662. function (node) {
  663. UtilsPrefabs.setOn(
  664. node.getChildByName('SureBtn'),
  665. function () {
  666. UtilsPrefabs.setOff(node.getChildByName('SureBtn'))
  667. var mt = cc.moveTo(1, 110, 180) //右上
  668. var finished = cc.callFunc(
  669. function () {
  670. task.removeTaskNode(task.taskCursorName[3])
  671. this.novice2()
  672. }.bind(this)
  673. )
  674. var sequence = cc.sequence(mt, finished)
  675. this.nodePrefabs.runAction(sequence)
  676. task.isShowTaskNode(task.taskCursorName[3], false)
  677. }.bind(this)
  678. )
  679. }.bind(this)
  680. )
  681. },
  682. novice2: function () {
  683. var BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView')
  684. task.addTaskTips(
  685. BuildingView,
  686. task.novice[2],
  687. 0,
  688. 50,
  689. task.taskCursorName[3],
  690. function (node) {
  691. UtilsPrefabs.setOn(
  692. node.getChildByName('SureBtn'),
  693. function () {
  694. UtilsPrefabs.setOff(node.getChildByName('SureBtn'))
  695. var mt = cc.moveTo(1, -200, 0) //
  696. var finished = cc.callFunc(
  697. function () {
  698. task.removeTaskNode(task.taskCursorName[3])
  699. this.novice3()
  700. }.bind(this)
  701. )
  702. var sequence = cc.sequence(mt, finished)
  703. this.nodePrefabs.runAction(sequence)
  704. task.isShowTaskNode(task.taskCursorName[3], false)
  705. }.bind(this)
  706. )
  707. }.bind(this)
  708. )
  709. },
  710. novice3: function () {
  711. var BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView')
  712. task.addTaskTips(
  713. BuildingView,
  714. task.novice[3],
  715. 0,
  716. -150,
  717. task.taskCursorName[3],
  718. function (node) {
  719. UtilsPrefabs.setOn(
  720. node.getChildByName('SureBtn'),
  721. function () {
  722. task.removeTaskNode(task.taskCursorName[3])
  723. }.bind(this)
  724. )
  725. }.bind(this)
  726. )
  727. },
  728. //外面管理的手指
  729. novicepersonnel: function () {
  730. task.removeTaskNode(task.taskCursorName[2]) //左上
  731. task.addTaskTips(
  732. task.personnelview,
  733. task.taskPrefab[1],
  734. 0,
  735. 0,
  736. task.taskCursorName[2],
  737. function (nodePrefabs) {
  738. //手指
  739. this.nodePrefabs = nodePrefabs
  740. }.bind(this)
  741. )
  742. },
  743. //外面的 建筑手指
  744. noviceBuilding: function () {
  745. //建造农舍指引
  746. task.showTiledTile(0, 0, 0, 23, 25)
  747. },
  748. novice4: function () {
  749. var BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView')
  750. task.addTaskTips(
  751. BuildingView,
  752. task.novice[4],
  753. 0,
  754. -200,
  755. task.taskCursorName[3],
  756. function (node) {
  757. UtilsPrefabs.setOn(
  758. node.getChildByName('SureBtn'),
  759. function () {
  760. task.removeTaskNode(task.taskCursorName[3])
  761. }.bind(this)
  762. )
  763. }.bind(this)
  764. )
  765. },
  766. //关闭 建造框
  767. onButtonEvent_Building_Close() {
  768. // cc.log(this.BuildView);
  769. this.onSetTouchStatus(this.BuildView, false)
  770. },
  771. //关闭 商城框
  772. onButtonEvent_Store_Close() {
  773. this.onSetTouchStatus(this.StoreView, false)
  774. },
  775. //人才界面
  776. onButtonEvent_Personnel_OPen() {
  777. this.onHideMenu()
  778. this.onSetTouchStatus(this.PersonnelView, true)
  779. },
  780. onButtonEvent_Personnel_Close() {
  781. this.onSetTouchStatus(this.PersonnelView, false)
  782. },
  783. //股票界面
  784. onButtonEvent_Stock_OPen() {
  785. this.onHideMenu()
  786. this.onSetTouchStatus(this.StockView, true)
  787. // console.log("所有建筑物数据", GlobalD.game.buildingsTiledMapUnit);
  788. UtilsWX.lookRankList(true)
  789. this.showFriend()
  790. },
  791. //限制
  792. returnDialog: function (cursor) {
  793. var num = 0
  794. // console.log("要创建什么提示呢数字", cursor);
  795. switch (cursor) {
  796. case 1:
  797. num = 0
  798. break
  799. case 4:
  800. num = 1
  801. break
  802. case 6:
  803. num = 2
  804. break
  805. }
  806. console.log('要创建什么提示呢', task.returnPrefab[num])
  807. var Canvas = cc.find('Canvas/UICamera')
  808. task.addTaskTips(
  809. Canvas,
  810. task.returnPrefab[num],
  811. 0,
  812. 0,
  813. task.taskCursorName[4],
  814. function (nodePrefabs) {
  815. UtilsPrefabs.setOn(
  816. nodePrefabs.getChildByName('SureBtn'),
  817. function () {
  818. task.removeTaskNode(task.taskCursorName[4])
  819. }.bind(this)
  820. )
  821. }.bind(this)
  822. )
  823. },
  824. showFriend: function () {
  825. // var data1 = {
  826. // name: "Whoareyou",
  827. // openId : userData.openId
  828. // }
  829. // UtilsWX.postMessage(data1);
  830. var data = {
  831. name: 'showFriend',
  832. }
  833. UtilsWX.postMessage(data)
  834. },
  835. onButtonEvent_Stock_Close() {
  836. this.onSetTouchStatus(this.StockView, false)
  837. var data = {
  838. name: 'hideFriend',
  839. }
  840. UtilsWX.postMessage(data)
  841. setTimeout(
  842. function () {
  843. UtilsWX.lookRankList(false)
  844. }.bind(this),
  845. 200
  846. )
  847. },
  848. //转盘界面
  849. onButtonEvent_Luck_OPen() {
  850. this.onHideMenu()
  851. this.onSetTouchStatus(this.LuckView, true)
  852. if (this.nodePrefabsLuck != null) {
  853. task.removeNode(this.nodePrefabsLuck)
  854. }
  855. },
  856. isTask: function (obj) {
  857. var Canvas = cc.find('Canvas/UICamera')
  858. UtilsPrefabs.init(Canvas).addPrefabs(
  859. UtilsPrefabs.sharePrefab[1],
  860. null,
  861. function (node) {
  862. var gosharebtn = UtilsPrefabs.getNode('gosharebtn', node)
  863. var close = UtilsPrefabs.getNode('close', node)
  864. UtilsPrefabs.setOn(
  865. close,
  866. function () {
  867. UtilsPrefabs.removePrefabs(Canvas, node.name)
  868. if (task.TaskIconCountClick == 5) {
  869. if (obj.currentTarget.name == 'GetGift') {
  870. task.addTaskIconCountClick()
  871. task.removeTaskNodes()
  872. }
  873. }
  874. }.bind(this)
  875. )
  876. UtilsPrefabs.setOn(
  877. gosharebtn,
  878. function () {
  879. // console.log("点击分享按钮");
  880. UtilsWX.sharebtn(
  881. function () {
  882. UtilsPrefabs.setOff(gosharebtn)
  883. GlobalD.GameData.PlusGolden(GlobalD.GameData.shareGive[0])
  884. GlobalD.GameData.PlusDiamond(GlobalD.GameData.shareGive[1])
  885. if (task.TaskIconCountClick == 5) {
  886. if (obj.currentTarget.name == 'GetGift') {
  887. task.addTaskIconCountClick()
  888. task.removeTaskNodes()
  889. }
  890. }
  891. }.bind(this)
  892. )
  893. UtilsPrefabs.removePrefabs(Canvas, node.name)
  894. }.bind(this)
  895. )
  896. }.bind(this)
  897. )
  898. },
  899. isTask4: function () {
  900. if (task.TaskIconCountClick == 4) {
  901. task.addTaskIconCountClick()
  902. task.removeTaskNodes()
  903. }
  904. },
  905. onButtonEvent_Luck_Close(obj) {
  906. // console.log("现在是谁点的", obj);
  907. let Wheel = this.LuckView.getChildByName('Wheel').getComponent('Wheel')
  908. Wheel.node.active = true
  909. Wheel.ShowRewards.active = false
  910. this.onSetTouchStatus(this.LuckView, false)
  911. if (obj.target.name == 'GetGift') {
  912. this.isTask(obj)
  913. }
  914. },
  915. onButtonEvent_EveryDay_OPen() {
  916. this.onHideMenu()
  917. this.onSetTouchStatus(this.EveryDaySignView, true)
  918. //打开每日签到 外面的按钮
  919. if (task.TaskIconCountClick == 4) {
  920. var EveryDaySign = cc.find(
  921. 'Canvas/UICamera/OverTheMask/EveryDaySignContainer/EveryDaySignView'
  922. )
  923. // var Canvas = cc.find("Canvas/UICamera");
  924. // task.removeTaskNodes();
  925. task.removeTaskNode(task.taskCursorName[4])
  926. task.addTaskTips(
  927. EveryDaySign,
  928. task.taskPrefab[1],
  929. 20,
  930. -470,
  931. task.taskCursorName[4],
  932. function (nodePrefabs) { }.bind(this)
  933. )
  934. }
  935. },
  936. onButtonEvent_EveryDay_Close() {
  937. this.onSetTouchStatus(this.EveryDaySignView, false)
  938. },
  939. onShowRewards: function (Index) {
  940. let ManageBuildingScript = this.node.getComponent('ManageBuildings')
  941. console.log('走了吗', Index)
  942. let GivePrize = this.ShowRewards.getChildByName('GivePrize')
  943. let Rewards = GivePrize.getChildByName('Rewards')
  944. Rewards.getComponent(cc.Sprite).spriteFrame = this.BuildingFrameArray[
  945. Index
  946. ].getChildByName('New Sprite(Splash)').getComponent(cc.Sprite).spriteFrame
  947. //开始播放
  948. var Sunshine =
  949. this.ShowRewards.getChildByName('GivePrize').getChildByName('Sunshine')
  950. Sunshine.scaleX = 0
  951. Sunshine.scaleY = 0
  952. GivePrize.scaleX = 0
  953. GivePrize.scaleY = 0
  954. Sunshine.stopAllActions()
  955. GivePrize.stopAllActions()
  956. this.scheduleOnce(function () {
  957. this.ShowRewards.opacity = 255
  958. this.ShowRewards.active = true
  959. var sc2 = cc.scaleTo(1, 0.5, 0.5)
  960. Sunshine.runAction(sc2)
  961. var sc3 = cc.scaleTo(1, 1, 1)
  962. GivePrize.runAction(sc3)
  963. var repeat = cc.repeatForever(cc.rotateBy(5.0, 360))
  964. Sunshine.runAction(repeat)
  965. }, 0.1)
  966. },
  967. onCloseShowRewards: function () {
  968. this.ShowRewards.active = false
  969. },
  970. DiamondGapViewShow: function () {
  971. this.DiamondGapView.active = true
  972. },
  973. GoldenChangeCallBack: function (Num, LastMoney, CurrentMoney) {
  974. let Scale = 30
  975. let Index = -1
  976. // if(Num>10*Scale)
  977. // {
  978. // Index = 7;//伐木场
  979. // }
  980. // if(Num>30*Scale)
  981. // {
  982. // Index = 8;//矿坑
  983. // }
  984. // if(Num>70*Scale)
  985. // {
  986. // // Index = 9;//加工厂
  987. // }
  988. // if(Num>350*Scale && Num<450*Scale)
  989. // {
  990. // Index = 4;//单元楼
  991. // }
  992. if (Num > 4000 && Num < 4500) {
  993. Index = 4 //单元楼
  994. }
  995. // else if(Num>450*Scale && Num<550*Scale)
  996. // {
  997. // Index = 11;//鲜花店
  998. // }
  999. else if (Num > 4500 && Num < 5500) {
  1000. Index = 11 //鲜花店
  1001. } else if (Num > 550 * Scale && Num < 650 * Scale) {
  1002. Index = 12 //甜品店
  1003. }
  1004. if (Num > 650 * Scale && Num < 750 * Scale) {
  1005. Index = 7 //伐木场
  1006. } else if (Num > 750 * Scale && Num < 950 * Scale) {
  1007. Index = 13 //汉堡店
  1008. }
  1009. // else if(Num>850*Scale)
  1010. // {
  1011. // Index = 0;//公路
  1012. // }
  1013. else if (Num > 950 * Scale && Num < 1050 * Scale) {
  1014. Index = 14 //咖啡店
  1015. } else if (Num > 1050 * Scale && Num < 1150 * Scale) {
  1016. Index = 5 //别墅
  1017. } else if (Num > 1150 * Scale && Num < 1250 * Scale) {
  1018. Index = 15 //洋装店
  1019. }
  1020. if (Num > 1250 * Scale && Num < 1350 * Scale) {
  1021. Index = 8 //矿坑
  1022. } else if (Num > 1350 * Scale) {
  1023. Index = 16 //酒吧
  1024. }
  1025. // else if(Num>250*Scale)
  1026. // {
  1027. // Index = 4;//单元楼
  1028. // }
  1029. // else if(Num>600*Scale)
  1030. // {
  1031. // Index = 5;//别墅
  1032. // }
  1033. var BuildingStateArray = GlobalD.GameData.GetBuildingStateArray()
  1034. if (Index == 0) {
  1035. if (BuildingStateArray[Index] != 1) {
  1036. BuildingStateArray[0] = 1 //公路
  1037. BuildingStateArray[1] = 1 //路铲
  1038. BuildingStateArray[2] = 1 //拆迁
  1039. let Building0 =
  1040. this.node.getComponent('ManageBuildings').BuildingArray[0]
  1041. let Building1 =
  1042. this.node.getComponent('ManageBuildings').BuildingArray[1]
  1043. let Building2 =
  1044. this.node.getComponent('ManageBuildings').BuildingArray[2]
  1045. Building0.active = true
  1046. Building1.active = true
  1047. Building2.active = true
  1048. GlobalD.GameData.SetBuildingStateArray(BuildingStateArray)
  1049. this.onShowRewards(Index)
  1050. }
  1051. } else {
  1052. if (BuildingStateArray[Index] != 1 && Index != -1) {
  1053. cc.log('Index=' + Index)
  1054. BuildingStateArray[Index] = 1
  1055. let Building =
  1056. this.node.getComponent('ManageBuildings').BuildingArray[Index]
  1057. Building.active = true
  1058. GlobalD.GameData.SetBuildingStateArray(BuildingStateArray)
  1059. this.onShowRewards(Index)
  1060. }
  1061. }
  1062. let Diff = CurrentMoney - LastMoney
  1063. let InitMoneyNum = LastMoney
  1064. let AnimTimes = 0
  1065. let Times = 3
  1066. this.schedule(
  1067. function () {
  1068. if (Diff > 0) {
  1069. InitMoneyNum += parseInt((CurrentMoney - LastMoney) / Times)
  1070. } else {
  1071. InitMoneyNum -= parseInt((CurrentMoney - LastMoney) / Times)
  1072. }
  1073. let result = this.FormatMoney(InitMoneyNum)
  1074. if (AnimTimes == Times - 1) {
  1075. this.Goldenlabel.getComponent(cc.Label).string =
  1076. this.FormatMoney(CurrentMoney)
  1077. return
  1078. }
  1079. this.Goldenlabel.getComponent(cc.Label).string = result
  1080. AnimTimes++
  1081. },
  1082. 0.05,
  1083. Times
  1084. )
  1085. },
  1086. DiamondChangeCallBack: function (Num, LastMoney, CurrentMoney) {
  1087. let Diff = CurrentMoney - LastMoney
  1088. let InitMoneyNum = LastMoney
  1089. let AnimTimes = 0
  1090. let Times = 3
  1091. this.schedule(
  1092. function () {
  1093. if (Diff > 0) {
  1094. InitMoneyNum += parseInt((CurrentMoney - LastMoney) / Times)
  1095. } else {
  1096. InitMoneyNum -= parseInt((CurrentMoney - LastMoney) / Times)
  1097. }
  1098. let result = this.FormatMoney(InitMoneyNum)
  1099. if (AnimTimes == Times - 1) {
  1100. // this.DiamondNowlabel.string = result + '/30000'
  1101. this.Diamondlabel.getComponent(cc.Label).string =
  1102. this.FormatMoney(CurrentMoney)
  1103. return
  1104. }
  1105. // this.DiamondNowlabel.string = result + '/30000'
  1106. this.Diamondlabel.getComponent(cc.Label).string = result
  1107. AnimTimes++
  1108. },
  1109. 0.05,
  1110. Times
  1111. )
  1112. },
  1113. CNTChangeCallBack: function (Num) {
  1114. this.CNTlabel.getComponent(cc.Label).string = this.FormatMoney(Num)
  1115. },
  1116. SNBChangeCallBack: function (Num) {
  1117. this.SNBlabel.getComponent(cc.Label).string = this.FormatMoney(Num)
  1118. },
  1119. FormatMoney(s, n) {
  1120. n = n > 0 && n <= 20 ? n : 2
  1121. s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
  1122. var l = s.split('.')[0].split('').reverse(),
  1123. r = s.split('.')[1]
  1124. let t = ''
  1125. for (let i = 0; i < l.length; i++) {
  1126. t += l[i] + ((i + 1) % 3 == 0 && i + 1 != l.length ? ',' : '')
  1127. }
  1128. return t.split('').reverse().join('') //+ "." + r;
  1129. },
  1130. /**
  1131. * 偷取果实
  1132. */
  1133. onStealAllFruit() {
  1134. //todo 偷取之前本地判断下体力值
  1135. if (GlobalD.PlayerAttribute.currentStrength <= 0) {
  1136. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "体力不足,无法收取作物!", 1);
  1137. return;
  1138. }
  1139. GlobalD.GameData.onStealAllFruit({ otherUserId: GlobalD.OtherUserInfo.userId }, (value) => {
  1140. console.log(value);
  1141. if (0 === value.code) {
  1142. if (this.StealViewSuccessPrefab) {
  1143. let _TipView = cc.instantiate(this.StealViewSuccessPrefab)
  1144. _TipView.parent = this.TipView
  1145. _TipView.setPosition(cc.v2(0, 0))
  1146. _TipView
  1147. .getComponent('StealViewSuccess')
  1148. .setInfo({ amount: value.data.stealSum });
  1149. }
  1150. let BuildingView = cc.find('Canvas/UICamera/BuildingContainer/BuildingView').getComponent('BuildingView');
  1151. BuildingView.onUpdateList();
  1152. //偷取成功后,关闭对应土地的提示图标
  1153. let _landBuildingsInfo = cc.find("Canvas/MyMapNode").children;
  1154. let _stealList = value.data.steals;
  1155. for (let j = 0; j < _stealList.length; j++) {
  1156. for (let i = _landBuildingsInfo.length - 1; i >= 0; i--) {
  1157. let resetLandInfo = _landBuildingsInfo[i];
  1158. if (resetLandInfo.name == "Labour_205_Holy_Farmland") {
  1159. let leaseFarmlandInfoScript = resetLandInfo.getComponent("LeaseFarmlandInfo");
  1160. if (leaseFarmlandInfoScript.leaseLandInfo && leaseFarmlandInfoScript.leaseLandInfo.configLandId == _stealList[j].landId) {
  1161. leaseFarmlandInfoScript.onHideStealHarvest();
  1162. }
  1163. }
  1164. }
  1165. }
  1166. } else {
  1167. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), value.msg, 1);
  1168. }
  1169. });
  1170. },
  1171. //体力值
  1172. StrengthChangeCallBack: function (Num) {
  1173. this.Strengthlabel.getComponent(cc.Label).string = Num
  1174. },
  1175. //幸运值
  1176. LuckyChangeCallBack: function (Num) {
  1177. this.Luckylabel.getComponent(cc.Label).string = Num
  1178. },
  1179. })