ManageUI.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  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. //记录当前选中的buildInfo
  1129. GlobalD.game.onSetCurrentSelectLeaseLandInfo(null);
  1130. }
  1131. }
  1132. this.onHideShowToolsAnimation();
  1133. this.onHideTopLabelAnimation();
  1134. this.onHideTopButtonAnimation();
  1135. },
  1136. onSwitchHideUI() {
  1137. this.onPlayShowToolsAnimation();
  1138. this.onPlayTopLabelAnimation();
  1139. this.onPlayTopButtonAnimation();
  1140. },
  1141. //底部工具栏
  1142. onPlayShowToolsAnimation() {
  1143. if (this.isShowTools) return;
  1144. this.isShowTools = true;
  1145. let animation = this.BottomView.getChildByName('BottomButton').getComponent(cc.Animation);
  1146. let state = animation.getAnimationState(animation.defaultClip.name);
  1147. if (!state.isPlaying) {
  1148. state.wrapMode = cc.WrapMode.Normal;
  1149. animation.play();
  1150. //播放之后设置一个状态
  1151. }
  1152. },
  1153. onHideShowToolsAnimation() {
  1154. if (!this.isShowTools) return;
  1155. this.isShowTools = false;
  1156. let animation = this.BottomView.getChildByName('BottomButton').getComponent(cc.Animation);
  1157. let state = animation.getAnimationState(animation.defaultClip.name);
  1158. if (!state.isPlaying) {
  1159. state.wrapMode = cc.WrapMode.Reverse;
  1160. animation.play();
  1161. }
  1162. },
  1163. //顶部工具栏
  1164. onPlayTopLabelAnimation() {
  1165. if (this.isShowTopLabel) return;
  1166. this.isShowTopLabel = true;
  1167. let animation = this.BottomView.getChildByName('TopLabel').getComponent(cc.Animation);
  1168. let state = animation.getAnimationState(animation.defaultClip.name);
  1169. if (!state.isPlaying) {
  1170. state.wrapMode = cc.WrapMode.Normal;
  1171. animation.play();
  1172. //播放之后设置一个状态
  1173. }
  1174. },
  1175. onHideTopLabelAnimation() {
  1176. if (!this.isShowTopLabel) return;
  1177. this.isShowTopLabel = false;
  1178. let animation = this.BottomView.getChildByName('TopLabel').getComponent(cc.Animation);
  1179. let state = animation.getAnimationState(animation.defaultClip.name);
  1180. if (!state.isPlaying) {
  1181. state.wrapMode = cc.WrapMode.Reverse;
  1182. animation.play();
  1183. }
  1184. },
  1185. //右边按钮栏
  1186. onPlayTopButtonAnimation() {
  1187. if (this.isShowTopButton) return;
  1188. this.isShowTopButton = true;
  1189. let animation = this.BottomView.getChildByName('TopButton').getComponent(cc.Animation);
  1190. let state = animation.getAnimationState(animation.defaultClip.name);
  1191. if (!state.isPlaying) {
  1192. state.wrapMode = cc.WrapMode.Normal;
  1193. animation.play();
  1194. //播放之后设置一个状态
  1195. }
  1196. },
  1197. onHideTopButtonAnimation() {
  1198. if (!this.isShowTopButton) return;
  1199. this.isShowTopButton = false;
  1200. let animation = this.BottomView.getChildByName('TopButton').getComponent(cc.Animation);
  1201. let state = animation.getAnimationState(animation.defaultClip.name);
  1202. if (!state.isPlaying) {
  1203. state.wrapMode = cc.WrapMode.Reverse;
  1204. animation.play();
  1205. }
  1206. },
  1207. onDestroy() {
  1208. GlobalD.TiledMap.node.off('TiledMap_Touch_End', this.onResetUI, this)
  1209. }
  1210. })