HomeGuide.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  1. const Api = require('../net/Api');
  2. const { GameNotificationKey, HomeGuideDialogType, HomeGuideArrowType } = require("../utils/GameEnum");
  3. const GameModule = require("../utils/GameModule");
  4. const TapTapTool = require("../utils/TapTapTool");
  5. const buildingLevel = require('../data/buildingLevel');
  6. cc.Class({
  7. extends: cc.Component,
  8. properties: {
  9. blockNode: cc.Node,
  10. touchNode: cc.Node,
  11. taskNode: cc.Node,
  12. taskTitleLabel: cc.Label,
  13. taskCoditionLabel: cc.Label,
  14. specialFrames: [cc.SpriteFrame],
  15. specialMask: cc.Node,
  16. specialMaskBg: cc.Node,
  17. mask: cc.Node,
  18. maskBg: cc.Node,
  19. arrowNode: cc.Node,
  20. blackGuideNode: cc.Node,
  21. tipsNode: cc.Node,
  22. descNode: cc.Node,
  23. //不同方向的对话框
  24. dialogTopRight: cc.Node,
  25. dialogTopLeft: cc.Node,
  26. dialogBottomLeft: cc.Node,
  27. //不同方向的人物
  28. figureLeft: cc.Node,
  29. figureRight: cc.Node,
  30. blockEvent: cc.Node,
  31. //手指
  32. fingerNode: cc.Node,
  33. finger: cc.Node
  34. },
  35. onLoad () {
  36. this.isPlaying = false;
  37. },
  38. init () {
  39. this.vsize = cc.view.getVisibleSize();
  40. this.initEvent();
  41. this.stateRecord = {};
  42. this._show13 = false;
  43. this.isShowFinger = false;
  44. this.guideState = {
  45. state1 : {
  46. tips: '纸醉金迷的城市某一处。。。',
  47. pass: 0,
  48. mask: 1,
  49. once: true
  50. },
  51. state2 : {
  52. tips: '一家经纪公司在默默成长。。。',
  53. pass: 0,
  54. mask: 1,
  55. once: true
  56. },
  57. state3 : {
  58. tips: '一个娱乐圈创业者的故事。。。',
  59. pass: 0,
  60. mask: 1,
  61. once: true
  62. },
  63. state4 : {
  64. tips: '嘿~老板!你回来啦!\n愣着出神在想什么呢?',
  65. pass: 0,
  66. mask: 1,
  67. dialogType: HomeGuideDialogType.BottomLeft,
  68. rect: [0, 0],
  69. pos: [0, 0],
  70. once: true
  71. },
  72. state5 : {
  73. tips: '开始努力赚钱啦~\n我们公司还没签约明星呢',
  74. pass: 0,
  75. mask: 1,
  76. dialogType: HomeGuideDialogType.BottomLeft,
  77. rect: [0, 0],
  78. pos: [0, 0],
  79. once: true
  80. },
  81. state6 : {
  82. tips: '点击下方的招财猫\n就可以获得金币啦',
  83. pass: 0,
  84. mask: 1,
  85. dialogType: HomeGuideDialogType.TopLeft,
  86. rect: [212, 244],
  87. pos: [13, -685],
  88. once: true,
  89. special: 'guide_black_cat'
  90. },
  91. state7 : {
  92. tips: '',
  93. taskTitle: '累积赚取200金币',
  94. taskCodition: 200,
  95. pass: 0,
  96. mask: 0,
  97. once: false
  98. },
  99. state8 : {
  100. tips: '金币可以升级总部大楼\n和购买明星',
  101. pass: 0,
  102. mask: 1,
  103. dialogType: HomeGuideDialogType.BottomLeft,
  104. rect: [0, 0],
  105. pos: [0, 0],
  106. once: true
  107. },
  108. state9 : {
  109. tips: '积累的金币可在屏幕的\n正上方查看噢',
  110. pass: 0,
  111. mask: 1,
  112. dialogType: HomeGuideDialogType.BottomLeft,
  113. rect: [0, 0],
  114. pos: [0, 0],
  115. arrowType: HomeGuideArrowType.Top,
  116. arrowPos: [0, 500],
  117. once: true
  118. },
  119. state10 : {
  120. tips: '金币的计算单位是\n1000=1A,1000A=1B...\n1000Y=1Z!!!',
  121. pass: 0,
  122. mask: 1,
  123. dialogType: HomeGuideDialogType.BottomLeft,
  124. rect: [0, 0],
  125. pos: [0, 0],
  126. arrowType: HomeGuideArrowType.Top,
  127. arrowPos: [0, 500],
  128. once: true
  129. },
  130. state11 : {
  131. tips: '点击左下角的总部大楼',
  132. pass: 0,
  133. mask: 1,
  134. dialogType: HomeGuideDialogType.TopRight,
  135. rect: [103, 95],
  136. pos: [-264, -760],
  137. once: true,
  138. special: 'guide_black_office'
  139. },
  140. state12 : {
  141. tips: '在这个界面升级你的总部大楼',
  142. pass: 0,
  143. mask: 1,
  144. dialogType: HomeGuideDialogType.TopRight,
  145. rect: [0, 0],
  146. pos: [0, 0],
  147. once: true
  148. },
  149. state13 : {
  150. tips: '',
  151. taskTitle: '总部大楼达到5级',
  152. taskCodition: 5,
  153. pass: 0,
  154. mask: 0,
  155. rect: [328, 160],
  156. pos: [80, 100], //手指点猫的位置
  157. arrowType: HomeGuideArrowType.Right,
  158. arrowPos: [80, 100],/// 箭头的位置
  159. once: false
  160. },
  161. state14 : {
  162. tips: '总部大楼等级越高\n点击产生的金币就越多!',
  163. pass: 0,
  164. mask: 1,
  165. dialogType: HomeGuideDialogType.TopRight,
  166. rect: [0, 0],
  167. pos: [0, 0],
  168. once: true
  169. },
  170. state15 : {
  171. tips: '',
  172. taskTitle: '总部大楼达到25级',
  173. taskCodition: 25,
  174. pass: 0,
  175. mask: 0,
  176. rect: [328, 160],
  177. pos: [80, 100], //手指点猫的位置
  178. arrowType: HomeGuideArrowType.Right,
  179. arrowPos: [80, 100],/// 箭头的位置
  180. once: false
  181. },
  182. state16 : {
  183. tips: '这是每25级获得的奖励!\n领取后该房间自动产出X2',
  184. pass: 0,
  185. mask: 1,
  186. dialogType: HomeGuideDialogType.TopRight,
  187. arrowType: HomeGuideArrowType.Left,
  188. arrowPos: [-180, 100],/// 箭头的位置
  189. rect: [108, 105],
  190. pos: [-279, -44],
  191. once: true,
  192. special: 'guide_black_award'
  193. },
  194. state17 : {
  195. tips: '现在我们来解锁房间吧',
  196. pass: 0,
  197. mask: 1,
  198. dialogType: HomeGuideDialogType.TopRight,
  199. rect: [0, 0],
  200. pos: [0, 0],
  201. once: true
  202. },
  203. state20 : {
  204. tips: '在主界面你可以解锁房间\n解锁后房间会自动产出金币',
  205. pass: 0,
  206. mask: 1,
  207. dialogType: HomeGuideDialogType.TopRight,
  208. rect: [0, 0],
  209. pos: [0, 0],
  210. once: true
  211. },
  212. state21 : {
  213. tips: '',
  214. taskTitle: '豪华的服装间达到5级',
  215. taskCodition: 5,
  216. pass: 0,
  217. mask: 0,
  218. rect: [328, 160],
  219. pos: [0, -500], //手指点猫的位置
  220. pos2: [100, 50], //手指点解锁房间位置
  221. pos3: [280, -65], //手指点升级位置
  222. once: false
  223. },
  224. state23 : {
  225. tips: '房间等级越高,自动产出的\n金币就越多哦~',
  226. pass: 0,
  227. mask: 1,
  228. dialogType: HomeGuideDialogType.TopRight,
  229. rect: [0, 0],
  230. pos: [0, 0],
  231. once: true
  232. },
  233. state24 : {
  234. tips: '',
  235. taskTitle: '豪华的服装间达到25级',
  236. taskCodition: 25,
  237. pass: 0,
  238. mask: 0,
  239. rect: [328, 160],
  240. pos: [0, -500], //手指点猫的位置
  241. pos2: [100, 50], //手指点解锁房间位置
  242. pos3: [280, -65], //手指点升级位置
  243. once: false
  244. },
  245. state26 : {
  246. tips: '这是每25级获得的奖励!\n领取后该房间自动产出X2',
  247. pass: 0,
  248. mask: 1,
  249. dialogType: HomeGuideDialogType.TopRight,
  250. rect: [92, 109],
  251. pos: [0, -100],
  252. once: true,
  253. special: 'guide_black_levelHome_award'
  254. },
  255. state27 : {
  256. tips: '现在我们可以签约明星啦!',
  257. pass: 0,
  258. mask: 1,
  259. dialogType: HomeGuideDialogType.TopLeft,
  260. rect: [0, 0],
  261. pos: [0, 0],
  262. once: true
  263. },
  264. state28 : {
  265. tips: '点击右下角的明星',
  266. pass: 0,
  267. mask: 1,
  268. dialogType: HomeGuideDialogType.TopLeft,
  269. rect: [64, 90],
  270. pos: [260, -760],
  271. once: true,
  272. special: 'guide_black_star'
  273. },
  274. state29 : {
  275. tips: '',
  276. pass: 0,
  277. mask: 0,
  278. rect: [0, 0],
  279. pos: [0, 0], //手指点猫的位置
  280. arrowType: HomeGuideArrowType.Right,
  281. arrowPos: [80, 255],/// 箭头的位置
  282. once: false
  283. },
  284. state31 : {
  285. tips: '查看右上角的任务中心',
  286. pass: 0,
  287. mask: 1,
  288. dialogType: HomeGuideDialogType.TopLeft,
  289. rect: [100, 74],
  290. pos: [322, 328],
  291. once: true,
  292. special: 'guide_black_task'
  293. },
  294. state32 : {
  295. tips: '如果不知道干什么...\n那就看下每日任务!',
  296. pass: 0,
  297. mask: 1,
  298. dialogType: HomeGuideDialogType.TopLeft,
  299. rect: [0, 0],
  300. pos: [0, 0],
  301. once: true
  302. },
  303. state33 : {
  304. tips: '',
  305. pass: 0,
  306. mask: 0,
  307. rect: [0, 0],
  308. pos: [0, 0],
  309. arrowType: HomeGuideArrowType.Right,
  310. arrowPos: [245, 515],
  311. once: true
  312. },
  313. state34 : {
  314. tips: '今天是我们的第一次签到哦~',
  315. pass: 0,
  316. mask: 0,
  317. rect: [0, 0],
  318. pos: [0, 0],
  319. dialogType: HomeGuideDialogType.TopLeft,
  320. once: true
  321. },
  322. };
  323. this.setupUI();
  324. this.syncStatePass();
  325. this.setupAllFinished();
  326. // for(let i = 1; i < 34; i++) {
  327. // let state = `state${i}`;
  328. // if (this.guideState[state] != undefined) {
  329. // this.guideState[state].pass = 0;
  330. // }
  331. // }
  332. // for(let i = 0; i < 34; i++) {
  333. // let state = `state${i}`;
  334. // if (this.guideState[state] != undefined) {
  335. // this.guideState[state].pass = 1;
  336. // }
  337. // }
  338. // this.guideState.state13.pass = 0;
  339. // this.guideState.state8.pass = 1;
  340. // this.guideState.state9.pass = 0;14
  341. // this.guideState.state10.pass = 0;
  342. // this.guideState.state11.pass = 0;
  343. // this.setupAllFinished();
  344. let self = this;
  345. this.finishState7 = _.debounce(() => {
  346. self.updateGuideState();
  347. self.handlePass(this.curState);
  348. self.handleState('state8');
  349. }, 1000, true);
  350. this.finishState13 = _.debounce(() => {
  351. let state = this.curState;
  352. self.updateGuideState();
  353. self.handlePass(this.curState);
  354. if (state === 'state13') {
  355. self.handleState('state14');
  356. } else {
  357. self.handleState('state16');
  358. }
  359. }, 1000, true);
  360. this.finishState21 = _.debounce(() => {
  361. self.updateGuideState();
  362. self.handlePass(this.curState);
  363. self.handleState('state23');
  364. }, 1000, true);
  365. this.finishState24 = _.debounce(() => {
  366. // this.node.emit(`Fire_${this.curState}`);
  367. self.updateGuideState();
  368. self.handlePass(this.curState);
  369. }, 1000, true);
  370. },
  371. setupUI() {
  372. let secretaryY = this.figureLeft.height / 2 - this.vsize.height / 2 + 20;
  373. this.figureLeft.y = secretaryY;
  374. this.figureRight.y = secretaryY;
  375. this.dialogY = this.dialogTopLeft.height / 2 - this.vsize.height / 2 + 270;
  376. this.dialogTopLeft.y = this.dialogY;
  377. this.dialogTopRight.y = this.dialogY;
  378. this.bottomDialogY = (344 - this.vsize.height) / 2;
  379. this.dialogBottomLeft.y = this.bottomDialogY;
  380. if (this.vsize.height >= 1624) {
  381. this.taskNode.y += 120;
  382. } else if (this.vsize.height >= 1500) {
  383. this.taskNode.y += 80;
  384. }
  385. },
  386. tabbarHideCat() {
  387. this.fingerNode.active = false;
  388. this.isShowFinger = false;
  389. },
  390. tabbarShowCat() {
  391. this.isShowFinger = true;
  392. },
  393. onDestroy() {
  394. },
  395. /**F
  396. * 同步用户guideState
  397. */
  398. syncStatePass () {
  399. let _guideState = window.guideState;
  400. // let _guideState = cc.sys.localStorage.getItem('guideState');
  401. if(!!_guideState) {
  402. for(let i in _guideState) {
  403. if(this.guideState[i]) {
  404. this.guideState[i].pass = _guideState[i];
  405. }
  406. }
  407. } else {
  408. let _guideState = Object.assign({}, this.guideState);
  409. this.uploadUserState(_guideState);
  410. }
  411. },
  412. setupAllFinished() {
  413. // 判断满足以下条件时为已完成购买明星前的教程:
  414. // 1. 总部大楼大于25级
  415. // 2. 已拥有1个明星
  416. let unLockStatus1 = GameGlobal.userData.buildingLevel >= 25;
  417. let unLockStatus2 = GameGlobal.userData.buyStarCount > 0;
  418. // 3. 是否已签到过
  419. let unLockStatus3 = GameGlobal.signCount > 0;
  420. if (unLockStatus1 && unLockStatus2) {
  421. if (unLockStatus3) {
  422. for(let i = 1; i < 35; i++) {
  423. let state = `state${i}`;
  424. if (this.guideState[state] != undefined) {
  425. this.guideState[state].pass = 1;
  426. }
  427. }
  428. } else {
  429. for(let i = 1; i < 31; i++) {
  430. let state = `state${i}`;
  431. if (this.guideState[state] != undefined) {
  432. this.guideState[state].pass = 1;
  433. }
  434. }
  435. }
  436. }
  437. },
  438. /**
  439. * 上报用户guideState
  440. * @param {Object} stateObj guideState对象
  441. */
  442. uploadUserState (stateObj) {
  443. // return;
  444. for(let i in stateObj) {
  445. stateObj[i] = stateObj[i].pass;
  446. }
  447. let stateStr = JSON.stringify(stateObj);
  448. // cc.sys.localStorage.setItem('guideState', stateStr)
  449. // 上报用户数据
  450. Api.httpPost({
  451. url: "/direct/add.do",
  452. data: {
  453. directJson: stateStr
  454. },
  455. success: res => {
  456. }
  457. })
  458. },
  459. initEvent() {
  460. this.blackGuideNode.on(cc.Node.EventType.TOUCH_END, () => {
  461. if (this.curState == 'state1') {
  462. this.hideBlackGuide();
  463. } else if (this.curState == 'state2') {
  464. this.hideBlackGuide();
  465. } else if (this.curState == 'state3') {
  466. this.hideBlackGuide();
  467. }
  468. });
  469. this.touchNode.on(cc.Node.EventType.TOUCH_END, () => {
  470. if (this.isPlaying) { return; }
  471. if (this.curState == 'state4') {
  472. this.handlePass(this.curState);
  473. this.handleState('state5');
  474. } else if (this.curState == 'state5') {
  475. this.node.emit(`Fire_${this.curState}`);
  476. this.handlePass(this.curState);
  477. this.handleState('state6');
  478. } else if (this.curState == 'state8') {
  479. this.handlePass(this.curState);
  480. this.handleState('state9');
  481. } else if (this.curState == 'state9') {
  482. this.handlePass(this.curState);
  483. this.handleState('state10');
  484. } else if (this.curState == 'state10') {
  485. this.handlePass(this.curState);
  486. this.handleState('state11');
  487. } else if (this.curState == 'state12') {
  488. this.handlePass(this.curState);
  489. this.handleState('state13');
  490. } else if (this.curState == 'state14') {
  491. this.handlePass(this.curState);
  492. this.handleState('state15');
  493. } else if (this.curState == 'state17') {
  494. this.node.emit(`Fire_${this.curState}`);
  495. this.handlePass(this.curState);
  496. this.handleState('state20');
  497. } else if (this.curState == 'state20') {
  498. this.handlePass(this.curState);
  499. this.handleState('state21');
  500. } else if (this.curState == 'state23') {
  501. this.handlePass(this.curState);
  502. this.handleState('state24');
  503. } else if (this.curState == 'state27') {
  504. this.handlePass(this.curState);
  505. this.handleState('state28');
  506. } else if (this.curState == 'state32') {
  507. this.node.emit(`Fire_${this.curState}`);
  508. this.handlePass(this.curState);
  509. this.handleState('state33');
  510. } else if (this.curState == 'state34') {
  511. this.handlePass(this.curState);
  512. }
  513. });
  514. //点击遮罩指定地方触发
  515. this.mask.on(cc.Node.EventType.TOUCH_END, () => {
  516. if (this.isPlaying) { return; }
  517. if(!!this.curState) {
  518. // 其他state的操作处理,触发在此节点上的自定义事件
  519. this.node.emit(`Fire_${this.curState}`);
  520. this.handlePass(this.curState);
  521. }
  522. }, this);
  523. //点击特殊遮罩指定地方触发
  524. this.specialMask.on(cc.Node.EventType.TOUCH_END, () => {
  525. if (this.isPlaying) { return; }
  526. if (this.curState == 'state6') {
  527. this.node.emit(`Fire_${this.curState}`);
  528. this.handlePass(this.curState);
  529. this.handleState('state7');
  530. } else if (this.curState == 'state16') {
  531. this.node.emit(`Fire_${this.curState}`);
  532. this.handlePass(this.curState);
  533. this.handleState('state17');
  534. } else if (this.curState == 'state26') {
  535. this.node.emit(`Fire_${this.curState}`);
  536. this.handlePass(this.curState);
  537. this.handleState('state27');
  538. } else if (this.curState == 'state31') {
  539. this.node.emit(`Fire_${this.curState}`);
  540. this.handlePass(this.curState);
  541. this.handleState('state32');
  542. } else if(!!this.curState) {
  543. // 其他state的操作处理,触发在此节点上的自定义事件
  544. this.node.emit(`Fire_${this.curState}`);
  545. this.handlePass(this.curState);
  546. }
  547. }, this);
  548. },
  549. /**
  550. * 设置手指指示位置
  551. * @param {Number} x mask的x坐标
  552. * @param {Number} y mask的y坐标
  553. */
  554. setFingerPos (x, y, isReversal = false) {
  555. this.fingerNode.active = true;
  556. if (isReversal) {
  557. this.finger.rotation = -150;
  558. this.finger.x = -47;
  559. this.finger.y = 120;
  560. }
  561. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  562. this.fingerNode.x = x;
  563. this.fingerNode.y = y - this.fingerNode.height / 2;
  564. let offsetY = 20;
  565. let actionUp = cc.moveBy(0.5, 0, offsetY);
  566. let actionDown = cc.moveBy(0.5, 0, -offsetY);
  567. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  568. this.finger.runAction(seq);
  569. },
  570. //重设手指位置
  571. resetFingerPos (x, y) {
  572. if (this.isShowFinger) {
  573. this.fingerNode.active = true;
  574. }
  575. if (this.fingerNode.x == x && this.fingerNode.y == (y - this.fingerNode.height / 2)) {
  576. return;
  577. }
  578. this.fingerNode.x = x;
  579. this.fingerNode.y = y - this.fingerNode.height / 2;
  580. },
  581. resetFingerPosIsReversalUp (x, y, isReversalUp = false) {
  582. if (this.isShowFinger) {
  583. this.fingerNode.active = true;
  584. }
  585. if (this.fingerNode.x == x && this.fingerNode.y == (y - this.fingerNode.height / 2)) {
  586. return;
  587. }
  588. this.finger.stopAllActions();
  589. if (isReversalUp) {
  590. this.finger.rotation = -150;
  591. this.finger.x = -47;
  592. this.finger.y = 125;
  593. } else {
  594. this.finger.rotation = 0;
  595. this.finger.x = 0;
  596. this.finger.y = 0;
  597. }
  598. this.fingerNode.x = x;
  599. this.fingerNode.y = y - this.fingerNode.height / 2;
  600. let offsetY = 20;
  601. let actionUp = cc.moveBy(0.5, 0, offsetY);
  602. let actionDown = cc.moveBy(0.5, 0, -offsetY);
  603. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  604. this.finger.runAction(seq);
  605. },
  606. //隐藏指示点击手指,部分引导不需要
  607. hideFinger () {
  608. this.fingerNode.active = false;
  609. this.finger.stopAllActions();
  610. this.finger.x = 0;
  611. this.finger.y = 0;
  612. this.finger.rotation = 0;
  613. },
  614. //隐藏箭头,部分引导不需要
  615. hideArrow () {
  616. this.arrowNode.active = false;
  617. this.arrowNode.stopAllActions();
  618. },
  619. //
  620. hideBlock() {
  621. this.blockNode.active = false;
  622. this.touchNode.active = false;
  623. },
  624. /**
  625. * 显示遮罩层
  626. */
  627. showMask () {
  628. let target = this.guideState[this.curState];
  629. this.maskBg.active = !!target.mask;
  630. this.mask.active = true;
  631. this.mask.width = target.rect[0];
  632. this.mask.height = target.rect[1];
  633. this.mask.x = target.pos[0];
  634. this.mask.y = (1624 - this.vsize.height) / 2 + target.pos[1];
  635. },
  636. /**
  637. * 显示特殊不规则遮罩
  638. */
  639. showSpecialMask() {
  640. let target = this.guideState[this.curState];
  641. this.specialMaskBg.active = !!target.mask;
  642. this.specialMask.active = true;
  643. this.specialMask.width = target.rect[0];
  644. this.specialMask.height = target.rect[1];
  645. this.specialMask.x = target.pos[0];
  646. this.specialMask.y = (1624 - this.vsize.height) / 2 + target.pos[1];
  647. for(let i = 0; i < this.specialFrames.length; i++) {
  648. let spriteFrame = this.specialFrames[i];
  649. if (spriteFrame.name == target.special) {
  650. this.specialMask.getComponent(cc.Mask).spriteFrame = spriteFrame;
  651. break;
  652. }
  653. }
  654. },
  655. /**
  656. * 显示秘书人物内容
  657. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  658. * @param {Bool} 默认左边人物,默认为true
  659. */
  660. showSecretary (isLeft = true) {
  661. if (isLeft) {
  662. this.figureLeft.active = true;
  663. let action1 = cc.moveBy(0.4,cc.v2(550,0));
  664. let action2 = cc.moveBy(0.2,cc.v2(-100,0));
  665. this.figureLeft.runAction(cc.sequence(action1, action2));
  666. } else {
  667. this.figureRight.active = true;
  668. let action1 = cc.moveBy(0.4,cc.v2(-550,0));
  669. let action2 = cc.moveBy(0.2,cc.v2(100,0));
  670. this.figureRight.runAction(cc.sequence(action1, action2));
  671. }
  672. },
  673. /**
  674. * 显示箭头
  675. */
  676. showArrow(offsetY = 0) {
  677. let target = this.guideState[this.curState];
  678. this.arrowNode.active = true;
  679. let offset = 20;
  680. var actionUp = cc.moveBy(0.4, 0, offset);
  681. var actionDown = cc.moveBy(0.4, 0, -offset);
  682. if (target.arrowType == HomeGuideArrowType.Top) {
  683. this.arrowNode.rotation = 0;
  684. } else if (target.arrowType == HomeGuideArrowType.Right) {
  685. this.arrowNode.rotation = 90;
  686. var actionUp = cc.moveBy(0.4, offset, 0);
  687. var actionDown = cc.moveBy(0.4, -offset, 0);
  688. } else if (target.arrowType == HomeGuideArrowType.Bottom) {
  689. this.arrowNode.rotation = 180;
  690. } else {
  691. this.arrowNode.rotation = -90;
  692. var actionUp = cc.moveBy(0.4, offset, 0);
  693. var actionDown = cc.moveBy(0.4, -offset, 0);
  694. }
  695. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  696. this.arrowNode.x = target.arrowPos[0];
  697. this.arrowNode.y = target.arrowPos[1] + offsetY;
  698. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  699. this.arrowNode.runAction(seq);
  700. },
  701. /**
  702. * 显示对话框内容
  703. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  704. */
  705. showDialog () {
  706. let callback = cc.callFunc(() => {
  707. this.isPlaying = false;
  708. });
  709. this.isPlaying = true;
  710. let target = this.guideState[this.curState];
  711. var textNode = cc.find('/text', this.dialogTopLeft);
  712. if (target.dialogType == HomeGuideDialogType.TopLeft) {
  713. this.dialogTopLeft.active = true;
  714. textNode = cc.find('/text', this.dialogTopLeft);
  715. let action1 = cc.moveTo(0.4,100,this.dialogY);
  716. let action2 = cc.moveTo(0.2,0,this.dialogY);
  717. this.dialogTopLeft.runAction(cc.sequence(action1, action2, callback));
  718. } else if (target.dialogType == HomeGuideDialogType.TopRight) {
  719. this.dialogTopRight.active = true;
  720. textNode = cc.find('/text', this.dialogTopRight);
  721. let action1 = cc.moveTo(0.4,-100,this.dialogY);
  722. let action2 = cc.moveTo(0.2,0,this.dialogY);
  723. this.dialogTopRight.runAction(cc.sequence(action1, action2, callback));
  724. } else if (target.dialogType == HomeGuideDialogType.BottomLeft) {
  725. this.dialogBottomLeft.active = true;
  726. textNode = cc.find('/text', this.dialogBottomLeft);
  727. let action1 = cc.moveTo(0.4,100,this.bottomDialogY);
  728. let action2 = cc.moveTo(0.2,0,this.bottomDialogY);
  729. this.dialogBottomLeft.runAction(cc.sequence(action1, action2, callback));
  730. }
  731. textNode.getComponent(cc.Label).string = target.tips;
  732. },
  733. showTask() {
  734. let target = this.guideState[this.curState];
  735. this.taskNode.active = true;
  736. this.taskTitleLabel.string = target.taskTitle;
  737. if (this.curState == 'state7') {
  738. this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`;
  739. } else if (this.curState == 'state21') {
  740. let level = GameGlobal.BuildingManager.getRoomLevel(1);
  741. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  742. } else if (this.curState == 'state13' || this.curState == 'state15') {
  743. let currentLevel = GameModule.userInfo.buildingLevel;
  744. this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`;
  745. }
  746. },
  747. /**
  748. * 上报已过指引
  749. */
  750. updateGuideState() {
  751. if (this.guideState[this.curState] != undefined) {
  752. this.guideState[this.curState].pass = 1;
  753. let stateClone = Object.assign({}, this.guideState);
  754. // 显示引导之后立即上报同步对应state数据
  755. this.uploadUserState(stateClone);
  756. }
  757. },
  758. /**
  759. * 显示第一次玩游戏黑色引导
  760. */
  761. showBlackGuide() {
  762. this.tipsNode.stopAllActions();
  763. this.descNode.stopAllActions();
  764. this.blackGuideNode.active = true;
  765. this.tipsNode.opacity = 0;
  766. this.descNode.opacity = 0;
  767. let target = this.guideState[this.curState];
  768. this.tipsNode.getComponent(cc.Label).string = `${target.tips}`;
  769. let fadeIn = cc.fadeIn(1.2);
  770. this.tipsNode.runAction(fadeIn);
  771. let nextFadeIn = cc.fadeIn(1.2);
  772. let nextFadeOut = cc.fadeOut(1.2);
  773. let seq = cc.repeatForever(cc.sequence(nextFadeIn, nextFadeOut));
  774. this.descNode.runAction(seq);
  775. },
  776. //关闭开始游戏的黑色遮罩
  777. hideBlackGuide() {
  778. this.tipsNode.stopAllActions();
  779. this.descNode.stopAllActions();
  780. let finished = cc.callFunc(() => {
  781. this.nextBlackState();
  782. }, this);
  783. let fadeOut1 = cc.fadeOut(0.5);
  784. let fadeOut2 = cc.fadeOut(0.5);
  785. this.tipsNode.runAction(fadeOut1);
  786. var seq = cc.sequence(fadeOut2, finished);
  787. this.descNode.runAction(seq);
  788. },
  789. nextBlackState() {
  790. if (this.curState == 'state1') {
  791. this.handlePass(this.curState);
  792. this.handleState('state2');
  793. } else if (this.curState == 'state2') {
  794. this.handlePass(this.curState);
  795. this.handleState('state3');
  796. } else if (this.curState == 'state3') {
  797. this.handlePass(this.curState);
  798. this.handleState('state4');
  799. }
  800. },
  801. /**
  802. * 隐藏遮罩半透明层
  803. */
  804. hideMask () {
  805. this.mask.active = false;
  806. this.specialMask.active = false;
  807. },
  808. /**
  809. * 已完成某一State,并上报
  810. *
  811. */
  812. handlePass (state) {
  813. let stateClone = Object.assign({}, this.guideState);
  814. this.curState = null;
  815. this.handleEnd();
  816. },
  817. handleEnd () {
  818. this.node.active = false;
  819. this.taskNode.active = false;
  820. this.blockNode.active = true;
  821. this.touchNode.active = true;
  822. this.blackGuideNode.active = false;
  823. this.arrowNode.active = false;
  824. this.figureLeft.active = false;
  825. this.figureRight.active = false;
  826. this.figureLeft.x = -this.vsize.width + 50;
  827. this.figureRight.x = this.vsize.width - 50;
  828. this.dialogTopLeft.active = false;
  829. this.dialogTopRight.active = false;
  830. this.dialogBottomLeft.active = false;
  831. this.dialogTopLeft.x = -this.vsize.width;
  832. this.dialogTopRight.x = this.vsize.width;
  833. this.dialogBottomLeft.x = -this.vsize.width;
  834. this.hideMask ();
  835. this.hideFinger();
  836. this.hideArrow();
  837. },
  838. /**
  839. * 根据状态key显示对应引导内容
  840. * @param {String} state 当前状态key
  841. */
  842. handleState (state) {
  843. if(this.stateRecord[state] || this.curState != null) {
  844. return;
  845. } else {
  846. this.stateRecord[state] = true;
  847. }
  848. if(state && !this.guideState[state].pass) {
  849. if(this.guideState[state]) {
  850. this.node.active = true;
  851. this.curState = state;
  852. if (this.guideState[state].once) {
  853. this.guideState[state].pass = 1;
  854. let stateClone = Object.assign({}, this.guideState);
  855. // 显示引导之后立即上报同步对应state数据
  856. this.uploadUserState(stateClone);
  857. }
  858. } else {
  859. return
  860. }
  861. console.log("Show " + state);
  862. switch (state) {
  863. case 'state1': {
  864. this.showBlackGuide();
  865. break;
  866. }
  867. case 'state2' : {
  868. this.showBlackGuide();
  869. break;
  870. }
  871. case 'state3' : {
  872. this.showBlackGuide();
  873. break;
  874. }
  875. case 'state4' : {
  876. this.showMask();
  877. // 秘书人物
  878. this.showSecretary();
  879. // 对话框
  880. this.showDialog();
  881. break;
  882. }
  883. case 'state5' : {
  884. this.showMask();
  885. // 秘书人物
  886. this.showSecretary();
  887. // 对话框
  888. this.showDialog();
  889. break;
  890. }
  891. case 'state6' : {
  892. // 遮罩区域
  893. this.hideMask();
  894. //特殊遮罩区域
  895. this.showSpecialMask();
  896. // 秘书人物
  897. this.showSecretary();
  898. // 对话框
  899. this.showDialog();
  900. // 指示位置
  901. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 70, this.specialMask.y + 60);
  902. break;
  903. }
  904. case 'state7' : {
  905. this.hideBlock();
  906. this.hideMask();
  907. this.showTask();
  908. break;
  909. }
  910. case 'state8' : {
  911. this.showMask();
  912. // 秘书人物
  913. this.showSecretary();
  914. // 对话框
  915. this.showDialog();
  916. break;
  917. }
  918. case 'state9' : {
  919. this.showMask();
  920. // 秘书人物
  921. this.showSecretary();
  922. // 对话框
  923. this.showDialog();
  924. var offsetY = 0;
  925. if (this.vsize.height >= 1624) {
  926. offsetY = 130;
  927. } else if (this.vsize.height >= 1500) {
  928. offsetY = 90;
  929. }
  930. //显示箭头
  931. this.showArrow(offsetY);
  932. break;
  933. }
  934. case 'state10' : {
  935. this.showMask();
  936. // 秘书人物
  937. this.showSecretary();
  938. // 对话框
  939. this.showDialog();
  940. var offsetY = 0;
  941. if (this.vsize.height >= 1624) {
  942. offsetY = 130;
  943. } else if (this.vsize.height >= 1500) {
  944. offsetY = 90;
  945. }
  946. //显示箭头
  947. this.showArrow(offsetY);
  948. break;
  949. }
  950. case 'state11' : {
  951. this.hideMask();
  952. //特殊遮罩区域
  953. this.showSpecialMask();
  954. // 秘书人物
  955. this.showSecretary(false);
  956. // 对话框
  957. this.showDialog();
  958. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 10, this.specialMask.y, true);
  959. break;
  960. } case 'state12' : {
  961. this.showMask();
  962. // 秘书人物
  963. this.showSecretary(false);
  964. // 对话框
  965. this.showDialog();
  966. break;
  967. } case 'state13' : {
  968. this.hideBlock();
  969. this.hideMask();
  970. this.showTask();
  971. this._show13 = true;
  972. //显示箭头
  973. var offsetY = 0;
  974. if (this.vsize.height >= 1624) {
  975. offsetY = -140;
  976. } else if (this.vsize.height >= 1500) {
  977. offsetY = -90;
  978. }
  979. //显示箭头
  980. this.showArrow(offsetY);
  981. this.setFingerPos(10000, 0, true);
  982. break;
  983. } case 'state14' : {
  984. this.showMask();
  985. // 秘书人物
  986. this.showSecretary(false);
  987. // 对话框
  988. this.showDialog();
  989. break;
  990. } case 'state15' : {
  991. this.hideBlock();
  992. this.hideMask();
  993. this.showTask();
  994. this._show13 = true;
  995. //显示箭头
  996. var offsetY = 0;
  997. if (this.vsize.height >= 1624) {
  998. offsetY = -140;
  999. } else if (this.vsize.height >= 1500) {
  1000. offsetY = -90;
  1001. }
  1002. //显示箭头
  1003. this.showArrow(offsetY);
  1004. this.setFingerPos(10000, 0, true);
  1005. this.hideFinger();
  1006. break;
  1007. } case 'state16' : {
  1008. this.hideMask();
  1009. this.showSpecialMask();
  1010. this.taskNode.active = false;
  1011. //显示箭头
  1012. var offsetY = 0;
  1013. if (this.vsize.height >= 1624) {
  1014. offsetY = -140;
  1015. } else if (this.vsize.height >= 1500) {
  1016. offsetY = -90;
  1017. }
  1018. //显示箭头
  1019. this.showArrow(offsetY);
  1020. this.showSecretary(false);
  1021. this.showDialog();
  1022. // this.mask.setPosition(-278, 100 + offsetY);
  1023. break;
  1024. } case 'state17' : {
  1025. this.showMask();
  1026. this.mask.width = 0;
  1027. this.mask.height = 0;
  1028. this.hideArrow();
  1029. this.showSecretary(false);
  1030. this.showDialog();
  1031. break;
  1032. }
  1033. case 'state20' : {
  1034. // 遮罩区域
  1035. this.showMask();
  1036. // 秘书人物
  1037. this.showSecretary(false);
  1038. // 对话框
  1039. this.showDialog();
  1040. break;
  1041. }
  1042. case 'state21' : {
  1043. this.hideBlock();
  1044. this.hideMask();
  1045. this.showTask();
  1046. let target = this.guideState[this.curState];
  1047. // 指示位置
  1048. this.setFingerPos(target.pos[0] + 40, target.pos[1]);
  1049. break;
  1050. }
  1051. case 'state23' : {
  1052. this.showMask();
  1053. // 秘书人物
  1054. this.showSecretary(false);
  1055. // 对话框
  1056. this.showDialog();
  1057. break;
  1058. }
  1059. case 'state24' : {
  1060. this.hideBlock();
  1061. this.hideMask();
  1062. this.showTask();
  1063. let target = this.guideState[this.curState];
  1064. // 指示位置
  1065. this.setFingerPos(target.pos[0] + 40, target.pos[1]);
  1066. break;
  1067. }
  1068. case 'state26' : {
  1069. // this.showMask();
  1070. this.hideMask();
  1071. this.showSpecialMask();
  1072. // 秘书人物
  1073. this.showSecretary(false);
  1074. // 对话框
  1075. this.showDialog();
  1076. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 20, this.specialMask.y - 20);
  1077. break;
  1078. }
  1079. case 'state27' : {
  1080. this.showMask();
  1081. // 秘书人物
  1082. this.showSecretary();
  1083. // 对话框
  1084. this.showDialog();
  1085. break;
  1086. }
  1087. case 'state28' : {
  1088. this.hideMask();
  1089. //特殊遮罩区域
  1090. this.showSpecialMask();
  1091. // 秘书人物
  1092. this.showSecretary();
  1093. // 对话框
  1094. this.showDialog();
  1095. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 10, this.specialMask.y + 10, true);
  1096. break;
  1097. }
  1098. case 'state29' : {
  1099. this.hideMask();
  1100. this.hideBlock();
  1101. this.hideFinger();
  1102. //显示箭头
  1103. var offsetY = 0;
  1104. if (this.vsize.height >= 1624) {
  1105. offsetY = -140;
  1106. } else if (this.vsize.height >= 1500) {
  1107. offsetY = -80;
  1108. }
  1109. this.showArrow(offsetY);
  1110. this.figureLeft.active = false;
  1111. this.figureRight.active = false;
  1112. break;
  1113. }
  1114. case 'state31' : {
  1115. this.hideMask();
  1116. //特殊遮罩区域
  1117. this.showSpecialMask();
  1118. // 秘书人物
  1119. this.showSecretary();
  1120. // 对话框
  1121. this.showDialog();
  1122. if (this.vsize.height >= 1624) {
  1123. this.specialMask.y += 260;
  1124. } else if (this.vsize.height >= 1500) {
  1125. this.specialMask.y += 168;
  1126. }
  1127. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2, this.specialMask.y - 20);
  1128. break;
  1129. }
  1130. case 'state32' : {
  1131. this.showMask();
  1132. // 秘书人物
  1133. this.showSecretary();
  1134. // 对话框
  1135. this.showDialog();
  1136. break;
  1137. }
  1138. case 'state33' : {
  1139. this.hideBlock();
  1140. this.hideMask();
  1141. this.showArrow();
  1142. break;
  1143. }
  1144. case 'state34' : {
  1145. this.hideMask();
  1146. this.showSecretary();
  1147. this.showDialog();
  1148. break;
  1149. }
  1150. default:
  1151. break;
  1152. }
  1153. return true
  1154. } else {
  1155. // return false
  1156. }
  1157. },
  1158. /**
  1159. * 【特殊处理】关闭任务界面
  1160. */
  1161. handleGuideState33 () {
  1162. if (this.curState == 'state33') {
  1163. this.node.emit(`Fire_${this.curState}`);
  1164. this.handlePass(this.curState);
  1165. if (GameGlobal.isSignAward == false) {
  1166. this.handleState('state34');
  1167. }
  1168. }
  1169. },
  1170. /**
  1171. * 【特殊处理】判断当前引导结束后才执行下一个引导
  1172. */
  1173. handleGuideStateNext(current, next) {
  1174. if (this.guideState[current].pass) {
  1175. this.handleState(next);
  1176. }
  1177. },
  1178. isPassGuideState(state) {
  1179. if (this.guideState[state].pass) {
  1180. return true;
  1181. } else {
  1182. return false;
  1183. }
  1184. },
  1185. start () {
  1186. },
  1187. update() {
  1188. this.guideTask7();
  1189. this.guideTask13();
  1190. this.guideTask21();
  1191. this.guideTask24();
  1192. },
  1193. guideTask7() {
  1194. if (this.curState == 'state7') {
  1195. let target = this.guideState[this.curState];
  1196. let coditionGold = {'n': target.taskCodition, 'e': 0};
  1197. this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`;
  1198. if (TapTapTool.compare(GameModule.userInfo.gold, coditionGold)) {
  1199. this.finishState7();
  1200. }
  1201. }
  1202. },
  1203. guideTask13() {
  1204. if ((this.curState == 'state13' || this.curState == 'state15')) {
  1205. let currentLevel = GameModule.userInfo.buildingLevel;
  1206. let target = this.guideState[this.curState];
  1207. /// 小于它 说明还没有完成任务
  1208. if (currentLevel < target.taskCodition) {
  1209. this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`;
  1210. let upGold = {};
  1211. if (this._show13) {
  1212. let buildingObjct = buildingLevel.find((n) => {
  1213. return n.level == currentLevel;
  1214. })
  1215. upGold = {'n': parseInt(buildingObjct.upGold), 'e': 0};
  1216. } else {
  1217. let minIndex = currentLevel - 1;
  1218. let maxIndex = (minIndex + 5) > 24 ? 24 : (minIndex + 5);
  1219. let upGolds = 0;
  1220. for (let i = minIndex; i < maxIndex; ++ i) {
  1221. upGolds += parseInt(buildingLevel[i].upGold);
  1222. }
  1223. upGold = {'n': upGolds, 'e': 0};
  1224. }
  1225. //// 金币不够
  1226. if (!TapTapTool.compare(GameModule.userInfo.gold, upGold)) {
  1227. // 指示位置
  1228. this.arrowNode.active = false;
  1229. this.fingerNode.active = true;
  1230. if (this._show13 == false) {
  1231. this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 190, false);
  1232. } else {
  1233. this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 40, true);
  1234. }
  1235. } else {
  1236. if (this._show13 === false) {
  1237. this.fingerNode.active = true;
  1238. this.resetFingerPosIsReversalUp(- this.node.width / 2 + 150, - this.node.height / 2 + 40, true);
  1239. } else {
  1240. this.arrowNode.active = true;
  1241. this.fingerNode.active = false;
  1242. }
  1243. }
  1244. } else {
  1245. this.finishState13();
  1246. }
  1247. }
  1248. },
  1249. //// 特别针对技能的方法 只对13 15有效
  1250. changeGuideTask1315(isShow) {
  1251. if (this.curState == 'state13' || this.curState == 'state15') {
  1252. this.arrowNode.active = isShow;
  1253. this._show13 = isShow;
  1254. }
  1255. },
  1256. guideTask21() {
  1257. if (this.curState == 'state21') {
  1258. let target = this.guideState[this.curState];
  1259. let level = GameGlobal.BuildingManager.getRoomLevel(1);
  1260. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1261. let data = GameGlobal.BuildingManager.getBuildingInfo(1, level);
  1262. // 判断是否已经解锁
  1263. if (data.isUnlocked || level > 0) {
  1264. // 判断是否有足够的金额升级
  1265. if (TapTapTool.compare(GameModule.userInfo.gold, data.nextUpGold)) {
  1266. var offsetY = 0;
  1267. if (this.vsize.height >= 1624) {
  1268. offsetY = -160;
  1269. } else if (this.vsize.height >= 1500) {
  1270. offsetY = -90;
  1271. }
  1272. this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY);
  1273. } else {
  1274. var offsetY = 0;
  1275. if (this.vsize.height >= 1624) {
  1276. offsetY = -130;
  1277. } else if (this.vsize.height >= 1500) {
  1278. offsetY = -70;
  1279. }
  1280. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1281. }
  1282. } else {
  1283. // 判断是否有足够的金额解锁
  1284. if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) {
  1285. var offsetY = 0;
  1286. if (this.vsize.height >= 1624) {
  1287. offsetY = -160;
  1288. } else if (this.vsize.height >= 1500) {
  1289. offsetY = -70;
  1290. }
  1291. this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY);
  1292. } else {
  1293. var offsetY = 0;
  1294. if (this.vsize.height >= 1624) {
  1295. offsetY = -130;
  1296. } else if (this.vsize.height >= 1500) {
  1297. offsetY = -70;
  1298. }
  1299. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1300. }
  1301. }
  1302. if (level >= target.taskCodition) {
  1303. this.finishState21();
  1304. }
  1305. }
  1306. },
  1307. getLevelHomeGold(level) {
  1308. //判断当前楼层等级相减后是否大于25级
  1309. let maxLevel = (25 - level) > 5 ? (level + 5) : 25;
  1310. let buildingGold = {'n': 0, 'e': 0};
  1311. for (let i = level; i <= maxLevel; ++ i) {
  1312. let data = GameGlobal.BuildingManager.getBuildingInfo(1, level);
  1313. buildingGold = TapTapTool.add(buildingGold, data.nextUpGold);
  1314. }
  1315. return buildingGold;
  1316. },
  1317. guideTask24() {
  1318. if (this.curState == 'state24') {
  1319. let target = this.guideState[this.curState];
  1320. let level = GameGlobal.BuildingManager.getRoomLevel(1);
  1321. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1322. let data = GameGlobal.BuildingManager.getBuildingInfo(1, level);
  1323. // 判断是否已经解锁
  1324. if (data.isUnlocked || level > 0) {
  1325. //判断楼层是否可以连升5级
  1326. let upGold = this.getLevelHomeGold(level);
  1327. // 判断是否有足够的金额升级
  1328. if (TapTapTool.compare(GameModule.userInfo.gold, upGold)) {
  1329. var offsetY = 0;
  1330. if (this.vsize.height >= 1624) {
  1331. offsetY = -160;
  1332. } else if (this.vsize.height >= 1500) {
  1333. offsetY = -90;
  1334. }
  1335. this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY);
  1336. } else {
  1337. var offsetY = 0;
  1338. if (this.vsize.height >= 1624) {
  1339. offsetY = -130;
  1340. } else if (this.vsize.height >= 1500) {
  1341. offsetY = -70;
  1342. }
  1343. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1344. }
  1345. } else {
  1346. // 判断是否有足够的金额解锁
  1347. if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) {
  1348. var offsetY = 0;
  1349. if (this.vsize.height >= 1624) {
  1350. offsetY = -160;
  1351. } else if (this.vsize.height >= 1500) {
  1352. offsetY = -70;
  1353. }
  1354. this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY);
  1355. } else {
  1356. var offsetY = 0;
  1357. if (this.vsize.height >= 1624) {
  1358. offsetY = -130;
  1359. } else if (this.vsize.height >= 1500) {
  1360. offsetY = -70;
  1361. }
  1362. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1363. }
  1364. }
  1365. if (level >= target.taskCodition) {
  1366. this.finishState24();
  1367. }
  1368. }
  1369. },
  1370. // update (dt) {},
  1371. });