Slash-The-Hordes/assets/Scripts/Menu/Menu.ts

32 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-12-19 12:17:32 +00:00
import { Component, _decorator } from "cc";
2022-12-16 10:49:52 +00:00
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
2022-12-14 07:46:34 +00:00
import { UIButton } from "../Services/UI/Button/UIButton";
2022-12-07 09:47:46 +00:00
import { GameRunner } from "./GameRunner";
2022-12-16 10:49:52 +00:00
import { MenuModalLauncher } from "./ModalWindows/MenuModalLauncher";
2022-12-07 09:47:46 +00:00
const { ccclass, property } = _decorator;
@ccclass("Menu")
export class Menu extends Component {
2022-12-14 07:46:34 +00:00
@property(UIButton) private playBtn: UIButton;
2022-12-15 10:14:35 +00:00
@property(UIButton) private upgradeBtn: UIButton;
2022-12-16 10:49:52 +00:00
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
private menuModalLauncher: MenuModalLauncher;
2022-12-14 07:46:34 +00:00
2022-12-12 08:15:27 +00:00
public async start(): Promise<void> {
2022-12-15 10:14:35 +00:00
this.playBtn.InteractedEvent.on(this.startGame, this);
this.upgradeBtn.InteractedEvent.on(this.openUpgradesWindow, this);
2022-12-16 10:49:52 +00:00
this.menuModalLauncher = new MenuModalLauncher(this.modalWindowManager);
2022-12-07 09:47:46 +00:00
}
2022-12-15 10:14:35 +00:00
private startGame(): void {
GameRunner.Instance.playGame();
}
2022-12-16 10:49:52 +00:00
private openUpgradesWindow(): void {
this.menuModalLauncher.openUpgradesWindow();
}
2022-12-07 09:47:46 +00:00
}