mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-10 00:56:06 +00:00
Modal windows
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { Component, Label, ProgressBar, _decorator } from "cc";
|
||||
import { UIButton } from "../../Services/UI/Button/UIButton";
|
||||
import { GameModalLauncher } from "../ModalWIndows/GameModalLauncher";
|
||||
import { Player } from "../Unit/Player/Player";
|
||||
import { UnitLevel } from "../Unit/UnitLevel";
|
||||
|
||||
@@ -8,20 +10,31 @@ const { ccclass, property } = _decorator;
|
||||
export class GameUI extends Component {
|
||||
@property(ProgressBar) private xpBar: ProgressBar;
|
||||
@property(Label) private timeAliveText: Label;
|
||||
@property(UIButton) private pauseBtn: UIButton;
|
||||
|
||||
private playerLevel: UnitLevel;
|
||||
private modalLauncher: GameModalLauncher;
|
||||
|
||||
public init(player: Player): void {
|
||||
public init(player: Player, modalLauncher: GameModalLauncher): void {
|
||||
this.playerLevel = player.Level;
|
||||
this.modalLauncher = modalLauncher;
|
||||
|
||||
this.playerLevel.XpAddedEvent.on(this.updateProgressBar, this);
|
||||
this.playerLevel.LevelUpEvent.on(this.updateProgressBar, this);
|
||||
this.xpBar.progress = 0;
|
||||
|
||||
this.pauseBtn.InteractedEvent.on(this.showPauseWindow, this);
|
||||
}
|
||||
|
||||
private updateProgressBar(): void {
|
||||
this.xpBar.progress = this.playerLevel.XP / this.playerLevel.RequiredXP;
|
||||
}
|
||||
|
||||
private showPauseWindow(): void {
|
||||
console.log("Show pause window");
|
||||
this.modalLauncher.showPauseModal();
|
||||
}
|
||||
|
||||
public updateTimeAlive(timeAlive: number): void {
|
||||
this.timeAliveText.string = `${Math.floor(timeAlive)}`;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ export class LevelUpSkill extends Component {
|
||||
public init(skillType: UpgradeType, translationData: TranslationData): void {
|
||||
this.skillType = skillType;
|
||||
this.skillTitle.string = `${translationData[`${skillType}_TITLE`]}`;
|
||||
this.node.on(NodeEventType.MOUSE_DOWN, this.chooseSkill, this);
|
||||
this.node.on(NodeEventType.TOUCH_START, this.chooseSkill, this);
|
||||
}
|
||||
|
||||
public get ChooseSkillEvent(): ISignal<UpgradeType> {
|
||||
|
Reference in New Issue
Block a user