HomeGuide.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. const Api = require('../net/Api');
  2. const { GameNotificationKey } = require("../utils/GameEnum");
  3. const GameModule = require("../utils/GameModule");
  4. const AlertManager = require("../utils/AlertManager");
  5. cc.Class({
  6. extends: cc.Component,
  7. properties: {
  8. guideText: cc.Label,
  9. dialog: cc.Node,
  10. finger: cc.Node,
  11. secretary: cc.Node,
  12. mask: cc.Node,
  13. maskBg: cc.Node,
  14. blockEvent: cc.Node
  15. },
  16. onLoad () {
  17. },
  18. init (game) {
  19. this.game = game
  20. this.homeSV = this.game.levelHome.scrollView // levelHome的scrollView组件
  21. this.vsize = cc.view.getVisibleSize()
  22. this.initEvent()
  23. this.stateRecord = {} //
  24. // AlertManager.showArtistOperationAlert()
  25. this.guideState = {
  26. state1 : {
  27. tips: '点击可以解锁房间噢!',
  28. pass: 0,
  29. mask: 1,
  30. rect: [328, 128],
  31. pos: [0, 10]
  32. },
  33. state2 : {
  34. tips: '点击可以收取金币~',
  35. pass: 0,
  36. mask: 1,
  37. rect: [60, 60],
  38. pos: [-140, -55]
  39. },
  40. state3 : {
  41. tips: '升级房间可以产出更多金币~',
  42. pass: 0,
  43. mask: 1,
  44. rect: [188, 72],
  45. pos: [207, -130]
  46. },
  47. state4 : {
  48. tips: '让我们开启更多的房间',
  49. pass: 0,
  50. mask: 1,
  51. rect: [328, 128],
  52. pos: [0, 0]
  53. },
  54. state5 : {
  55. tips: '涉猎更多的行业,为签约艺人做好准备~',
  56. pass: 0,
  57. mask: 1,
  58. rect: [328, 128],
  59. pos: [0, 0]
  60. },
  61. state6 : {
  62. tips: '看~我们已经解锁好友了~签约你的好友成为你的艺人,一起发展公司!',
  63. pass: 0,
  64. mask: 1,
  65. rect: [130, 130],
  66. pos: [-305, -720]
  67. },
  68. state7 : {
  69. tips: '派出你的星探签约好友~让Ta成为你的旗下艺人',
  70. pass: 0,
  71. mask: 1,
  72. rect: [240, 80],
  73. pos: [-168, -735]
  74. },
  75. state12 : {
  76. tips: '艺人不够怎么办?\n除了派出星探,还可以抢人~',
  77. pass: 0,
  78. mask: 1,
  79. rect: [0, 0],
  80. pos: [0, 0]
  81. },
  82. state13 : {
  83. tips: '点击全部好友',
  84. pass: 0,
  85. mask: 1,
  86. rect: [130, 130],
  87. pos: [-305, -720]
  88. },
  89. state14 : {
  90. tips: '艺人不够怎么办?\n点击这里抢夺的艺人',
  91. pass: 0,
  92. mask: 1,
  93. rect: [700, 190],
  94. pos: [0, 137]
  95. },
  96. state15 : {
  97. tips: '点击这里的抢夺',
  98. pass: 0,
  99. mask: 1,
  100. rect: [182, 72],
  101. pos: [-273, -368]
  102. },
  103. state16 : {
  104. tips: '点击确定就可以抢夺啦\n注意~抢夺有几率失败的噢',
  105. pass: 0,
  106. mask: 1,
  107. rect: [236, 80],
  108. pos: [132, -275]
  109. },
  110. state17 : {
  111. tips: '我们的艺人已经准备好啦\n让我们来把艺人入驻到房间内开始工作',
  112. pass: 0,
  113. mask: 1,
  114. rect: [0, 0],
  115. pos: [0, 0]
  116. },
  117. state18 : {
  118. tips: '点击房间旁的添加按钮',
  119. pass: 0,
  120. mask: 1,
  121. rect: [70, 70],
  122. pos: [-328, 42]
  123. },
  124. state19 : {
  125. tips: '选择这名艺人',
  126. pass: 0,
  127. mask: 1,
  128. rect: [640, 190],
  129. pos: [0, 100]
  130. },
  131. state20 : {
  132. tips: '点击确定就好啦~',
  133. pass: 0,
  134. mask: 1,
  135. rect: [240, 80],
  136. pos: [0, -740]
  137. },
  138. state21 : {
  139. tips: '看~这样就入驻好啦,\n艺人会帮你赚更多的钱\n有新的艺人不要忘记入驻哦',
  140. pass: 0,
  141. mask: 1,
  142. rect: [0, 0],
  143. pos: [0, 0]
  144. },
  145. state25 : {
  146. tips: '点击安抚',
  147. pass: 0,
  148. mask: 1,
  149. rect: [102, 87],
  150. pos: [-285, 15]
  151. },
  152. state26 : {
  153. tips: '选择互动事件',
  154. pass: 0,
  155. mask: 1,
  156. rect: [430, 80],
  157. pos: [0, -5]
  158. },
  159. state27 : {
  160. tips: '提醒你的好友一起互动\n可以获得更多的亲密度噢~',
  161. pass: 0,
  162. mask: 1,
  163. rect: [236, 80],
  164. pos: [0, -300]
  165. },
  166. state28 : {
  167. tips: '培养可以提高艺人的等级\n赚取更多的金币噢~',
  168. pass: 0,
  169. mask: 1,
  170. rect: [182, 72],
  171. pos: [273, -368]
  172. },
  173. state29 : {
  174. tips: '选择一个培养任务开始培养',
  175. pass: 0,
  176. mask: 1,
  177. rect: [176, 56],
  178. pos: [217, 147]
  179. },
  180. state30 : {
  181. tips: '很好,培养倒计时结束后记得来完成任务',
  182. pass: 0,
  183. mask: 1,
  184. rect: [720, 880],
  185. pos: [0, -142]
  186. },
  187. state31 : {
  188. tips: '守护可以保护自己的艺人\n不被他人抢走',
  189. pass: 0,
  190. mask: 1,
  191. rect: [102, 76],
  192. pos: [-290, -180]
  193. },
  194. state32 : {
  195. tips: '选择空的槽位',
  196. pass: 0,
  197. mask: 1,
  198. rect: [184, 244],
  199. pos: [-208, -110]
  200. },
  201. state33 : {
  202. tips: '将这张谈心卡装备上去吧~',
  203. pass: 0,
  204. mask: 1,
  205. rect: [136, 136],
  206. pos: [-225, 102]
  207. },
  208. state34 : {
  209. tips: '想要重点守护的艺人\n记得把槽位装满噢~',
  210. pass: 0,
  211. mask: 1,
  212. rect: [720, 542],
  213. pos: [0, -119]
  214. },
  215. state35 : {
  216. tips: '看~有别的艺人入驻我们的公司了,赶走他,抢掉Ta的收益~',
  217. pass: 0,
  218. mask: 1,
  219. rect: [0, 0],
  220. pos: [0, 0]
  221. },
  222. state36 : {
  223. tips: '抢走Ta的收益,这可是好大一笔钱呢!',
  224. pass: 0,
  225. mask: 1,
  226. rect: [240, 85],
  227. pos: [0, (this.vsize.height - 1624) / 2 - 115]
  228. },
  229. state37 : {
  230. tips: '点击装备',
  231. pass: 0,
  232. mask: 1,
  233. rect: [180, 54],
  234. pos: [-227, 250]
  235. },
  236. }
  237. this.syncStatePass()
  238. this.game.updateUIState(this.guideState)
  239. // For Test: state4
  240. // this.handleState('state35')
  241. },
  242. /**
  243. * 同步用户guideState
  244. */
  245. syncStatePass () {
  246. let _guideState = window.guideState
  247. // let _guideState = cc.sys.localStorage.getItem('guideState');
  248. if(!!_guideState) {
  249. for(let i in _guideState) {
  250. if(this.guideState[i]) {
  251. this.guideState[i].pass = _guideState[i]
  252. }
  253. }
  254. } else {
  255. let _guideState = Object.assign({}, this.guideState)
  256. this.uploadUserState(_guideState)
  257. }
  258. },
  259. /**
  260. * 上报用户guideState
  261. * @param {Object} stateObj guideState对象
  262. */
  263. uploadUserState (stateObj) {
  264. for(let i in stateObj) {
  265. stateObj[i] = stateObj[i].pass
  266. }
  267. let stateStr = JSON.stringify(stateObj)
  268. // cc.sys.localStorage.setItem('guideState', stateStr)
  269. // 上报用户数据
  270. Api.httpPost({
  271. url: "/direct/add.do",
  272. data: {
  273. directJson: stateStr
  274. },
  275. success: res => {
  276. }
  277. })
  278. },
  279. initEvent() {
  280. this.mask.on(cc.Node.EventType.TOUCH_END, () => {
  281. this.homeSV.vertical = true
  282. if(this.curState == 'state6') {
  283. // state6 结束后直接跳到 state7
  284. this.handlePass(this.curState)
  285. this.handleState('state7')
  286. } else if(this.curState == 'state7') {
  287. this.handlePass(this.curState)
  288. // state7 点击后显示邀请好友弹窗
  289. this.game.friendSystem.inviteFriend()
  290. } else if(this.curState == 'state13') {
  291. // state13 结束后直接跳到 state14
  292. this.handlePass(this.curState)
  293. setTimeout(() => {
  294. this.handleState('state14')
  295. }, 300)
  296. } else if(this.curState == 'state14') {
  297. // 跳转userinfo界面
  298. let tab = GameModule.tab.getComponent('Tab')
  299. if(tab.friends && tab.friends.length > 0) {
  300. let uid = tab.friends[0].uid
  301. this.game.gameFSM.showuserinfo(uid)
  302. }
  303. this.handlePass(this.curState)
  304. } else if(this.curState == 'state18') {
  305. this.handleGuideState18()
  306. this.handlePass(this.curState)
  307. setTimeout(() => {
  308. this.handleState('state19')
  309. }, 300)
  310. } else if(this.curState == 'state19') {
  311. let cnode = cc.find('Canvas/artist_resident')
  312. cnode = cnode.getComponent('ArtistResident')
  313. cnode.guide()
  314. this.curState = null
  315. this.handleState('state20')
  316. } else if(this.curState == 'state20') {
  317. let cnode = cc.find('Canvas/artist_resident')
  318. cnode = cnode.getComponent('ArtistResident')
  319. cnode.confirm()
  320. this.curState = null
  321. this.handleState('state21')
  322. } else if(!!this.curState) {
  323. // 其他state的操作处理,触发在此节点上的自定义事件
  324. this.node.emit(`Fire_${this.curState}`)
  325. this.handlePass(this.curState)
  326. }
  327. }, this)
  328. },
  329. /**
  330. * 设置手指指示位置
  331. * @param {Number} x mask的x坐标
  332. * @param {Number} y mask的y坐标
  333. */
  334. setFingerPos (x, y) {
  335. this.finger.active = true;
  336. let offsetY = 20
  337. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  338. this.finger.x = x
  339. this.finger.y = y - this.finger.height / 2
  340. let actionUp = cc.moveBy(0.5, 0, offsetY)
  341. let actionDown = cc.moveBy(0.5, 0, -offsetY)
  342. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown))
  343. this.finger.runAction(seq)
  344. },
  345. //隐藏指示点击手指,部分引导不需要
  346. hideFinger () {
  347. this.finger.active = false;
  348. this.finger.stopAllActions();
  349. },
  350. /**
  351. * 显示遮罩层
  352. */
  353. showMask () {
  354. let target = this.guideState[this.curState]
  355. this.maskBg.active = !!target.mask
  356. this.mask.active = true
  357. this.mask.width = target.rect[0]
  358. this.mask.height = target.rect[1]
  359. this.mask.x = target.pos[0]
  360. this.mask.y = (1624 - this.vsize.height) / 2 + target.pos[1]
  361. },
  362. /**
  363. * levelhome 的 scrollView 组件滚动到底部
  364. * 某些任务状态下必须 [state1, state2, state3]
  365. */
  366. scrollToBottom () {
  367. this.homeSV.scrollToBottom(0)
  368. },
  369. /**
  370. * 显示秘书人物内容
  371. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  372. */
  373. showSecretary (offsetY = 0) {
  374. let targetX = this.secretary.width / 2 - this.vsize.width / 2
  375. let secretaryY = this.secretary.height / 2 - this.vsize.height / 2 + offsetY
  376. this.secretary.x = -this.vsize.width
  377. this.secretary.y = secretaryY
  378. this.secretary.active = true
  379. let action1 = cc.moveTo(0.4, targetX, secretaryY)
  380. this.secretary.runAction(action1)
  381. },
  382. /**
  383. * 显示对话框内容
  384. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  385. */
  386. showDialog (offsetY = 0) {
  387. let target = this.guideState[this.curState]
  388. let targetX = this.secretary.width / 2 - this.vsize.width / 2
  389. let dialogY = this.dialog.height / 2 - this.vsize.height / 2 + 250 + offsetY
  390. this.dialog.x = this.vsize.width
  391. this.dialog.y = dialogY
  392. this.dialog.active = true
  393. let action2 = cc.moveTo(0.5, targetX + this.secretary.width, dialogY)
  394. this.dialog.runAction(action2)
  395. this.guideText.string = target.tips
  396. },
  397. /**
  398. * 根据状态key显示对应引导内容
  399. * @param {String} state 当前状态key
  400. */
  401. handleState (state) {
  402. if(this.stateRecord[state] || this.curState != null) {
  403. return
  404. } else {
  405. this.stateRecord[state] = true
  406. }
  407. if(state && !this.guideState[state].pass) {
  408. if(this.guideState[state]) {
  409. this.node.active = true
  410. this.curState = state
  411. this.guideState[state].pass = 1
  412. let stateClone = Object.assign({}, this.guideState)
  413. // 显示引导之后立即上报同步对应state数据
  414. this.uploadUserState(stateClone)
  415. } else {
  416. return
  417. }
  418. console.log("Show " + state);
  419. switch (state) {
  420. case 'state1': {
  421. // 滚动到底部
  422. this.scrollToBottom()
  423. setTimeout(() => {
  424. // 遮罩区域
  425. this.showMask()
  426. // 秘书人物
  427. this.showSecretary()
  428. // 对话框
  429. this.showDialog()
  430. // 指示位置
  431. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  432. }, 300);
  433. break;
  434. }
  435. case 'state2' : {
  436. // 滚动到底部
  437. this.scrollToBottom()
  438. this.homeSV.vertical = false
  439. setTimeout(() => {
  440. // 遮罩区域
  441. this.showMask()
  442. // 秘书人物
  443. this.showSecretary()
  444. // 对话框
  445. this.showDialog()
  446. // 指示位置
  447. this.setFingerPos(this.mask.x + this.mask.width, this.mask.y)
  448. }, 300)
  449. break;
  450. }
  451. case 'state3' : {
  452. // 滚动到底部
  453. this.scrollToBottom()
  454. this.homeSV.vertical = false
  455. setTimeout(() => {
  456. // 遮罩区域
  457. this.showMask()
  458. // 秘书人物
  459. this.showSecretary()
  460. // 对话框
  461. this.showDialog()
  462. // 指示位置
  463. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  464. }, 300)
  465. break;
  466. }
  467. case 'state4' : {
  468. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  469. let itemH = 340 // 每一层的高度
  470. let offsetY = maxScrollOffset.y - itemH
  471. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.2)
  472. setTimeout(() => {
  473. // 遮罩区域
  474. this.showMask()
  475. // 秘书人物
  476. this.showSecretary()
  477. // 对话框
  478. this.showDialog()
  479. // 指示位置
  480. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  481. }, 300)
  482. break;
  483. }
  484. case 'state5' : {
  485. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  486. let itemH = 340 * 2 - 10
  487. let offsetY = maxScrollOffset.y - itemH
  488. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.2)
  489. setTimeout(() => {
  490. // 遮罩区域
  491. this.showMask()
  492. // 秘书人物
  493. this.showSecretary()
  494. // 对话框
  495. this.showDialog()
  496. // 指示位置
  497. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  498. }, 300)
  499. break;
  500. }
  501. case 'state6' : {
  502. this.game.updateUIState(this.guideState)
  503. // 遮罩区域
  504. this.showMask()
  505. // 秘书人物
  506. this.showSecretary(250)
  507. // 对话框
  508. this.showDialog(250)
  509. // 指示位置
  510. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  511. break;
  512. }
  513. case 'state7' : {
  514. this.game._showFriendSystem()
  515. setTimeout(() => {
  516. // 遮罩区域
  517. this.showMask()
  518. // 秘书人物
  519. this.showSecretary(200)
  520. // 对话框
  521. this.showDialog(200)
  522. // 指示位置
  523. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  524. }, 200)
  525. break;
  526. }
  527. case 'state12' : {
  528. this.game.friendSystem.close()
  529. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  530. this.handlePass()
  531. this.handleState('state13')
  532. })
  533. // 遮罩区域
  534. this.showMask()
  535. // 秘书人物
  536. this.showSecretary(250)
  537. // 对话框
  538. this.showDialog(250)
  539. this.hideFinger()
  540. break;
  541. }
  542. case 'state13' : {
  543. // 遮罩区域
  544. this.showMask();
  545. // 秘书人物
  546. this.showSecretary(250);
  547. // 对话框
  548. this.showDialog(250);
  549. // 指示位置
  550. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  551. break;
  552. }
  553. case 'state14' : {
  554. // 遮罩区域
  555. this.showMask()
  556. // 秘书人物
  557. this.showSecretary()
  558. // 对话框
  559. this.showDialog()
  560. // 指示位置
  561. this.setFingerPos(this.mask.x, this.mask.y)
  562. break;
  563. }
  564. case 'state15':
  565. // 遮罩区域
  566. this.showMask();
  567. // 秘书人物
  568. this.showSecretary();
  569. // 对话框
  570. this.showDialog();
  571. if (this.vsize.height >= 1624) {
  572. this.mask.y += 238;
  573. }
  574. // 指示位置
  575. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  576. break;
  577. case 'state16':
  578. // 遮罩区域
  579. this.showMask();
  580. // 秘书人物
  581. this.showSecretary();
  582. // 对话框
  583. this.showDialog();
  584. if (this.vsize.height >= 1624) {
  585. this.mask.y += 146;
  586. }
  587. // 指示位置
  588. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  589. break;
  590. case 'state17': {
  591. this.game.friendSystem.close()
  592. if(this.game.userInfo) {
  593. this.game.userInfo.closeInformationAction()
  594. }
  595. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  596. this.handlePass()
  597. this.handleState('state18')
  598. })
  599. // 遮罩区域
  600. this.showMask()
  601. // 秘书人物
  602. this.showSecretary()
  603. // 对话框
  604. this.showDialog()
  605. this.hideFinger()
  606. break;
  607. }
  608. case 'state18': {
  609. let index = 4 - this.state18data.index
  610. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  611. let itemH = 333 * index
  612. let offsetY = maxScrollOffset.y - itemH
  613. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.3)
  614. // 遮罩区域
  615. this.showMask()
  616. // 秘书人物
  617. this.showSecretary()
  618. // 对话框
  619. this.showDialog()
  620. // 指示位置
  621. this.setFingerPos(this.mask.x + this.mask.width, this.mask.y);
  622. break;
  623. }
  624. case 'state19': {
  625. // 遮罩区域
  626. this.showMask()
  627. // 秘书人物
  628. this.showSecretary(250)
  629. // 对话框
  630. this.showDialog(250)
  631. // 指示位置
  632. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  633. break;
  634. }
  635. case 'state20': {
  636. // 遮罩区域
  637. this.showMask()
  638. // 对话框
  639. this.showDialog(250)
  640. // 指示位置
  641. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  642. break;
  643. }
  644. case 'state21': {
  645. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  646. this.handleEnd()
  647. })
  648. // 遮罩区域
  649. this.showMask()
  650. // 对话框
  651. this.showDialog(250)
  652. // 指示位置
  653. this.hideFinger()
  654. break;
  655. }
  656. case 'state25':
  657. // 遮罩区域
  658. this.showMask();
  659. // 秘书人物
  660. this.showSecretary();
  661. // 对话框
  662. this.showDialog();
  663. // 指示位置
  664. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  665. break;
  666. case 'state26':
  667. // 遮罩区域
  668. this.showMask();
  669. // 秘书人物
  670. this.showSecretary();
  671. // 对话框
  672. this.showDialog();
  673. // 指示位置
  674. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  675. break;
  676. case 'state27':
  677. // 遮罩区域
  678. this.showMask();
  679. // 秘书人物
  680. this.showSecretary();
  681. // 对话框
  682. this.showDialog();
  683. // 指示位置
  684. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  685. break;
  686. case 'state28':
  687. // 遮罩区域
  688. this.showMask();
  689. // 秘书人物
  690. this.showSecretary();
  691. // 对话框
  692. this.showDialog();
  693. if (this.vsize.height >= 1624) {
  694. this.mask.y += 240;
  695. }
  696. // 指示位置
  697. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  698. break;
  699. case 'state29':
  700. // 遮罩区域
  701. this.showMask();
  702. // 秘书人物
  703. this.showSecretary();
  704. // 对话框
  705. this.showDialog();
  706. if (this.vsize.height >= 1624) {
  707. this.mask.y += 146;
  708. }
  709. // 指示位置
  710. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  711. break;
  712. case 'state30':
  713. // 遮罩区域
  714. this.showMask();
  715. if (this.vsize.height >= 1624) {
  716. this.mask.y += 145;
  717. }
  718. // 秘书人物
  719. this.showSecretary();
  720. // 对话框
  721. this.showDialog();
  722. this.hideFinger ();
  723. break;
  724. case 'state31':
  725. // 遮罩区域
  726. this.showMask();
  727. // 秘书人物
  728. this.showSecretary();
  729. // 对话框
  730. this.showDialog();
  731. if (this.vsize.height >= 1624) {
  732. this.mask.y += 238;
  733. }
  734. // 指示位置
  735. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  736. break;
  737. case 'state32':
  738. // 遮罩区域
  739. this.showMask();
  740. // 秘书人物
  741. this.showSecretary();
  742. // 对话框
  743. this.showDialog();
  744. if (this.vsize.height >= 1624) {
  745. this.mask.y += 148;
  746. }
  747. // 指示位置
  748. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  749. break;
  750. case 'state33':
  751. // 遮罩区域
  752. this.showMask();
  753. // 秘书人物
  754. this.showSecretary();
  755. // 对话框
  756. this.showDialog();
  757. if (this.vsize.height >= 1624) {
  758. this.mask.y += 288;
  759. }
  760. // 指示位置
  761. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  762. break;
  763. case 'state34':
  764. // 遮罩区域
  765. this.showMask();
  766. // 秘书人物
  767. this.showSecretary();
  768. // 对话框
  769. this.showDialog();
  770. if (this.vsize.height >= 1624) {
  771. this.mask.y += 145;
  772. }
  773. this.hideFinger ();
  774. break;
  775. case 'state35':
  776. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  777. this.handlePass(this.curState)
  778. this.node.emit(`Fire_state35`)
  779. })
  780. // 遮罩区域
  781. this.showMask();
  782. // 秘书人物
  783. this.showSecretary();
  784. // 对话框
  785. this.showDialog();
  786. this.hideFinger ();
  787. break;
  788. case 'state36':
  789. // 遮罩区域
  790. this.showMask();
  791. // 秘书人物
  792. this.showSecretary();
  793. // 对话框
  794. this.showDialog();
  795. // 指示位置
  796. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  797. break;
  798. case 'state37':
  799. // 遮罩区域
  800. this.showMask();
  801. // 秘书人物
  802. this.showSecretary();
  803. // 对话框
  804. this.showDialog();
  805. if (this.vsize.height >= 1624) {
  806. this.mask.y += 291;
  807. }
  808. // 指示位置
  809. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  810. break;
  811. default:
  812. break;
  813. }
  814. return true
  815. } else {
  816. // return false
  817. }
  818. },
  819. /**
  820. * 隐藏遮罩半透明层
  821. */
  822. hideMask () {
  823. this.maskBg.active = false
  824. },
  825. /**
  826. * 已完成某一State,并上报
  827. *
  828. */
  829. handlePass (state) {
  830. let stateClone = Object.assign({}, this.guideState)
  831. this.game.updateUIState(stateClone)
  832. this.curState = null
  833. this.handleEnd()
  834. },
  835. handleEnd () {
  836. this.mask.active = false
  837. this.secretary.x = -700
  838. this.secretary.active = false
  839. this.dialog.x = 870
  840. this.dialog.active = false
  841. this.node.active = false
  842. this.finger.stopAllActions()
  843. },
  844. /**
  845. * 【特殊处理】抢夺好友引导
  846. * @param {Array} list 好友列表数组
  847. */
  848. handleGuideState14 (list) {
  849. // 好友数量大于0,同时已经完成了state7,触发抢夺好友引导state14
  850. if(list && list.length > 0 && this.guideState.state7.pass) {
  851. this.handleState('state14')
  852. }
  853. },
  854. /**
  855. * 【特殊处理】艺人入驻引导-17
  856. * @param {Array} list 艺人列表数组
  857. */
  858. handleGuideState17 (list) {
  859. let result = null
  860. list.forEach(n => {
  861. if(n.role == 2 && n.jobId && result == null) {
  862. result = {
  863. jobId: n.jobId
  864. }
  865. }
  866. })
  867. let unlockCount = 0
  868. this.game.levelHome.buildingInfos.forEach(n => {
  869. unlockCount += parseInt(n.isUnlocked)
  870. })
  871. // 拥有一名可入驻的艺人,
  872. // 同时已解锁5层建筑,
  873. // 同时已经完成了state16,
  874. // 触发抢夺好友引导state17
  875. if(result != null && this.guideState.state16.pass && unlockCount == 5) {
  876. // 遍历查找jobId对应的buildingInfo
  877. this.game.levelHome.buildingInfos.forEach((item, index) => {
  878. if(item.jobId == result.jobId) {
  879. result = Object.assign({index: index}, item)
  880. }
  881. })
  882. this.state18data = result
  883. this.handleState('state17')
  884. }
  885. },
  886. /**
  887. * 【特殊处理】艺人入驻引导-18
  888. */
  889. handleGuideState18 () {
  890. if(this.state18data) {
  891. let uid = parseInt(Global.user.uid)
  892. AlertManager.showArtistResident(this.state18data, uid, true);
  893. }
  894. },
  895. /**
  896. * 【特殊处理】判断当前引导结束后才执行下一个引导
  897. */
  898. handleGuideStateNext(current, next) {
  899. if (this.guideState[current].pass) {
  900. this.handleState(next);
  901. }
  902. },
  903. /**
  904. * 【特殊处理】培养和守护都完成后才触发互动引导
  905. */
  906. handleGuideState25 () {
  907. if (this.guideState.state28.pass && this.guideState.state31.pass) {
  908. this.handleState('state25');
  909. }
  910. },
  911. start () {
  912. },
  913. // update (dt) {},
  914. });