ManageUI.js 38 KB

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