2023-01-02 09:56:41 +00:00
|
|
|
import { Canvas, Component, _decorator } from "cc";
|
|
|
|
import { AppRoot } from "../AppRoot/AppRoot";
|
|
|
|
import { requireAppRootAsync } from "../AppRoot/AppRootUtils";
|
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-31 12:32:40 +00:00
|
|
|
import { OpenCloseAnimator } from "../Utils/OpenCloseAnimator";
|
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-21 13:08:49 +00:00
|
|
|
@property(UIButton) private audioSettingsBtn: UIButton;
|
2023-01-02 09:56:41 +00:00
|
|
|
@property(Canvas) private menuCanvas: Canvas;
|
2022-12-16 10:49:52 +00:00
|
|
|
|
|
|
|
private menuModalLauncher: MenuModalLauncher;
|
2022-12-14 07:46:34 +00:00
|
|
|
|
2022-12-12 08:15:27 +00:00
|
|
|
public async start(): Promise<void> {
|
2023-01-02 09:56:41 +00:00
|
|
|
requireAppRootAsync();
|
|
|
|
this.menuCanvas.cameraComponent = AppRoot.Instance.MainCamera;
|
|
|
|
|
2022-12-15 10:14:35 +00:00
|
|
|
this.playBtn.InteractedEvent.on(this.startGame, this);
|
|
|
|
this.upgradeBtn.InteractedEvent.on(this.openUpgradesWindow, this);
|
2022-12-21 13:08:49 +00:00
|
|
|
this.audioSettingsBtn.InteractedEvent.on(this.openAudioSettingsWindow, this);
|
2022-12-16 10:49:52 +00:00
|
|
|
|
2023-01-02 09:56:41 +00:00
|
|
|
this.menuModalLauncher = new MenuModalLauncher(AppRoot.Instance.ModalWindowManager);
|
2022-12-07 09:47:46 +00:00
|
|
|
}
|
2022-12-15 10:14:35 +00:00
|
|
|
|
|
|
|
private startGame(): void {
|
2023-01-02 09:56:41 +00:00
|
|
|
AppRoot.Instance.ScreenFader.playOpen();
|
2022-12-15 10:14:35 +00:00
|
|
|
GameRunner.Instance.playGame();
|
|
|
|
}
|
|
|
|
|
2022-12-16 10:49:52 +00:00
|
|
|
private openUpgradesWindow(): void {
|
|
|
|
this.menuModalLauncher.openUpgradesWindow();
|
|
|
|
}
|
2022-12-21 13:08:49 +00:00
|
|
|
|
|
|
|
private openAudioSettingsWindow(): void {
|
|
|
|
this.menuModalLauncher.openAudioSettingsWindow();
|
|
|
|
}
|
2022-12-07 09:47:46 +00:00
|
|
|
}
|