HomeGuide.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544
  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. onDestory() {
  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 = Global.userData.buildingLevel >= 25;
  417. let unLockStatus2 = Global.userData.buyStarCount > 0;
  418. if (unLockStatus1 && unLockStatus2) {
  419. for(let i = 1; i < 31; i++) {
  420. let state = `state${i}`;
  421. if (this.guideState[state] != undefined) {
  422. this.guideState[state].pass = 1;
  423. }
  424. }
  425. }
  426. // this.guideState.state16.pass = 0;
  427. },
  428. /**
  429. * 上报用户guideState
  430. * @param {Object} stateObj guideState对象
  431. */
  432. uploadUserState (stateObj) {
  433. // return;
  434. for(let i in stateObj) {
  435. stateObj[i] = stateObj[i].pass;
  436. }
  437. let stateStr = JSON.stringify(stateObj);
  438. // cc.sys.localStorage.setItem('guideState', stateStr)
  439. // 上报用户数据
  440. Api.httpPost({
  441. url: "/direct/add.do",
  442. data: {
  443. directJson: stateStr
  444. },
  445. success: res => {
  446. }
  447. })
  448. },
  449. initEvent() {
  450. this.blackGuideNode.on(cc.Node.EventType.TOUCH_END, () => {
  451. if (this.curState == 'state1') {
  452. this.hideBlackGuide();
  453. } else if (this.curState == 'state2') {
  454. this.hideBlackGuide();
  455. } else if (this.curState == 'state3') {
  456. this.hideBlackGuide();
  457. }
  458. });
  459. this.touchNode.on(cc.Node.EventType.TOUCH_END, () => {
  460. if (this.isPlaying) { return; }
  461. if (this.curState == 'state4') {
  462. this.handlePass(this.curState);
  463. this.handleState('state5');
  464. } else if (this.curState == 'state5') {
  465. this.node.emit(`Fire_${this.curState}`);
  466. this.handlePass(this.curState);
  467. this.handleState('state6');
  468. } else if (this.curState == 'state8') {
  469. this.handlePass(this.curState);
  470. this.handleState('state9');
  471. } else if (this.curState == 'state9') {
  472. this.handlePass(this.curState);
  473. this.handleState('state10');
  474. } else if (this.curState == 'state10') {
  475. this.handlePass(this.curState);
  476. this.handleState('state11');
  477. } else if (this.curState == 'state12') {
  478. this.handlePass(this.curState);
  479. this.handleState('state13');
  480. } else if (this.curState == 'state14') {
  481. this.handlePass(this.curState);
  482. this.handleState('state15');
  483. } else if (this.curState == 'state17') {
  484. this.node.emit(`Fire_${this.curState}`);
  485. this.handlePass(this.curState);
  486. this.handleState('state20');
  487. } else if (this.curState == 'state20') {
  488. this.handlePass(this.curState);
  489. this.handleState('state21');
  490. } else if (this.curState == 'state23') {
  491. this.handlePass(this.curState);
  492. this.handleState('state24');
  493. } else if (this.curState == 'state27') {
  494. this.handlePass(this.curState);
  495. this.handleState('state28');
  496. } else if (this.curState == 'state32') {
  497. this.node.emit(`Fire_${this.curState}`);
  498. this.handlePass(this.curState);
  499. this.handleState('state33');
  500. } else if (this.curState == 'state34') {
  501. this.handlePass(this.curState);
  502. }
  503. });
  504. //点击遮罩指定地方触发
  505. this.mask.on(cc.Node.EventType.TOUCH_END, () => {
  506. if (this.isPlaying) { return; }
  507. if(!!this.curState) {
  508. // 其他state的操作处理,触发在此节点上的自定义事件
  509. this.node.emit(`Fire_${this.curState}`);
  510. this.handlePass(this.curState);
  511. }
  512. }, this);
  513. //点击特殊遮罩指定地方触发
  514. this.specialMask.on(cc.Node.EventType.TOUCH_END, () => {
  515. if (this.isPlaying) { return; }
  516. if (this.curState == 'state6') {
  517. this.node.emit(`Fire_${this.curState}`);
  518. this.handlePass(this.curState);
  519. this.handleState('state7');
  520. } else if (this.curState == 'state16') {
  521. this.node.emit(`Fire_${this.curState}`);
  522. this.handlePass(this.curState);
  523. this.handleState('state17');
  524. } else if (this.curState == 'state26') {
  525. this.node.emit(`Fire_${this.curState}`);
  526. this.handlePass(this.curState);
  527. this.handleState('state27');
  528. } else if (this.curState == 'state31') {
  529. this.node.emit(`Fire_${this.curState}`);
  530. this.handlePass(this.curState);
  531. this.handleState('state32');
  532. } else if(!!this.curState) {
  533. // 其他state的操作处理,触发在此节点上的自定义事件
  534. this.node.emit(`Fire_${this.curState}`);
  535. this.handlePass(this.curState);
  536. }
  537. }, this);
  538. },
  539. /**
  540. * 设置手指指示位置
  541. * @param {Number} x mask的x坐标
  542. * @param {Number} y mask的y坐标
  543. */
  544. setFingerPos (x, y, isReversal = false) {
  545. this.fingerNode.active = true;
  546. if (isReversal) {
  547. this.finger.rotation = -150;
  548. this.finger.x = -47;
  549. this.finger.y = 120;
  550. }
  551. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  552. this.fingerNode.x = x;
  553. this.fingerNode.y = y - this.fingerNode.height / 2;
  554. let offsetY = 20;
  555. let actionUp = cc.moveBy(0.5, 0, offsetY);
  556. let actionDown = cc.moveBy(0.5, 0, -offsetY);
  557. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  558. this.finger.runAction(seq);
  559. },
  560. //重设手指位置
  561. resetFingerPos (x, y) {
  562. if (this.isShowFinger) {
  563. this.fingerNode.active = true;
  564. }
  565. if (this.fingerNode.x == x && this.fingerNode.y == (y - this.fingerNode.height / 2)) {
  566. return;
  567. }
  568. this.fingerNode.x = x;
  569. this.fingerNode.y = y - this.fingerNode.height / 2;
  570. },
  571. resetFingerPosIsReversalUp (x, y, isReversalUp = false) {
  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.finger.stopAllActions();
  579. if (isReversalUp) {
  580. this.finger.rotation = -150;
  581. this.finger.x = -47;
  582. this.finger.y = 125;
  583. } else {
  584. this.finger.rotation = 0;
  585. this.finger.x = 0;
  586. this.finger.y = 0;
  587. }
  588. this.fingerNode.x = x;
  589. this.fingerNode.y = y - this.fingerNode.height / 2;
  590. let offsetY = 20;
  591. let actionUp = cc.moveBy(0.5, 0, offsetY);
  592. let actionDown = cc.moveBy(0.5, 0, -offsetY);
  593. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  594. this.finger.runAction(seq);
  595. },
  596. //隐藏指示点击手指,部分引导不需要
  597. hideFinger () {
  598. this.fingerNode.active = false;
  599. this.finger.stopAllActions();
  600. this.finger.x = 0;
  601. this.finger.y = 0;
  602. this.finger.rotation = 0;
  603. },
  604. //隐藏箭头,部分引导不需要
  605. hideArrow () {
  606. this.arrowNode.active = false;
  607. this.arrowNode.stopAllActions();
  608. },
  609. //
  610. hideBlock() {
  611. this.blockNode.active = false;
  612. this.touchNode.active = false;
  613. },
  614. /**
  615. * 显示遮罩层
  616. */
  617. showMask () {
  618. let target = this.guideState[this.curState];
  619. this.maskBg.active = !!target.mask;
  620. this.mask.active = true;
  621. this.mask.width = target.rect[0];
  622. this.mask.height = target.rect[1];
  623. this.mask.x = target.pos[0];
  624. this.mask.y = (1624 - this.vsize.height) / 2 + target.pos[1];
  625. },
  626. /**
  627. * 显示特殊不规则遮罩
  628. */
  629. showSpecialMask() {
  630. let target = this.guideState[this.curState];
  631. this.specialMaskBg.active = !!target.mask;
  632. this.specialMask.active = true;
  633. this.specialMask.width = target.rect[0];
  634. this.specialMask.height = target.rect[1];
  635. this.specialMask.x = target.pos[0];
  636. this.specialMask.y = (1624 - this.vsize.height) / 2 + target.pos[1];
  637. for(let i = 0; i < this.specialFrames.length; i++) {
  638. let spriteFrame = this.specialFrames[i];
  639. if (spriteFrame.name == target.special) {
  640. this.specialMask.getComponent(cc.Mask).spriteFrame = spriteFrame;
  641. break;
  642. }
  643. }
  644. },
  645. /**
  646. * 显示秘书人物内容
  647. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  648. * @param {Bool} 默认左边人物,默认为true
  649. */
  650. showSecretary (isLeft = true) {
  651. if (isLeft) {
  652. this.figureLeft.active = true;
  653. let action1 = cc.moveBy(0.4,cc.v2(550,0));
  654. let action2 = cc.moveBy(0.2,cc.v2(-100,0));
  655. this.figureLeft.runAction(cc.sequence(action1, action2));
  656. } else {
  657. this.figureRight.active = true;
  658. let action1 = cc.moveBy(0.4,cc.v2(-550,0));
  659. let action2 = cc.moveBy(0.2,cc.v2(100,0));
  660. this.figureRight.runAction(cc.sequence(action1, action2));
  661. }
  662. },
  663. /**
  664. * 显示箭头
  665. */
  666. showArrow(offsetY = 0) {
  667. let target = this.guideState[this.curState];
  668. this.arrowNode.active = true;
  669. let offset = 20;
  670. var actionUp = cc.moveBy(0.4, 0, offset);
  671. var actionDown = cc.moveBy(0.4, 0, -offset);
  672. if (target.arrowType == HomeGuideArrowType.Top) {
  673. this.arrowNode.rotation = 0;
  674. } else if (target.arrowType == HomeGuideArrowType.Right) {
  675. this.arrowNode.rotation = 90;
  676. var actionUp = cc.moveBy(0.4, offset, 0);
  677. var actionDown = cc.moveBy(0.4, -offset, 0);
  678. } else if (target.arrowType == HomeGuideArrowType.Bottom) {
  679. this.arrowNode.rotation = 180;
  680. } else {
  681. this.arrowNode.rotation = -90;
  682. var actionUp = cc.moveBy(0.4, offset, 0);
  683. var actionDown = cc.moveBy(0.4, -offset, 0);
  684. }
  685. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  686. this.arrowNode.x = target.arrowPos[0];
  687. this.arrowNode.y = target.arrowPos[1] + offsetY;
  688. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown));
  689. this.arrowNode.runAction(seq);
  690. },
  691. /**
  692. * 显示对话框内容
  693. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  694. */
  695. showDialog () {
  696. let callback = cc.callFunc(() => {
  697. this.isPlaying = false;
  698. });
  699. this.isPlaying = true;
  700. let target = this.guideState[this.curState];
  701. var textNode = cc.find('/text', this.dialogTopLeft);
  702. if (target.dialogType == HomeGuideDialogType.TopLeft) {
  703. this.dialogTopLeft.active = true;
  704. textNode = cc.find('/text', this.dialogTopLeft);
  705. let action1 = cc.moveTo(0.4,100,this.dialogY);
  706. let action2 = cc.moveTo(0.2,0,this.dialogY);
  707. this.dialogTopLeft.runAction(cc.sequence(action1, action2, callback));
  708. } else if (target.dialogType == HomeGuideDialogType.TopRight) {
  709. this.dialogTopRight.active = true;
  710. textNode = cc.find('/text', this.dialogTopRight);
  711. let action1 = cc.moveTo(0.4,-100,this.dialogY);
  712. let action2 = cc.moveTo(0.2,0,this.dialogY);
  713. this.dialogTopRight.runAction(cc.sequence(action1, action2, callback));
  714. } else if (target.dialogType == HomeGuideDialogType.BottomLeft) {
  715. this.dialogBottomLeft.active = true;
  716. textNode = cc.find('/text', this.dialogBottomLeft);
  717. let action1 = cc.moveTo(0.4,100,this.bottomDialogY);
  718. let action2 = cc.moveTo(0.2,0,this.bottomDialogY);
  719. this.dialogBottomLeft.runAction(cc.sequence(action1, action2, callback));
  720. }
  721. textNode.getComponent(cc.Label).string = target.tips;
  722. },
  723. showTask() {
  724. let target = this.guideState[this.curState];
  725. this.taskNode.active = true;
  726. this.taskTitleLabel.string = target.taskTitle;
  727. if (this.curState == 'state7') {
  728. this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`;
  729. } else if (this.curState == 'state21') {
  730. let level = Global.BuildingManager.getRoomLevel(1);
  731. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  732. } else if (this.curState == 'state13' || this.curState == 'state15') {
  733. let currentLevel = GameModule.userInfo.buildingLevel;
  734. this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`;
  735. }
  736. },
  737. /**
  738. * 上报已过指引
  739. */
  740. updateGuideState() {
  741. if (this.guideState[this.curState] != undefined) {
  742. this.guideState[this.curState].pass = 1;
  743. let stateClone = Object.assign({}, this.guideState);
  744. // 显示引导之后立即上报同步对应state数据
  745. this.uploadUserState(stateClone);
  746. }
  747. },
  748. /**
  749. * 显示第一次玩游戏黑色引导
  750. */
  751. showBlackGuide() {
  752. this.tipsNode.stopAllActions();
  753. this.descNode.stopAllActions();
  754. this.blackGuideNode.active = true;
  755. this.tipsNode.opacity = 0;
  756. this.descNode.opacity = 0;
  757. let target = this.guideState[this.curState];
  758. this.tipsNode.getComponent(cc.Label).string = `${target.tips}`;
  759. let fadeIn = cc.fadeIn(1.2);
  760. this.tipsNode.runAction(fadeIn);
  761. let nextFadeIn = cc.fadeIn(1.2);
  762. let nextFadeOut = cc.fadeOut(1.2);
  763. let seq = cc.repeatForever(cc.sequence(nextFadeIn, nextFadeOut));
  764. this.descNode.runAction(seq);
  765. },
  766. //关闭开始游戏的黑色遮罩
  767. hideBlackGuide() {
  768. this.tipsNode.stopAllActions();
  769. this.descNode.stopAllActions();
  770. let finished = cc.callFunc(() => {
  771. this.nextBlackState();
  772. }, this);
  773. let fadeOut1 = cc.fadeOut(0.5);
  774. let fadeOut2 = cc.fadeOut(0.5);
  775. this.tipsNode.runAction(fadeOut1);
  776. var seq = cc.sequence(fadeOut2, finished);
  777. this.descNode.runAction(seq);
  778. },
  779. nextBlackState() {
  780. if (this.curState == 'state1') {
  781. this.handlePass(this.curState);
  782. this.handleState('state2');
  783. } else if (this.curState == 'state2') {
  784. this.handlePass(this.curState);
  785. this.handleState('state3');
  786. } else if (this.curState == 'state3') {
  787. this.handlePass(this.curState);
  788. this.handleState('state4');
  789. }
  790. },
  791. /**
  792. * 隐藏遮罩半透明层
  793. */
  794. hideMask () {
  795. this.mask.active = false;
  796. this.specialMask.active = false;
  797. },
  798. /**
  799. * 已完成某一State,并上报
  800. *
  801. */
  802. handlePass (state) {
  803. let stateClone = Object.assign({}, this.guideState);
  804. this.curState = null;
  805. this.handleEnd();
  806. },
  807. handleEnd () {
  808. this.node.active = false;
  809. this.taskNode.active = false;
  810. this.blockNode.active = true;
  811. this.touchNode.active = true;
  812. this.blackGuideNode.active = false;
  813. this.arrowNode.active = false;
  814. this.figureLeft.active = false;
  815. this.figureRight.active = false;
  816. this.figureLeft.x = -this.vsize.width + 50;
  817. this.figureRight.x = this.vsize.width - 50;
  818. this.dialogTopLeft.active = false;
  819. this.dialogTopRight.active = false;
  820. this.dialogBottomLeft.active = false;
  821. this.dialogTopLeft.x = -this.vsize.width;
  822. this.dialogTopRight.x = this.vsize.width;
  823. this.dialogBottomLeft.x = -this.vsize.width;
  824. this.hideMask ();
  825. this.hideFinger();
  826. this.hideArrow();
  827. },
  828. /**
  829. * 根据状态key显示对应引导内容
  830. * @param {String} state 当前状态key
  831. */
  832. handleState (state) {
  833. if(this.stateRecord[state] || this.curState != null) {
  834. return;
  835. } else {
  836. this.stateRecord[state] = true;
  837. }
  838. if(state && !this.guideState[state].pass) {
  839. if(this.guideState[state]) {
  840. this.node.active = true;
  841. this.curState = state;
  842. if (this.guideState[state].once) {
  843. this.guideState[state].pass = 1;
  844. let stateClone = Object.assign({}, this.guideState);
  845. // 显示引导之后立即上报同步对应state数据
  846. this.uploadUserState(stateClone);
  847. }
  848. } else {
  849. return
  850. }
  851. console.log("Show " + state);
  852. switch (state) {
  853. case 'state1': {
  854. this.showBlackGuide();
  855. break;
  856. }
  857. case 'state2' : {
  858. this.showBlackGuide();
  859. break;
  860. }
  861. case 'state3' : {
  862. this.showBlackGuide();
  863. break;
  864. }
  865. case 'state4' : {
  866. this.showMask();
  867. // 秘书人物
  868. this.showSecretary();
  869. // 对话框
  870. this.showDialog();
  871. break;
  872. }
  873. case 'state5' : {
  874. this.showMask();
  875. // 秘书人物
  876. this.showSecretary();
  877. // 对话框
  878. this.showDialog();
  879. break;
  880. }
  881. case 'state6' : {
  882. // 遮罩区域
  883. this.hideMask();
  884. //特殊遮罩区域
  885. this.showSpecialMask();
  886. // 秘书人物
  887. this.showSecretary();
  888. // 对话框
  889. this.showDialog();
  890. // 指示位置
  891. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 70, this.specialMask.y + 60);
  892. break;
  893. }
  894. case 'state7' : {
  895. this.hideBlock();
  896. this.hideMask();
  897. this.showTask();
  898. break;
  899. }
  900. case 'state8' : {
  901. this.showMask();
  902. // 秘书人物
  903. this.showSecretary();
  904. // 对话框
  905. this.showDialog();
  906. break;
  907. }
  908. case 'state9' : {
  909. this.showMask();
  910. // 秘书人物
  911. this.showSecretary();
  912. // 对话框
  913. this.showDialog();
  914. var offsetY = 0;
  915. if (this.vsize.height >= 1624) {
  916. offsetY = 130;
  917. } else if (this.vsize.height >= 1500) {
  918. offsetY = 90;
  919. }
  920. //显示箭头
  921. this.showArrow(offsetY);
  922. break;
  923. }
  924. case 'state10' : {
  925. this.showMask();
  926. // 秘书人物
  927. this.showSecretary();
  928. // 对话框
  929. this.showDialog();
  930. var offsetY = 0;
  931. if (this.vsize.height >= 1624) {
  932. offsetY = 130;
  933. } else if (this.vsize.height >= 1500) {
  934. offsetY = 90;
  935. }
  936. //显示箭头
  937. this.showArrow(offsetY);
  938. break;
  939. }
  940. case 'state11' : {
  941. this.hideMask();
  942. //特殊遮罩区域
  943. this.showSpecialMask();
  944. // 秘书人物
  945. this.showSecretary(false);
  946. // 对话框
  947. this.showDialog();
  948. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 10, this.specialMask.y, true);
  949. break;
  950. } case 'state12' : {
  951. this.showMask();
  952. // 秘书人物
  953. this.showSecretary(false);
  954. // 对话框
  955. this.showDialog();
  956. break;
  957. } case 'state13' : {
  958. this.hideBlock();
  959. this.hideMask();
  960. this.showTask();
  961. this._show13 = true;
  962. //显示箭头
  963. var offsetY = 0;
  964. if (this.vsize.height >= 1624) {
  965. offsetY = -140;
  966. } else if (this.vsize.height >= 1500) {
  967. offsetY = -90;
  968. }
  969. //显示箭头
  970. this.showArrow(offsetY);
  971. this.setFingerPos(10000, 0, true);
  972. break;
  973. } case 'state14' : {
  974. this.showMask();
  975. // 秘书人物
  976. this.showSecretary(false);
  977. // 对话框
  978. this.showDialog();
  979. break;
  980. } case 'state15' : {
  981. this.hideBlock();
  982. this.hideMask();
  983. this.showTask();
  984. this._show13 = true;
  985. //显示箭头
  986. var offsetY = 0;
  987. if (this.vsize.height >= 1624) {
  988. offsetY = -140;
  989. } else if (this.vsize.height >= 1500) {
  990. offsetY = -90;
  991. }
  992. //显示箭头
  993. this.showArrow(offsetY);
  994. this.setFingerPos(10000, 0, true);
  995. this.hideFinger();
  996. break;
  997. } case 'state16' : {
  998. this.hideMask();
  999. this.showSpecialMask();
  1000. this.taskNode.active = false;
  1001. //显示箭头
  1002. var offsetY = 0;
  1003. if (this.vsize.height >= 1624) {
  1004. offsetY = -140;
  1005. } else if (this.vsize.height >= 1500) {
  1006. offsetY = -90;
  1007. }
  1008. //显示箭头
  1009. this.showArrow(offsetY);
  1010. this.showSecretary(false);
  1011. this.showDialog();
  1012. // this.mask.setPosition(-278, 100 + offsetY);
  1013. break;
  1014. } case 'state17' : {
  1015. this.showMask();
  1016. this.mask.width = 0;
  1017. this.mask.height = 0;
  1018. this.hideArrow();
  1019. this.showSecretary(false);
  1020. this.showDialog();
  1021. break;
  1022. }
  1023. case 'state20' : {
  1024. // 遮罩区域
  1025. this.showMask();
  1026. // 秘书人物
  1027. this.showSecretary(false);
  1028. // 对话框
  1029. this.showDialog();
  1030. break;
  1031. }
  1032. case 'state21' : {
  1033. this.hideBlock();
  1034. this.hideMask();
  1035. this.showTask();
  1036. let target = this.guideState[this.curState];
  1037. // 指示位置
  1038. this.setFingerPos(target.pos[0] + 40, target.pos[1]);
  1039. break;
  1040. }
  1041. case 'state23' : {
  1042. this.showMask();
  1043. // 秘书人物
  1044. this.showSecretary(false);
  1045. // 对话框
  1046. this.showDialog();
  1047. break;
  1048. }
  1049. case 'state24' : {
  1050. this.hideBlock();
  1051. this.hideMask();
  1052. this.showTask();
  1053. let target = this.guideState[this.curState];
  1054. // 指示位置
  1055. this.setFingerPos(target.pos[0] + 40, target.pos[1]);
  1056. break;
  1057. }
  1058. case 'state26' : {
  1059. // this.showMask();
  1060. this.hideMask();
  1061. this.showSpecialMask();
  1062. // 秘书人物
  1063. this.showSecretary(false);
  1064. // 对话框
  1065. this.showDialog();
  1066. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 20, this.specialMask.y - 20);
  1067. break;
  1068. }
  1069. case 'state27' : {
  1070. this.showMask();
  1071. // 秘书人物
  1072. this.showSecretary();
  1073. // 对话框
  1074. this.showDialog();
  1075. break;
  1076. }
  1077. case 'state28' : {
  1078. this.hideMask();
  1079. //特殊遮罩区域
  1080. this.showSpecialMask();
  1081. // 秘书人物
  1082. this.showSecretary();
  1083. // 对话框
  1084. this.showDialog();
  1085. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 10, this.specialMask.y + 10, true);
  1086. break;
  1087. }
  1088. case 'state29' : {
  1089. this.hideMask();
  1090. this.hideBlock();
  1091. this.hideFinger();
  1092. //显示箭头
  1093. var offsetY = 0;
  1094. if (this.vsize.height >= 1624) {
  1095. offsetY = -140;
  1096. } else if (this.vsize.height >= 1500) {
  1097. offsetY = -80;
  1098. }
  1099. this.showArrow(offsetY);
  1100. this.figureLeft.active = false;
  1101. this.figureRight.active = false;
  1102. break;
  1103. }
  1104. case 'state31' : {
  1105. this.hideMask();
  1106. //特殊遮罩区域
  1107. this.showSpecialMask();
  1108. // 秘书人物
  1109. this.showSecretary();
  1110. // 对话框
  1111. this.showDialog();
  1112. if (this.vsize.height >= 1624) {
  1113. this.specialMask.y += 260;
  1114. } else if (this.vsize.height >= 1500) {
  1115. this.specialMask.y += 168;
  1116. }
  1117. this.setFingerPos(this.specialMask.x + this.specialMask.width / 2, this.specialMask.y - 20);
  1118. break;
  1119. }
  1120. case 'state32' : {
  1121. this.showMask();
  1122. // 秘书人物
  1123. this.showSecretary();
  1124. // 对话框
  1125. this.showDialog();
  1126. break;
  1127. }
  1128. case 'state33' : {
  1129. this.hideBlock();
  1130. this.hideMask();
  1131. this.showArrow();
  1132. break;
  1133. }
  1134. case 'state34' : {
  1135. this.hideMask();
  1136. this.showSecretary();
  1137. this.showDialog();
  1138. break;
  1139. }
  1140. default:
  1141. break;
  1142. }
  1143. return true
  1144. } else {
  1145. // return false
  1146. }
  1147. },
  1148. /**
  1149. * 【特殊处理】关闭任务界面
  1150. */
  1151. handleGuideState33 () {
  1152. if (this.curState == 'state33') {
  1153. this.node.emit(`Fire_${this.curState}`);
  1154. this.handlePass(this.curState);
  1155. if (Global.isSignAward == false) {
  1156. this.handleState('state34');
  1157. }
  1158. }
  1159. },
  1160. /**
  1161. * 【特殊处理】判断当前引导结束后才执行下一个引导
  1162. */
  1163. handleGuideStateNext(current, next) {
  1164. if (this.guideState[current].pass) {
  1165. this.handleState(next);
  1166. }
  1167. },
  1168. isPassGuideState(state) {
  1169. if (this.guideState[state].pass) {
  1170. return true;
  1171. } else {
  1172. return false;
  1173. }
  1174. },
  1175. start () {
  1176. },
  1177. update() {
  1178. this.guideTask7();
  1179. this.guideTask13();
  1180. this.guideTask21();
  1181. this.guideTask24();
  1182. },
  1183. guideTask7() {
  1184. if (this.curState == 'state7') {
  1185. let target = this.guideState[this.curState];
  1186. let coditionGold = {'n': target.taskCodition, 'e': 0};
  1187. this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`;
  1188. if (TapTapTool.compare(GameModule.userInfo.gold, coditionGold)) {
  1189. this.finishState7();
  1190. }
  1191. }
  1192. },
  1193. guideTask13() {
  1194. if ((this.curState == 'state13' || this.curState == 'state15')) {
  1195. let currentLevel = GameModule.userInfo.buildingLevel;
  1196. let target = this.guideState[this.curState];
  1197. /// 小于它 说明还没有完成任务
  1198. if (currentLevel < target.taskCodition) {
  1199. this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`;
  1200. let upGold = {};
  1201. if (this._show13) {
  1202. let buildingObjct = buildingLevel.find((n) => {
  1203. return n.level == currentLevel;
  1204. })
  1205. upGold = {'n': parseInt(buildingObjct.upGold), 'e': 0};
  1206. } else {
  1207. let minIndex = currentLevel - 1;
  1208. let maxIndex = (minIndex + 5) > 24 ? 24 : (minIndex + 5);
  1209. let upGolds = 0;
  1210. for (let i = minIndex; i < maxIndex; ++ i) {
  1211. upGolds += parseInt(buildingLevel[i].upGold);
  1212. }
  1213. upGold = {'n': upGolds, 'e': 0};
  1214. }
  1215. //// 金币不够
  1216. if (!TapTapTool.compare(GameModule.userInfo.gold, upGold)) {
  1217. // 指示位置
  1218. this.arrowNode.active = false;
  1219. this.fingerNode.active = true;
  1220. if (this._show13 == false) {
  1221. this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 190, false);
  1222. } else {
  1223. this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 40, true);
  1224. }
  1225. } else {
  1226. if (this._show13 === false) {
  1227. this.fingerNode.active = true;
  1228. this.resetFingerPosIsReversalUp(- this.node.width / 2 + 150, - this.node.height / 2 + 40, true);
  1229. } else {
  1230. this.arrowNode.active = true;
  1231. this.fingerNode.active = false;
  1232. }
  1233. }
  1234. } else {
  1235. this.finishState13();
  1236. }
  1237. }
  1238. },
  1239. //// 特别针对技能的方法 只对13 15有效
  1240. changeGuideTask1315(isShow) {
  1241. if (this.curState == 'state13' || this.curState == 'state15') {
  1242. this.arrowNode.active = isShow;
  1243. this._show13 = isShow;
  1244. }
  1245. },
  1246. guideTask21() {
  1247. if (this.curState == 'state21') {
  1248. let target = this.guideState[this.curState];
  1249. let level = Global.BuildingManager.getRoomLevel(1);
  1250. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1251. let data = Global.BuildingManager.getBuildingInfo(1, level);
  1252. // 判断是否已经解锁
  1253. if (data.isUnlocked || level > 0) {
  1254. // 判断是否有足够的金额升级
  1255. if (TapTapTool.compare(GameModule.userInfo.gold, data.nextUpGold)) {
  1256. var offsetY = 0;
  1257. if (this.vsize.height >= 1624) {
  1258. offsetY = -160;
  1259. } else if (this.vsize.height >= 1500) {
  1260. offsetY = -90;
  1261. }
  1262. this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY);
  1263. } else {
  1264. var offsetY = 0;
  1265. if (this.vsize.height >= 1624) {
  1266. offsetY = -130;
  1267. } else if (this.vsize.height >= 1500) {
  1268. offsetY = -70;
  1269. }
  1270. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1271. }
  1272. } else {
  1273. // 判断是否有足够的金额解锁
  1274. if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) {
  1275. var offsetY = 0;
  1276. if (this.vsize.height >= 1624) {
  1277. offsetY = -160;
  1278. } else if (this.vsize.height >= 1500) {
  1279. offsetY = -70;
  1280. }
  1281. this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY);
  1282. } else {
  1283. var offsetY = 0;
  1284. if (this.vsize.height >= 1624) {
  1285. offsetY = -130;
  1286. } else if (this.vsize.height >= 1500) {
  1287. offsetY = -70;
  1288. }
  1289. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1290. }
  1291. }
  1292. if (level >= target.taskCodition) {
  1293. this.finishState21();
  1294. }
  1295. }
  1296. },
  1297. guideTask24() {
  1298. if (this.curState == 'state24') {
  1299. let target = this.guideState[this.curState];
  1300. let level = Global.BuildingManager.getRoomLevel(1);
  1301. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1302. let data = Global.BuildingManager.getBuildingInfo(1, level);
  1303. // 判断是否已经解锁
  1304. if (data.isUnlocked || level > 0) {
  1305. // 判断是否有足够的金额升级
  1306. if (TapTapTool.compare(GameModule.userInfo.gold, data.nextUpGold)) {
  1307. var offsetY = 0;
  1308. if (this.vsize.height >= 1624) {
  1309. offsetY = -160;
  1310. } else if (this.vsize.height >= 1500) {
  1311. offsetY = -90;
  1312. }
  1313. this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY);
  1314. } else {
  1315. var offsetY = 0;
  1316. if (this.vsize.height >= 1624) {
  1317. offsetY = -130;
  1318. } else if (this.vsize.height >= 1500) {
  1319. offsetY = -70;
  1320. }
  1321. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1322. }
  1323. } else {
  1324. // 判断是否有足够的金额解锁
  1325. if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) {
  1326. var offsetY = 0;
  1327. if (this.vsize.height >= 1624) {
  1328. offsetY = -160;
  1329. } else if (this.vsize.height >= 1500) {
  1330. offsetY = -70;
  1331. }
  1332. this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY);
  1333. } else {
  1334. var offsetY = 0;
  1335. if (this.vsize.height >= 1624) {
  1336. offsetY = -130;
  1337. } else if (this.vsize.height >= 1500) {
  1338. offsetY = -70;
  1339. }
  1340. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1341. }
  1342. }
  1343. if (level >= target.taskCodition) {
  1344. this.finishState24();
  1345. }
  1346. }
  1347. },
  1348. // update (dt) {},
  1349. });