NoviceWindow.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { _decorator, Component, Node } from 'cc';
  2. import { Http } from '../core/net/Http';
  3. import { WindowManager } from '../core/ui/window/WindowManager';
  4. import { WindowOpenMode } from '../core/ui/window/WindowOpenMode';
  5. import { g } from '../Data/g';
  6. const { ccclass, property } = _decorator;
  7. /** 新手引导 */
  8. @ccclass('NoviceWindow')
  9. export class NoviceWindow extends Component {
  10. @property({ type: [Node], tooltip: "新手引导节点集合" }) novices: Array<Node> = [];
  11. // @property({ type: Window, tooltip: "获取窗口" }) getWindow: Window;
  12. @property({ type: Http, tooltip: "http组件" }) http: Http;
  13. public static isNovicing = false;
  14. public static isOpenLvRedpacket = false;
  15. public static isLastStep = false;
  16. private index = 0;
  17. start() {
  18. NoviceWindow.isNovicing = true;
  19. for (let i = 0; i < this.novices.length; i++) {
  20. this.novices[i].active = i == 0;
  21. }
  22. this.index = 0;
  23. }
  24. update() {
  25. if (!NoviceWindow.isNovicing) {
  26. this.node.active = false;
  27. this.node.destroy();
  28. }
  29. if (NoviceWindow.isOpenLvRedpacket) {
  30. this.novices[this.index].active = false;
  31. NoviceWindow.isOpenLvRedpacket = false;
  32. }
  33. if (NoviceWindow.isLastStep) {
  34. NoviceWindow.isLastStep = false;
  35. this.next();
  36. } else {
  37. switch (this.index) {
  38. case 0:
  39. if (g.gameData.getMyLocalData(g.userData.id).myLocalGenerals.length > 1) {
  40. this.next();
  41. }
  42. break;
  43. case 1:
  44. if (g.userData.lv == 2) {
  45. this.next();
  46. }
  47. break;
  48. }
  49. }
  50. }
  51. /**下一步 */
  52. public next(): void {
  53. this.novices[this.index].active = false;
  54. if (this.novices[this.index + 1]) {
  55. this.novices[++this.index].active = true;
  56. } else {
  57. this.node.active = false;
  58. this.node.destroy();
  59. }
  60. }
  61. /**打开等级红包 */
  62. public goTowithDraw(): void {
  63. WindowManager.open("Prefabs/Withdraw/Withdraw", WindowOpenMode.CloseAndCover);
  64. this.next();
  65. }
  66. }