Slash-The-Hordes/assets/Scripts/Game/ModalWIndows/GameModalLauncher.ts

28 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-11-25 11:00:09 +00:00
import { ModalWindowManager } from "../../Services/ModalWindowSystem/ModalWindowManager";
import { Pauser } from "../Pauser";
2022-11-28 10:49:16 +00:00
import { Player } from "../Unit/Player/Player";
2022-11-25 11:00:09 +00:00
import { Upgrader } from "../Upgrades/Upgrader";
import { UpgradeType } from "../Upgrades/UpgradeType";
import { GameModalWindowTypes } from "./GameModalWindowTypes";
export class GameModalLauncher {
public constructor(
private modalWindowManager: ModalWindowManager,
private player: Player,
private gamePauser: Pauser,
private upgrader: Upgrader
) {
this.player.Level.LevelUpEvent.on(this.showLevelUpModal, this);
}
private async showLevelUpModal(): Promise<void> {
this.gamePauser.pause();
const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal<UpgradeType[], UpgradeType>(
GameModalWindowTypes.LevelUpModal,
Array.from(this.upgrader.getAvailableUpgrades())
);
this.gamePauser.resume();
this.upgrader.upgradeSkill(skillToUpgrade);
}
}