HomeGuide.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  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 >= 1500) {
  575. this.mask.y += 165;
  576. this.mask.y += (this.vsize.height - 1500)/2.0;
  577. }
  578. // 指示位置
  579. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  580. break;
  581. case 'state16':
  582. // 遮罩区域
  583. this.showMask();
  584. // 秘书人物
  585. this.showSecretary();
  586. // 对话框
  587. this.showDialog();
  588. if (this.vsize.height >= 1500) {
  589. this.mask.y += 85;
  590. this.mask.y += (this.vsize.height - 1500)/2.0;
  591. }
  592. // 指示位置
  593. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  594. break;
  595. case 'state17': {
  596. this.game.friendSystem.close()
  597. if(this.game.userInfo) {
  598. this.game.userInfo.closeInformationAction()
  599. }
  600. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  601. this.handlePass()
  602. setTimeout(() => {
  603. this.handleState('state18')
  604. }, 300);
  605. })
  606. // 遮罩区域
  607. this.showMask()
  608. // 秘书人物
  609. this.showSecretary()
  610. // 对话框
  611. this.showDialog()
  612. this.hideFinger()
  613. break;
  614. }
  615. case 'state18': {
  616. let index = 4 - this.state18data.index
  617. let maxScrollOffset = this.homeSV.getMaxScrollOffset() // scrollView组件最大偏移量
  618. let itemH = 333 * index
  619. let offsetY = maxScrollOffset.y - itemH
  620. this.homeSV.scrollToOffset(cc.v2(0, offsetY), 0.3)
  621. // 遮罩区域
  622. this.showMask()
  623. // 秘书人物
  624. this.showSecretary()
  625. // 对话框
  626. this.showDialog()
  627. // 指示位置
  628. this.setFingerPos(this.mask.x + this.mask.width, this.mask.y);
  629. break;
  630. }
  631. case 'state19': {
  632. // 遮罩区域
  633. this.showMask()
  634. // 秘书人物
  635. this.showSecretary(250)
  636. // 对话框
  637. this.showDialog(250)
  638. // 指示位置
  639. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  640. break;
  641. }
  642. case 'state20': {
  643. // 遮罩区域
  644. this.showMask()
  645. // 对话框
  646. this.showDialog(250)
  647. // 指示位置
  648. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  649. break;
  650. }
  651. case 'state21': {
  652. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  653. this.handleEnd()
  654. })
  655. // 遮罩区域
  656. this.showMask()
  657. // 对话框
  658. this.showDialog(250)
  659. // 指示位置
  660. this.hideFinger()
  661. break;
  662. }
  663. case 'state25':
  664. // 遮罩区域
  665. this.showMask();
  666. // 秘书人物
  667. this.showSecretary();
  668. // 对话框
  669. this.showDialog();
  670. // 指示位置
  671. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  672. break;
  673. case 'state26':
  674. // 遮罩区域
  675. this.showMask();
  676. // 秘书人物
  677. this.showSecretary();
  678. // 对话框
  679. this.showDialog();
  680. if (this.vsize.height >= 1500) {
  681. this.mask.y += 83;
  682. this.mask.y += (this.vsize.height - 1500)/2.0;
  683. }
  684. // 指示位置
  685. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  686. break;
  687. case 'state27':
  688. // 遮罩区域
  689. this.showMask();
  690. // 秘书人物
  691. this.showSecretary();
  692. // 对话框
  693. this.showDialog();
  694. if (this.vsize.height >= 1500) {
  695. this.mask.y += 84;
  696. this.mask.y += (this.vsize.height - 1500)/2.0;
  697. }
  698. // 指示位置
  699. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  700. break;
  701. case 'state28':
  702. // 遮罩区域
  703. this.showMask();
  704. // 秘书人物
  705. this.showSecretary();
  706. // 对话框
  707. this.showDialog();
  708. if (this.vsize.height >= 1500) {
  709. this.mask.y += 178;
  710. this.mask.y += (this.vsize.height - 1500)/2.0;
  711. }
  712. // 指示位置
  713. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  714. break;
  715. case 'state29':
  716. // 遮罩区域
  717. this.showMask();
  718. // 秘书人物
  719. this.showSecretary();
  720. // 对话框
  721. this.showDialog();
  722. if (this.vsize.height >= 1500) {
  723. this.mask.y += 84;
  724. this.mask.y += (this.vsize.height - 1500)/2.0;
  725. }
  726. // 指示位置
  727. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  728. break;
  729. case 'state30':
  730. // 遮罩区域
  731. this.showMask();
  732. if (this.vsize.height >= 1500) {
  733. this.mask.y += 83;
  734. this.mask.y += (this.vsize.height - 1500)/2.0;
  735. }
  736. // 秘书人物
  737. this.showSecretary();
  738. // 对话框
  739. this.showDialog();
  740. this.hideFinger ();
  741. break;
  742. case 'state31':
  743. // 遮罩区域
  744. this.showMask();
  745. // 秘书人物
  746. this.showSecretary();
  747. // 对话框
  748. this.showDialog();
  749. if (this.vsize.height >= 1500) {
  750. this.mask.y += 176;
  751. this.mask.y += (this.vsize.height - 1500)/2.0;
  752. }
  753. // 指示位置
  754. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  755. break;
  756. case 'state32':
  757. // 遮罩区域
  758. this.showMask();
  759. // 秘书人物
  760. this.showSecretary();
  761. // 对话框
  762. this.showDialog();
  763. if (this.vsize.height >= 1500) {
  764. this.mask.y += 86;
  765. this.mask.y += (this.vsize.height - 1500)/2.0;
  766. }
  767. // 指示位置
  768. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  769. break;
  770. case 'state33':
  771. // 遮罩区域
  772. this.showMask();
  773. // 秘书人物
  774. this.showSecretary();
  775. // 对话框
  776. this.showDialog();
  777. if (this.vsize.height >= 1500) {
  778. this.mask.y += 164;
  779. this.mask.y += this.vsize.height - 1500;
  780. }
  781. // 指示位置
  782. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  783. break;
  784. case 'state34':
  785. // 遮罩区域
  786. this.showMask();
  787. // 秘书人物
  788. this.showSecretary();
  789. // 对话框
  790. this.showDialog();
  791. if (this.vsize.height >= 1500) {
  792. this.mask.y += 83;
  793. this.mask.y += (this.vsize.height - 1500)/2.0;
  794. }
  795. this.hideFinger ();
  796. break;
  797. case 'state35':
  798. this.dialog.once(cc.Node.EventType.TOUCH_END, () => {
  799. this.handlePass(this.curState)
  800. this.node.emit(`Fire_state35`)
  801. })
  802. // 遮罩区域
  803. this.showMask();
  804. // 秘书人物
  805. this.showSecretary();
  806. // 对话框
  807. this.showDialog();
  808. this.hideFinger ();
  809. break;
  810. case 'state36':
  811. // 遮罩区域
  812. this.showMask();
  813. // 秘书人物
  814. this.showSecretary();
  815. // 对话框
  816. this.showDialog();
  817. // 指示位置
  818. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  819. break;
  820. case 'state37':
  821. // 遮罩区域
  822. this.showMask();
  823. // 秘书人物
  824. this.showSecretary();
  825. // 对话框
  826. this.showDialog();
  827. if (this.vsize.height >= 1500) {
  828. this.mask.y += 167;
  829. this.mask.y += this.vsize.height - 1500;
  830. }
  831. // 指示位置
  832. this.setFingerPos(this.mask.x + this.mask.width / 2, this.mask.y);
  833. break;
  834. default:
  835. break;
  836. }
  837. return true
  838. } else {
  839. // return false
  840. }
  841. },
  842. /**
  843. * 隐藏遮罩半透明层
  844. */
  845. hideMask () {
  846. this.maskBg.active = false
  847. },
  848. /**
  849. * 已完成某一State,并上报
  850. *
  851. */
  852. handlePass (state) {
  853. let stateClone = Object.assign({}, this.guideState)
  854. this.game.updateUIState(stateClone)
  855. this.curState = null
  856. this.handleEnd()
  857. },
  858. handleEnd () {
  859. this.mask.active = false
  860. this.secretary.x = -700
  861. this.secretary.active = false
  862. this.dialog.x = 870
  863. this.dialog.active = false
  864. this.node.active = false
  865. this.finger.stopAllActions()
  866. },
  867. /**
  868. * 【特殊处理】开启好友功能引导
  869. */
  870. handleGuideState6 () {
  871. if(this.guideState.state5.pass) {
  872. this.handleState('state6')
  873. }
  874. },
  875. /**
  876. * 【特殊处理】抢夺好友引导
  877. * @param {Array} list 好友列表数组
  878. */
  879. handleGuideState14 (list) {
  880. // 好友数量大于0,同时已经完成了state7,触发抢夺好友引导state14
  881. if(list && list.length > 0 && this.guideState.state7.pass) {
  882. // 如果好友列表第一个为老板,则需要再判断除老板以外的好友
  883. if(list[0].role == 1) {
  884. if(list.length >= 2) {
  885. this.guideState.state14.pos = [0, -53]
  886. this.guideState.state14.uid = list[1].uid
  887. this.handleState('state14')
  888. }
  889. } else {
  890. // 如果好友列表第一个不是老板,则直接显示引导好友列表第一条
  891. this.guideState.state14.uid = list[0].uid
  892. this.handleState('state14')
  893. }
  894. }
  895. },
  896. /**
  897. * 【特殊处理】艺人入驻引导-17
  898. * @param {Array} list 艺人列表数组
  899. */
  900. handleGuideState17 (list) {
  901. let result = null
  902. list.forEach(n => {
  903. if(n.role == 2 && n.jobId && result == null) {
  904. result = {
  905. jobId: n.jobId
  906. }
  907. }
  908. })
  909. let unlockCount = 0
  910. this.game.levelHome.buildingInfos.forEach(n => {
  911. unlockCount += parseInt(n.isUnlocked)
  912. })
  913. // 拥有一名可入驻的艺人,
  914. // 同时已解锁5层建筑,
  915. // 同时已经完成了state16,
  916. // 触发抢夺好友引导state17
  917. if(result != null && this.guideState.state16.pass && unlockCount == 5) {
  918. // 遍历查找jobId对应的buildingInfo
  919. this.game.levelHome.buildingInfos.forEach((item, index) => {
  920. if(item.jobId == result.jobId) {
  921. result = Object.assign({index: index}, item)
  922. }
  923. })
  924. this.state18data = result
  925. this.handleState('state17')
  926. }
  927. },
  928. /**
  929. * 【特殊处理】艺人入驻引导-18
  930. */
  931. handleGuideState18 () {
  932. if(this.state18data) {
  933. let uid = parseInt(Global.user.uid)
  934. AlertManager.showArtistResident(this.state18data, uid, true);
  935. }
  936. },
  937. /**
  938. * 【特殊处理】判断当前引导结束后才执行下一个引导
  939. */
  940. handleGuideStateNext(current, next) {
  941. if (this.guideState[current].pass) {
  942. this.handleState(next);
  943. }
  944. },
  945. /**
  946. * 【特殊处理】培养和守护都完成后才触发互动引导
  947. */
  948. handleGuideState25 () {
  949. if (this.guideState.state28.pass && this.guideState.state31.pass) {
  950. this.handleState('state25');
  951. }
  952. },
  953. start () {
  954. },
  955. // update (dt) {},
  956. });