mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-12-08 21:59:26 +00:00
new structure, spawner, rebind
This commit is contained in:
21
assets/Scripts/Services/GameTimer.ts
Normal file
21
assets/Scripts/Services/GameTimer.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user