mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-28 09:24:16 +00:00
35 lines
900 B
TypeScript
35 lines
900 B
TypeScript
import { GameView } from "../../../core/game/GameView";
|
|
import { TransformHandler } from "../TransformHandler";
|
|
import { Layer } from "./Layer";
|
|
|
|
export class SpawnTimer implements Layer {
|
|
constructor(
|
|
private game: GameView,
|
|
private transformHandler: TransformHandler,
|
|
) {}
|
|
|
|
init() {}
|
|
tick() {}
|
|
shouldTransform(): boolean {
|
|
return false;
|
|
}
|
|
|
|
renderLayer(context: CanvasRenderingContext2D) {
|
|
if (!this.game.inSpawnPhase()) {
|
|
return;
|
|
}
|
|
|
|
const barHeight = 15;
|
|
const barBackgroundWidth = this.transformHandler.width();
|
|
|
|
const ratio = this.game.ticks() / this.game.config().numSpawnPhaseTurns();
|
|
|
|
// Draw bar background
|
|
context.fillStyle = "rgba(0, 0, 0, 0.5)";
|
|
context.fillRect(0, 0, barBackgroundWidth, barHeight);
|
|
|
|
context.fillStyle = "rgba(0, 128, 255, 0.7)";
|
|
context.fillRect(0, 0, barBackgroundWidth * ratio, barHeight);
|
|
}
|
|
}
|