ManageUI.js 37 KB

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