HomeGuide.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  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: [510, 80],
  157. pos: [0, -40]
  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. // this.guideState.state17.pass = 0
  240. // this.guideState.state18.pass = 0
  241. // this.guideState.state19.pass = 0
  242. // this.guideState.state20.pass = 0
  243. // this.guideState.state21.pass = 0
  244. // For Test: state4
  245. // this.handleState('state17')
  246. },
  247. /**
  248. * 同步用户guideState
  249. */
  250. syncStatePass () {
  251. let _guideState = window.guideState
  252. // let _guideState = cc.sys.localStorage.getItem('guideState');
  253. if(!!_guideState) {
  254. for(let i in _guideState) {
  255. if(this.guideState[i]) {
  256. this.guideState[i].pass = _guideState[i]
  257. }
  258. }
  259. } else {
  260. let _guideState = Object.assign({}, this.guideState)
  261. this.uploadUserState(_guideState)
  262. }
  263. },
  264. /**
  265. * 上报用户guideState
  266. * @param {Object} stateObj guideState对象
  267. */
  268. uploadUserState (stateObj) {
  269. for(let i in stateObj) {
  270. stateObj[i] = stateObj[i].pass
  271. }
  272. let stateStr = JSON.stringify(stateObj)
  273. // cc.sys.localStorage.setItem('guideState', stateStr)
  274. // 上报用户数据
  275. Api.httpPost({
  276. url: "/direct/add.do",
  277. data: {
  278. directJson: stateStr
  279. },
  280. success: res => {
  281. }
  282. })
  283. },
  284. initEvent() {
  285. this.mask.on(cc.Node.EventType.TOUCH_END, () => {
  286. this.homeSV.vertical = true
  287. if(this.curState == 'state6') {
  288. // state6 结束后直接跳到 state7
  289. this.handlePass(this.curState)
  290. this.handleState('state7')
  291. } else if(this.curState == 'state7') {
  292. this.handlePass(this.curState)
  293. // state7 点击后显示邀请好友弹窗
  294. this.game.friendSystem.showTalent()
  295. } else if(this.curState == 'state13') {
  296. // state13 结束后直接跳到 state14
  297. this.handlePass(this.curState)
  298. setTimeout(() => {
  299. this.handleState('state14')
  300. }, 300)
  301. } else if(this.curState == 'state14') {
  302. // 跳转userinfo界面
  303. if(this.guideState.state14.uid) {
  304. this.game.gameFSM.showuserinfo(this.guideState.state14.uid)
  305. }
  306. this.handlePass(this.curState)
  307. } else if(this.curState == 'state18') {
  308. this.handleGuideState18()
  309. this.handlePass(this.curState)
  310. setTimeout(() => {
  311. this.handleState('state19')
  312. }, 300)
  313. } else if(this.curState == 'state19') {
  314. let cnode = cc.find('Canvas/artist_resident')
  315. cnode = cnode.getComponent('ArtistResident')
  316. cnode.guide()
  317. this.curState = null
  318. this.handleState('state20')
  319. } else if(this.curState == 'state20') {
  320. let cnode = cc.find('Canvas/artist_resident')
  321. cnode = cnode.getComponent('ArtistResident')
  322. cnode.confirm()
  323. this.curState = null
  324. this.handleState('state21')
  325. } else if(!!this.curState) {
  326. // 其他state的操作处理,触发在此节点上的自定义事件
  327. this.node.emit(`Fire_${this.curState}`)
  328. this.handlePass(this.curState)
  329. }
  330. }, this)
  331. },
  332. /**
  333. * 设置手指指示位置
  334. * @param {Number} x mask的x坐标
  335. * @param {Number} y mask的y坐标
  336. */
  337. setFingerPos (x, y) {
  338. this.finger.active = true;
  339. let offsetY = 20
  340. // 手指当前位置 = mask矩形位置的右下角 + 偏移量
  341. this.finger.x = x
  342. this.finger.y = y - this.finger.height / 2
  343. let actionUp = cc.moveBy(0.5, 0, offsetY)
  344. let actionDown = cc.moveBy(0.5, 0, -offsetY)
  345. let seq = cc.repeatForever(cc.sequence(actionUp, actionDown))
  346. this.finger.runAction(seq)
  347. },
  348. //隐藏指示点击手指,部分引导不需要
  349. hideFinger () {
  350. this.finger.active = false;
  351. this.finger.stopAllActions();
  352. },
  353. /**
  354. * 显示遮罩层
  355. */
  356. showMask () {
  357. let target = this.guideState[this.curState]
  358. this.maskBg.active = !!target.mask
  359. this.mask.active = true
  360. this.mask.width = target.rect[0]
  361. this.mask.height = target.rect[1]
  362. this.mask.x = target.pos[0]
  363. this.mask.y = (1624 - this.vsize.height) / 2 + target.pos[1]
  364. },
  365. /**
  366. * levelhome 的 scrollView 组件滚动到底部
  367. * 某些任务状态下必须 [state1, state2, state3]
  368. */
  369. scrollToBottom () {
  370. this.homeSV.scrollToBottom(0)
  371. },
  372. /**
  373. * 显示秘书人物内容
  374. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  375. */
  376. showSecretary (offsetY = 0) {
  377. let targetX = this.secretary.width / 2 - this.vsize.width / 2
  378. let secretaryY = this.secretary.height / 2 - this.vsize.height / 2 + offsetY
  379. this.secretary.x = -this.vsize.width
  380. this.secretary.y = secretaryY
  381. this.secretary.active = true
  382. let action1 = cc.moveTo(0.4, targetX, secretaryY)
  383. this.secretary.runAction(action1)
  384. },
  385. /**
  386. * 显示对话框内容
  387. * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0
  388. */
  389. showDialog (offsetY = 0) {
  390. let target = this.guideState[this.curState]
  391. let targetX = this.secretary.width / 2 - this.vsize.width / 2
  392. let dialogY = this.dialog.height / 2 - this.vsize.height / 2 + 250 + offsetY
  393. this.dialog.x = this.vsize.width
  394. this.dialog.y = dialogY
  395. this.dialog.active = true
  396. let action2 = cc.moveTo(0.5, targetX + this.secretary.width, dialogY)
  397. this.dialog.runAction(action2)
  398. this.guideText.string = target.tips
  399. },
  400. /**
  401. * 根据状态key显示对应引导内容
  402. * @param {String} state 当前状态key
  403. */
  404. handleState (state) {
  405. if(this.stateRecord[state] || this.curState != null) {
  406. return
  407. } else {
  408. this.stateRecord[state] = true
  409. }
  410. if(state && !this.guideState[state].pass) {
  411. if(this.guideState[state]) {
  412. this.node.active = true
  413. this.curState = state
  414. this.guideState[state].pass = 1
  415. let stateClone = Object.assign({}, this.guideState)
  416. // 显示引导之后立即上报同步对应state数据
  417. this.uploadUserState(stateClone)
  418. } else {
  419. return
  420. }
  421. console.log("Show " + state);
  422. switch (state) {
  423. case 'state1': {
  424. // 滚动到底部
  425. this.scrollToBottom()
  426. setTimeout(() => {
  427. // 遮罩区域
  428. this.showMask()
  429. // 秘书人物
  430. this.showSecretary()
  431. // 对话框
  432. this.showDialog()
  433. // 指示位置
  434. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  435. }, 50);
  436. break;
  437. }
  438. case 'state2' : {
  439. // 滚动到底部
  440. this.scrollToBottom()
  441. this.homeSV.vertical = false
  442. setTimeout(() => {
  443. // 遮罩区域
  444. this.showMask()
  445. // 秘书人物
  446. this.showSecretary()
  447. // 对话框
  448. this.showDialog()
  449. // 指示位置
  450. this.setFingerPos(this.mask.x + this.mask.width, this.mask.y)
  451. }, 50)
  452. break;
  453. }
  454. case 'state3' : {
  455. // 滚动到底部
  456. this.scrollToBottom()
  457. this.homeSV.vertical = false
  458. setTimeout(() => {
  459. // 遮罩区域
  460. this.showMask()
  461. // 秘书人物
  462. this.showSecretary()
  463. // 对话框
  464. this.showDialog()
  465. // 指示位置
  466. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  467. }, 50)
  468. break;
  469. }
  470. case 'state4' : {
  471. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  472. let itemH = 340 // 每一层的高度
  473. let offsetY = maxScrollOffset.y - itemH
  474. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.2)
  475. setTimeout(() => {
  476. // 遮罩区域
  477. this.showMask()
  478. // 秘书人物
  479. this.showSecretary()
  480. // 对话框
  481. this.showDialog()
  482. // 指示位置
  483. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  484. }, 50)
  485. break;
  486. }
  487. case 'state5' : {
  488. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  489. let itemH = 340 * 2 - 10
  490. let offsetY = maxScrollOffset.y - itemH
  491. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.2)
  492. setTimeout(() => {
  493. // 遮罩区域
  494. this.showMask()
  495. // 秘书人物
  496. this.showSecretary()
  497. // 对话框
  498. this.showDialog()
  499. // 指示位置
  500. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  501. }, 50)
  502. break;
  503. }
  504. case 'state6' : {
  505. this.game.updateUIState(this.guideState)
  506. // 遮罩区域
  507. this.showMask()
  508. // 秘书人物
  509. this.showSecretary(250)
  510. // 对话框
  511. this.showDialog(250)
  512. // 指示位置
  513. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  514. break;
  515. }
  516. case 'state7' : {
  517. this.game._showFriendSystem()
  518. setTimeout(() => {
  519. // 遮罩区域
  520. this.showMask()
  521. // 秘书人物
  522. this.showSecretary(200)
  523. // 对话框
  524. this.showDialog(200)
  525. // 指示位置
  526. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y)
  527. }, 50)
  528. break;
  529. }
  530. case 'state12' : {
  531. this.game.friendSystem.close()
  532. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  533. this.handlePass()
  534. this.handleState('state13')
  535. })
  536. // 遮罩区域
  537. this.showMask()
  538. // 秘书人物
  539. this.showSecretary(250)
  540. // 对话框
  541. this.showDialog(250)
  542. this.hideFinger()
  543. break;
  544. }
  545. case 'state13' : {
  546. // 遮罩区域
  547. this.showMask();
  548. // 秘书人物
  549. this.showSecretary(250);
  550. // 对话框
  551. this.showDialog(250);
  552. // 指示位置
  553. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  554. break;
  555. }
  556. case 'state14' : {
  557. // 遮罩区域
  558. this.showMask()
  559. // 秘书人物
  560. this.showSecretary()
  561. // 对话框
  562. this.showDialog()
  563. // 指示位置
  564. this.setFingerPos(this.mask.x, this.mask.y)
  565. break;
  566. }
  567. case 'state15':
  568. // 遮罩区域
  569. this.showMask();
  570. // 秘书人物
  571. this.showSecretary();
  572. // 对话框
  573. this.showDialog();
  574. if (this.vsize.height >= 1624) {
  575. this.mask.y += 238;
  576. }
  577. // 指示位置
  578. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  579. break;
  580. case 'state16':
  581. // 遮罩区域
  582. this.showMask();
  583. // 秘书人物
  584. this.showSecretary();
  585. // 对话框
  586. this.showDialog();
  587. if (this.vsize.height >= 1624) {
  588. this.mask.y += 146;
  589. }
  590. // 指示位置
  591. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  592. break;
  593. case 'state17': {
  594. this.game.friendSystem.close()
  595. if(this.game.userInfo) {
  596. this.game.userInfo.closeInformationAction()
  597. }
  598. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  599. this.handlePass()
  600. setTimeout(() => {
  601. this.handleState('state18')
  602. }, 300);
  603. })
  604. // 遮罩区域
  605. this.showMask()
  606. // 秘书人物
  607. this.showSecretary()
  608. // 对话框
  609. this.showDialog()
  610. this.hideFinger()
  611. break;
  612. }
  613. case 'state18': {
  614. let index = 4 - this.state18data.index
  615. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  616. let itemH = 333 * index
  617. let offsetY = maxScrollOffset.y - itemH
  618. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.3)
  619. // 遮罩区域
  620. this.showMask()
  621. // 秘书人物
  622. this.showSecretary()
  623. // 对话框
  624. this.showDialog()
  625. // 指示位置
  626. this.setFingerPos(this.mask.x + this.mask.width, this.mask.y);
  627. break;
  628. }
  629. case 'state19': {
  630. // 遮罩区域
  631. this.showMask()
  632. // 秘书人物
  633. this.showSecretary(250)
  634. // 对话框
  635. this.showDialog(250)
  636. // 指示位置
  637. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  638. break;
  639. }
  640. case 'state20': {
  641. // 遮罩区域
  642. this.showMask()
  643. // 对话框
  644. this.showDialog(250)
  645. // 指示位置
  646. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  647. break;
  648. }
  649. case 'state21': {
  650. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  651. this.handleEnd()
  652. })
  653. // 遮罩区域
  654. this.showMask()
  655. // 对话框
  656. this.showDialog(250)
  657. // 指示位置
  658. this.hideFinger()
  659. break;
  660. }
  661. case 'state25':
  662. // 遮罩区域
  663. this.showMask();
  664. // 秘书人物
  665. this.showSecretary();
  666. // 对话框
  667. this.showDialog();
  668. // 指示位置
  669. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  670. break;
  671. case 'state26':
  672. // 遮罩区域
  673. this.showMask();
  674. // 秘书人物
  675. this.showSecretary();
  676. // 对话框
  677. this.showDialog();
  678. if (this.vsize.height >= 1500) {
  679. this.mask.y += 83;
  680. this.mask.y += (this.vsize.height - 1500)/2.0;
  681. }
  682. // 指示位置
  683. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  684. break;
  685. case 'state27':
  686. // 遮罩区域
  687. this.showMask();
  688. // 秘书人物
  689. this.showSecretary();
  690. // 对话框
  691. this.showDialog();
  692. if (this.vsize.height >= 1500) {
  693. this.mask.y += 84;
  694. this.mask.y += (this.vsize.height - 1500)/2.0;
  695. }
  696. // 指示位置
  697. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  698. break;
  699. case 'state28':
  700. // 遮罩区域
  701. this.showMask();
  702. // 秘书人物
  703. this.showSecretary();
  704. // 对话框
  705. this.showDialog();
  706. if (this.vsize.height >= 1500) {
  707. this.mask.y += 178;
  708. this.mask.y += (this.vsize.height - 1500)/2.0;
  709. }
  710. // 指示位置
  711. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  712. break;
  713. case 'state29':
  714. // 遮罩区域
  715. this.showMask();
  716. // 秘书人物
  717. this.showSecretary();
  718. // 对话框
  719. this.showDialog();
  720. if (this.vsize.height >= 1500) {
  721. this.mask.y += 84;
  722. this.mask.y += (this.vsize.height - 1500)/2.0;
  723. }
  724. // 指示位置
  725. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  726. break;
  727. case 'state30':
  728. // 遮罩区域
  729. this.showMask();
  730. if (this.vsize.height >= 1500) {
  731. this.mask.y += 83;
  732. this.mask.y += (this.vsize.height - 1500)/2.0;
  733. }
  734. // 秘书人物
  735. this.showSecretary();
  736. // 对话框
  737. this.showDialog();
  738. this.hideFinger ();
  739. break;
  740. case 'state31':
  741. // 遮罩区域
  742. this.showMask();
  743. // 秘书人物
  744. this.showSecretary();
  745. // 对话框
  746. this.showDialog();
  747. if (this.vsize.height >= 1500) {
  748. this.mask.y += 176;
  749. this.mask.y += (this.vsize.height - 1500)/2.0;
  750. }
  751. // 指示位置
  752. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  753. break;
  754. case 'state32':
  755. // 遮罩区域
  756. this.showMask();
  757. // 秘书人物
  758. this.showSecretary();
  759. // 对话框
  760. this.showDialog();
  761. if (this.vsize.height >= 1500) {
  762. this.mask.y += 86;
  763. this.mask.y += (this.vsize.height - 1500)/2.0;
  764. }
  765. // 指示位置
  766. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  767. break;
  768. case 'state33':
  769. // 遮罩区域
  770. this.showMask();
  771. // 秘书人物
  772. this.showSecretary();
  773. // 对话框
  774. this.showDialog();
  775. if (this.vsize.height >= 1500) {
  776. this.mask.y += 164;
  777. this.mask.y += this.vsize.height - 1500;
  778. }
  779. // 指示位置
  780. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  781. break;
  782. case 'state34':
  783. // 遮罩区域
  784. this.showMask();
  785. // 秘书人物
  786. this.showSecretary();
  787. // 对话框
  788. this.showDialog();
  789. if (this.vsize.height >= 1500) {
  790. this.mask.y += 83;
  791. this.mask.y += (this.vsize.height - 1500)/2.0;
  792. }
  793. this.hideFinger ();
  794. break;
  795. case 'state35':
  796. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  797. this.handlePass(this.curState)
  798. this.node.emit(`Fire_state35`)
  799. })
  800. // 遮罩区域
  801. this.showMask();
  802. // 秘书人物
  803. this.showSecretary();
  804. // 对话框
  805. this.showDialog();
  806. this.hideFinger ();
  807. break;
  808. case 'state36':
  809. // 遮罩区域
  810. this.showMask();
  811. // 秘书人物
  812. this.showSecretary();
  813. // 对话框
  814. this.showDialog();
  815. // 指示位置
  816. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  817. break;
  818. case 'state37':
  819. // 遮罩区域
  820. this.showMask();
  821. // 秘书人物
  822. this.showSecretary();
  823. // 对话框
  824. this.showDialog();
  825. if (this.vsize.height >= 1500) {
  826. this.mask.y += 167;
  827. this.mask.y += this.vsize.height - 1500;
  828. }
  829. // 指示位置
  830. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  831. break;
  832. default:
  833. break;
  834. }
  835. return true
  836. } else {
  837. // return false
  838. }
  839. },
  840. /**
  841. * 隐藏遮罩半透明层
  842. */
  843. hideMask () {
  844. this.maskBg.active = false
  845. },
  846. /**
  847. * 已完成某一State,并上报
  848. *
  849. */
  850. handlePass (state) {
  851. let stateClone = Object.assign({}, this.guideState)
  852. this.game.updateUIState(stateClone)
  853. this.curState = null
  854. this.handleEnd()
  855. },
  856. handleEnd () {
  857. this.mask.active = false
  858. this.secretary.x = -700
  859. this.secretary.active = false
  860. this.dialog.x = 870
  861. this.dialog.active = false
  862. this.node.active = false
  863. this.finger.stopAllActions()
  864. },
  865. /**
  866. * 【特殊处理】开启好友功能引导
  867. */
  868. handleGuideState6 () {
  869. if(this.guideState.state5.pass) {
  870. this.handleState('state6')
  871. }
  872. },
  873. /**
  874. * 【特殊处理】抢夺好友引导
  875. * @param {Array} list 好友列表数组
  876. */
  877. handleGuideState14 (list) {
  878. // 好友数量大于0,同时已经完成了state7,触发抢夺好友引导state14
  879. if(list && list.length > 0 && this.guideState.state7.pass) {
  880. // 如果好友列表第一个为老板,则需要再判断除老板以外的好友
  881. if(list[0].role == 1) {
  882. if(list.length >= 2) {
  883. this.guideState.state14.pos = [0, -53]
  884. this.guideState.state14.uid = list[1].uid
  885. this.handleState('state14')
  886. }
  887. } else {
  888. // 如果好友列表第一个不是老板,则直接显示引导好友列表第一条
  889. this.guideState.state14.uid = list[0].uid
  890. this.handleState('state14')
  891. }
  892. }
  893. },
  894. /**
  895. * 【特殊处理】艺人入驻引导-17
  896. * @param {Array} list 艺人列表数组
  897. */
  898. handleGuideState17 (list) {
  899. let result = null
  900. list.forEach(n => {
  901. if(n.role == 2 && n.jobId && result == null) {
  902. result = {
  903. jobId: n.jobId
  904. }
  905. }
  906. })
  907. let unlockCount = 0
  908. this.game.levelHome.buildingInfos.forEach(n => {
  909. unlockCount += parseInt(n.isUnlocked)
  910. })
  911. // 拥有一名可入驻的艺人,
  912. // 同时已解锁5层建筑,
  913. // 同时已经完成了state16,
  914. // 触发抢夺好友引导state17
  915. if(result != null && this.guideState.state16.pass && unlockCount == 5) {
  916. // 遍历查找jobId对应的buildingInfo
  917. this.game.levelHome.buildingInfos.forEach((item, index) => {
  918. if(item.jobId == result.jobId) {
  919. result = Object.assign({index: index}, item)
  920. }
  921. })
  922. this.state18data = result
  923. this.handleState('state17')
  924. }
  925. },
  926. /**
  927. * 【特殊处理】艺人入驻引导-18
  928. */
  929. handleGuideState18 () {
  930. if(this.state18data) {
  931. let uid = parseInt(Global.user.uid)
  932. AlertManager.showArtistResident(this.state18data, uid, true);
  933. }
  934. },
  935. /**
  936. * 【特殊处理】判断当前引导结束后才执行下一个引导
  937. */
  938. handleGuideStateNext(current, next) {
  939. if (this.guideState[current].pass) {
  940. this.handleState(next);
  941. }
  942. },
  943. /**
  944. * 【特殊处理】培养和守护都完成后才触发互动引导
  945. */
  946. handleGuideState25 () {
  947. if (this.guideState.state28.pass && this.guideState.state31.pass) {
  948. this.handleState('state25');
  949. }
  950. },
  951. start () {
  952. },
  953. // update (dt) {},
  954. });