HomeGuide.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557
  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. let unLockStatus1 = GameGlobal.userData.buildingLevel >= 25;
  407. let unLockStatus2 = GameGlobal.userData.buyStarCount > 0;
  408. // 3. 是否已签到过
  409. let unLockStatus3 = GameGlobal.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 = GameGlobal.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 (GameGlobal.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 = GameGlobal.BuildingManager.getRoomLevel(1);
  1250. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1251. let data = GameGlobal.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 = GameGlobal.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 = GameGlobal.BuildingManager.getRoomLevel(1);
  1311. this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
  1312. let data = GameGlobal.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. });