DifficultyManager.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Label, macro, Node, NodeEventType } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('DifficultyManager')
  4. export class DifficultyManager extends Component {
  5. Difficulty: number = -1
  6. static UpSpeed: number = 10;
  7. static G: number = 20;
  8. protected start(): void {
  9. this.schedule(() => {
  10. let num = parseInt(this.getComponent(Label).string)
  11. if (num < 50) {
  12. if (this.Difficulty != 0) {
  13. this.Difficulty = 0
  14. /////////////////////////
  15. DifficultyManager.UpSpeed = 10;
  16. DifficultyManager.G = 20;
  17. }
  18. } else if (num < 100) {
  19. if (this.Difficulty != 1) {
  20. this.Difficulty = 1
  21. /////////////////////////
  22. DifficultyManager.UpSpeed = 15;
  23. DifficultyManager.G = 30;
  24. }
  25. } else if (num < 150) {
  26. if (this.Difficulty != 2) {
  27. this.Difficulty = 2
  28. /////////////////////////
  29. DifficultyManager.UpSpeed = 20;
  30. DifficultyManager.G = 40;
  31. }
  32. }
  33. }, 1, macro.REPEAT_FOREVER, 0)
  34. }
  35. }