Modal windows

This commit is contained in:
Martin
2022-12-21 14:08:49 +01:00
parent b4abb4df21
commit f3eb520300
25 changed files with 5287 additions and 263 deletions

View File

@@ -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)}`;
}

View File

@@ -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> {