DifficultyManager.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { _decorator, Component, Label, macro, Node, NodeEventType } from 'cc';
  2. import { EventManager } from './EventManager';
  3. import { DEBUG } from 'cc/env';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('DifficultyManager')
  6. export class DifficultyManager extends Component {
  7. Difficulty: number = -1
  8. static UpSpeed: number = 10;
  9. static G: number = 0;
  10. static Left_Right_Speed: number = 20;
  11. protected onLoad(): void {
  12. EventManager.instance.et.on(EventManager.EventType.initOver, this.initOver, this);
  13. }
  14. initOver() {
  15. this.up()
  16. this.schedule(() => {
  17. this.up()
  18. }, 1, macro.REPEAT_FOREVER, 0)
  19. }
  20. up() {
  21. let num = parseInt(this.getComponent(Label).string)
  22. if (num < 2000) {
  23. if (this.Difficulty != 0) {
  24. this.Difficulty = 0
  25. /////////////////////////
  26. DifficultyManager.UpSpeed = 10;
  27. DifficultyManager.G = 20;
  28. DifficultyManager.Left_Right_Speed = 20;
  29. }
  30. } else if (num < 4000) {
  31. if (this.Difficulty != 1) {
  32. this.Difficulty = 1
  33. /////////////////////////
  34. DifficultyManager.UpSpeed = 15;
  35. DifficultyManager.G = 30;
  36. DifficultyManager.Left_Right_Speed = 30;
  37. }
  38. } else if (num < 6000) {
  39. if (this.Difficulty != 2) {
  40. this.Difficulty = 2
  41. /////////////////////////
  42. DifficultyManager.UpSpeed = 20;
  43. DifficultyManager.G = 40;
  44. DifficultyManager.Left_Right_Speed = 40;
  45. }
  46. }
  47. }
  48. protected start(): void {
  49. return
  50. // EventManager.instance.et.emit(EventManager.EventType.initOver);
  51. }
  52. }