import { _decorator, Component, Label, macro, Node, NodeEventType } from 'cc'; import { EventManager } from './EventManager'; import { DEBUG } from 'cc/env'; const { ccclass, property } = _decorator; @ccclass('DifficultyManager') export class DifficultyManager extends Component { Difficulty: number = -1 static UpSpeed: number = 10; static G: number = 0; static Left_Right_Speed: number = 20; protected onLoad(): void { EventManager.instance.et.on(EventManager.EventType.initOver, this.initOver, this); } initOver() { this.up() this.schedule(() => { this.up() }, 1, macro.REPEAT_FOREVER, 0) } up() { let num = parseInt(this.getComponent(Label).string) if (num < 2000) { if (this.Difficulty != 0) { this.Difficulty = 0 ///////////////////////// DifficultyManager.UpSpeed = 10; DifficultyManager.G = 20; DifficultyManager.Left_Right_Speed = 20; } } else if (num < 4000) { if (this.Difficulty != 1) { this.Difficulty = 1 ///////////////////////// DifficultyManager.UpSpeed = 15; DifficultyManager.G = 30; DifficultyManager.Left_Right_Speed = 30; } } else if (num < 6000) { if (this.Difficulty != 2) { this.Difficulty = 2 ///////////////////////// DifficultyManager.UpSpeed = 20; DifficultyManager.G = 40; DifficultyManager.Left_Right_Speed = 40; } } } protected start(): void { return // EventManager.instance.et.emit(EventManager.EventType.initOver); } }