HomeGuide.js 51 KB

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