HomeGuide.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  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. if (Global.debug) {
  327. for(let i = 0; i < 35; i++) {
  328. let state = `state${i}`;
  329. if (this.guideState[state] != undefined) {
  330. this.guideState[state].pass = 1;
  331. }
  332. }
  333. }
  334. let self = this;
  335. this.finishState7 = _.debounce(() => {
  336. self.updateGuideState();
  337. self.handlePass(this.curState);
  338. self.handleState('state8');
  339. }, 1000, true);
  340. this.finishState13 = _.debounce(() => {
  341. let state = this.curState;
  342. self.updateGuideState();
  343. self.handlePass(this.curState);
  344. if (state === 'state13') {
  345. self.handleState('state14');
  346. } else {
  347. self.handleState('state16');
  348. }
  349. }, 1000, true);
  350. this.finishState21 = _.debounce(() => {
  351. self.updateGuideState();
  352. self.handlePass(this.curState);
  353. self.handleState('state23');
  354. }, 1000, true);
  355. this.finishState24 = _.debounce(() => {
  356. // this.node.emit(`Fire_${this.curState}`);
  357. self.updateGuideState();
  358. self.handlePass(this.curState);
  359. }, 1000, true);
  360. },
  361. setupUI() {
  362. let secretaryY = this.figureLeft.height / 2 - this.vsize.height / 2 + 20;
  363. this.figureLeft.y = secretaryY;
  364. this.figureRight.y = secretaryY;
  365. this.dialogY = this.dialogTopLeft.height / 2 - this.vsize.height / 2 + 270;
  366. this.dialogTopLeft.y = this.dialogY;
  367. this.dialogTopRight.y = this.dialogY;
  368. this.bottomDialogY = (344 - this.vsize.height) / 2;
  369. this.dialogBottomLeft.y = this.bottomDialogY;
  370. if (this.vsize.height >= 1624) {
  371. this.taskNode.y += 120;
  372. } else if (this.vsize.height >= 1500) {
  373. this.taskNode.y += 80;
  374. }
  375. },
  376. tabbarHideCat() {
  377. this.fingerNode.active = false;
  378. this.isShowFinger = false;
  379. },
  380. tabbarShowCat() {
  381. this.isShowFinger = true;
  382. },
  383. onDestroy() {
  384. },
  385. /**F
  386. * 同步用户guideState
  387. */
  388. syncStatePass () {
  389. let _guideState = window.guideState;
  390. // let _guideState = cc.sys.localStorage.getItem('guideState');
  391. if(!!_guideState) {
  392. for(let i in _guideState) {
  393. if(this.guideState[i]) {
  394. this.guideState[i].pass = _guideState[i];
  395. }
  396. }
  397. } else {
  398. let _guideState = Object.assign({}, this.guideState);
  399. this.uploadUserState(_guideState);
  400. }
  401. },
  402. setupAllFinished() {
  403. // 判断满足以下条件时为已完成购买明星前的教程:
  404. // 1. 总部大楼大于25级
  405. // 2. 已拥有1个明星
  406. // 3. 是否已签到过
  407. let unLockStatus1 = Global.userData.buildingLevel >= 25;
  408. let unLockStatus2 = Global.userData.buyStarCount > 0;
  409. let unLockStatus3 = Global.signCount > 0;
  410. if (unLockStatus1 && unLockStatus2) {
  411. if (unLockStatus3) {
  412. for(let i = 1; i < 35; i++) {
  413. let state = `state${i}`;
  414. if (this.guideState[state] != undefined) {
  415. this.guideState[state].pass = 1;
  416. }
  417. }
  418. } else {
  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. }
  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. getLevelHomeGold(level) {
  1298. //判断当前楼层等级相减后是否大于25级
  1299. let maxLevel = (25 - level) > 5 ? (level + 5) : 25;
  1300. let buildingGold = {'n': 0, 'e': 0};
  1301. for (let i = level; i <= maxLevel; ++ i) {
  1302. let data = Global.BuildingManager.getBuildingInfo(1, level);
  1303. buildingGold = TapTapTool.add(buildingGold, data.nextUpGold);
  1304. }
  1305. return buildingGold;
  1306. },
  1307. guideTask24() {
  1308. if (this.curState == 'state24') {
  1309. let target = this.guideState[this.curState];
  1310. let level = Global.BuildingManager.getRoomLevel(1);
  1311. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1312. let data = Global.BuildingManager.getBuildingInfo(1, level);
  1313. // 判断是否已经解锁
  1314. if (data.isUnlocked || level > 0) {
  1315. //判断楼层是否可以连升5级
  1316. let upGold = this.getLevelHomeGold(level);
  1317. // 判断是否有足够的金额升级
  1318. if (TapTapTool.compare(GameModule.userInfo.gold, upGold)) {
  1319. var offsetY = 0;
  1320. if (this.vsize.height >= 1624) {
  1321. offsetY = -160;
  1322. } else if (this.vsize.height >= 1500) {
  1323. offsetY = -90;
  1324. }
  1325. this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY);
  1326. } else {
  1327. var offsetY = 0;
  1328. if (this.vsize.height >= 1624) {
  1329. offsetY = -130;
  1330. } else if (this.vsize.height >= 1500) {
  1331. offsetY = -70;
  1332. }
  1333. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1334. }
  1335. } else {
  1336. // 判断是否有足够的金额解锁
  1337. if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) {
  1338. var offsetY = 0;
  1339. if (this.vsize.height >= 1624) {
  1340. offsetY = -160;
  1341. } else if (this.vsize.height >= 1500) {
  1342. offsetY = -70;
  1343. }
  1344. this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY);
  1345. } else {
  1346. var offsetY = 0;
  1347. if (this.vsize.height >= 1624) {
  1348. offsetY = -130;
  1349. } else if (this.vsize.height >= 1500) {
  1350. offsetY = -70;
  1351. }
  1352. this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY);
  1353. }
  1354. }
  1355. if (level >= target.taskCodition) {
  1356. this.finishState24();
  1357. }
  1358. }
  1359. },
  1360. // update (dt) {},
  1361. });