mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Game ui
This commit is contained in:
22
assets/Scripts/Game/UI/GameUI.ts
Normal file
22
assets/Scripts/Game/UI/GameUI.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Component, ProgressBar, _decorator } from "cc";
|
||||
import { Player } from "../Player/Player";
|
||||
import { UnitLevel } from "../Player/UnitLevel";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GameUI")
|
||||
export class GameUI extends Component {
|
||||
@property(ProgressBar) private xpBar: ProgressBar;
|
||||
|
||||
private playerLevel: UnitLevel;
|
||||
|
||||
public init(player: Player): void {
|
||||
this.playerLevel = player.Level;
|
||||
this.playerLevel.XpAddedEvent.on(this.updateProgressBar, this);
|
||||
this.playerLevel.LevelUpEvent.on(this.updateProgressBar, this);
|
||||
this.xpBar.progress = 0;
|
||||
}
|
||||
|
||||
private updateProgressBar(): void {
|
||||
this.xpBar.progress = this.playerLevel.XP / this.playerLevel.RequiredXP;
|
||||
}
|
||||
}
|
9
assets/Scripts/Game/UI/GameUI.ts.meta
Normal file
9
assets/Scripts/Game/UI/GameUI.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2e393e26-6f0c-4667-ae26-c1d4e1026d08",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user