Slash-The-Hordes/assets/Scripts/Services/GameTimer.ts

22 lines
490 B
TypeScript
Raw Permalink Normal View History

2022-11-08 18:45:57 +00:00
export class GameTimer {
private targetDelay: number;
private currentDelay = 0;
public constructor(targetDelay: number) {
this.targetDelay = targetDelay;
}
public gameTick(deltaTime: number): void {
this.currentDelay += deltaTime;
}
public tryFinishPeriod(): boolean {
if (this.targetDelay <= this.currentDelay) {
this.currentDelay = 0;
return true;
} else {
return false;
}
}
}