CurrentLevel.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import LocalData, { WorkState } from "../Template/LocalData";
  8. import PopComponet from "../Template/PopComponet";
  9. import GameLevel from "./GameLevel";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class CurrentLevel extends PopComponet {
  13. onLoad() {
  14. }
  15. protected onEnable(): void {
  16. let Label = this.node.getChildByName("Sp").getChildByName("Label").getComponent(cc.Label)
  17. let Node = this.node.getChildByName("Node")
  18. Node.active = false
  19. this.weiqi(true)
  20. //现在的关卡状态
  21. switch (LocalData.getInstance().getWorkState()) {
  22. case WorkState.引导:
  23. Label.string = `小鹅巴士`
  24. break;
  25. case WorkState.上班:
  26. if (GameLevel.gameLevel < 5) {
  27. Label.string = `第 ${GameLevel.gameLevel} 车`
  28. } else {
  29. Label.string = `最后一车`
  30. this.DifficultyUp_anim()
  31. }
  32. break;
  33. case WorkState.加班:
  34. Label.string = `加班车`
  35. break;
  36. default:
  37. cc.error('未知状态');
  38. break;
  39. }
  40. }
  41. protected start(): void {
  42. this.scheduleOnce(() => {
  43. if (this.isValid) {
  44. super.Surpclose()
  45. }
  46. }, 2)
  47. this.bus_anim()
  48. }
  49. bus_anim() {
  50. let Sp = this.node.getChildByName("Sp")
  51. Sp.setPosition(-1000, 0)
  52. cc.tween(Sp)
  53. .to(0.5, { x: 0 }, { easing: 'quadOut' })// quadOut2次方 cubicOut3次方 //quartOut 4次方
  54. .call(() => {
  55. this.weiqi(false)
  56. })
  57. .delay(1)
  58. .to(0.5, { x: 1000 }, { easing: 'quadIn' })
  59. .start()
  60. let Mask = this.node.getChildByName("Mask")
  61. Mask.opacity = 155
  62. cc.tween(Mask)
  63. .to(0.5, { opacity: 220 })
  64. .delay(1)
  65. .to(0.5, { opacity: 155 })
  66. .start()
  67. }
  68. //难度飙升
  69. DifficultyUp_anim() {
  70. let Node = this.node.getChildByName("Node")
  71. Node.active = true
  72. let image = Node.getChildByName("image")
  73. cc.tween(image)
  74. .to(0.5, { scale: 1.2 })
  75. .to(0.5, { scale: 1 })
  76. .to(0.5, { scale: 1.2 })
  77. .to(0.5, { scale: 1 })
  78. .start()
  79. }
  80. weiqi(is: boolean) {
  81. for (let index = 1; index < 4; index++) {
  82. let line3 = this.node.getChildByName("Sp").getChildByName("line" + index)
  83. line3.active = is
  84. }
  85. }
  86. }