mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 00:26:04 +00:00
Added timer
This commit is contained in:
@@ -48,6 +48,7 @@ export class Game extends Component {
|
||||
private gamePauser: Pauser = new Pauser();
|
||||
|
||||
private static instance: Game;
|
||||
private timeAlive = 0;
|
||||
|
||||
public static get Instance(): Game {
|
||||
return this.instance;
|
||||
@@ -136,6 +137,9 @@ export class Game extends Component {
|
||||
this.diagonalProjectileLauncher.gameTick(deltaTime);
|
||||
this.background.gameTick();
|
||||
|
||||
this.timeAlive += deltaTime;
|
||||
this.gameUI.updateTimeAlive(this.timeAlive);
|
||||
|
||||
this.camera.node.worldPosition = this.player.node.worldPosition;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, ProgressBar, _decorator } from "cc";
|
||||
import { Component, Label, ProgressBar, _decorator } from "cc";
|
||||
import { Player } from "../Unit/Player/Player";
|
||||
import { UnitLevel } from "../Unit/UnitLevel";
|
||||
|
||||
@@ -7,6 +7,7 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass("GameUI")
|
||||
export class GameUI extends Component {
|
||||
@property(ProgressBar) private xpBar: ProgressBar;
|
||||
@property(Label) private timeAliveText: Label;
|
||||
|
||||
private playerLevel: UnitLevel;
|
||||
|
||||
@@ -20,4 +21,8 @@ export class GameUI extends Component {
|
||||
private updateProgressBar(): void {
|
||||
this.xpBar.progress = this.playerLevel.XP / this.playerLevel.RequiredXP;
|
||||
}
|
||||
|
||||
public updateTimeAlive(timeAlive: number): void {
|
||||
this.timeAliveText.string = `${Math.floor(timeAlive)}`;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user