mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Menu modal WIP, new settigns
This commit is contained in:
@@ -21,7 +21,7 @@ export class GameModalLauncher {
|
||||
private async showLevelUpModal(): Promise<void> {
|
||||
this.gamePauser.pause();
|
||||
const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal<LevelUpModalWindowParams, UpgradeType>(
|
||||
GameModalWindowTypes.LevelUpModal,
|
||||
GameModalWindowTypes.LevelUp,
|
||||
{ availableUpgrades: Array.from(this.upgrader.getAvailableUpgrades()), translationData: this.translationData }
|
||||
);
|
||||
this.gamePauser.resume();
|
||||
|
@@ -1,3 +1,3 @@
|
||||
export enum GameModalWindowTypes {
|
||||
LevelUpModal = "LevelUpModalWindow"
|
||||
LevelUp = "LevelUpModalWindow"
|
||||
}
|
||||
|
@@ -1,25 +1,31 @@
|
||||
import { _decorator, Component, Node, Button } from "cc";
|
||||
import { type } from "os";
|
||||
import { _decorator, Component } from "cc";
|
||||
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
|
||||
import { UIButton } from "../Services/UI/Button/UIButton";
|
||||
|
||||
import { GameRunner } from "./GameRunner";
|
||||
import { MenuModalLauncher } from "./ModalWindows/MenuModalLauncher";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("Menu")
|
||||
export class Menu extends Component {
|
||||
@property(UIButton) private playBtn: UIButton;
|
||||
@property(UIButton) private upgradeBtn: UIButton;
|
||||
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
|
||||
|
||||
private menuModalLauncher: MenuModalLauncher;
|
||||
|
||||
public async start(): Promise<void> {
|
||||
this.playBtn.InteractedEvent.on(this.startGame, this);
|
||||
this.upgradeBtn.InteractedEvent.on(this.openUpgradesWindow, this);
|
||||
|
||||
this.menuModalLauncher = new MenuModalLauncher(this.modalWindowManager);
|
||||
}
|
||||
|
||||
private startGame(): void {
|
||||
GameRunner.Instance.playGame();
|
||||
}
|
||||
|
||||
private openUpgradesWindow(): void {}
|
||||
private openUpgradesWindow(): void {
|
||||
this.menuModalLauncher.openUpgradesWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
12
assets/Scripts/Menu/ModalWindows.meta
Normal file
12
assets/Scripts/Menu/ModalWindows.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "ee6e2e1a-723c-4e5d-a689-95f478d0fc97",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
10
assets/Scripts/Menu/ModalWindows/MenuModalLauncher.ts
Normal file
10
assets/Scripts/Menu/ModalWindows/MenuModalLauncher.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ModalWindowManager } from "../../Services/ModalWindowSystem/ModalWindowManager";
|
||||
import { MenuModalWindowTypes } from "./MenuModalWindowTypes";
|
||||
|
||||
export class MenuModalLauncher {
|
||||
public constructor(private modalWindowManager: ModalWindowManager) {}
|
||||
|
||||
public async openUpgradesWindow(): Promise<void> {
|
||||
await this.modalWindowManager.showModal(MenuModalWindowTypes.Upgrades, {});
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fc6227d2-7b1d-49f3-85a2-abdb82e1638b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
3
assets/Scripts/Menu/ModalWindows/MenuModalWindowTypes.ts
Normal file
3
assets/Scripts/Menu/ModalWindows/MenuModalWindowTypes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export enum MenuModalWindowTypes {
|
||||
Upgrades = "UpgradesModalWindow"
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5c0f41ea-f404-452a-b17b-0ecdfd0a5f71",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
12
assets/Scripts/Menu/ModalWindows/Upgrades.meta
Normal file
12
assets/Scripts/Menu/ModalWindows/Upgrades.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "332aac81-54d3-4914-bc63-2efdecaef4b2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
20
assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts
Normal file
20
assets/Scripts/Menu/ModalWindows/Upgrades/UpgradeUI.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("UpgradeUI")
|
||||
export class UpgradeUI extends Component {
|
||||
@property(Prefab) private levelPointPrefab: Prefab;
|
||||
@property(Node) private levelPointsParent: Node;
|
||||
@property(Label) private title: Label;
|
||||
@property(Label) private description: Label;
|
||||
|
||||
public init(titleText: string, descriptionText: string, levels: number): void {
|
||||
for (let i = 0; i < levels; i++) {
|
||||
const node: Node = instantiate(this.levelPointPrefab);
|
||||
node.setParent(this.levelPointsParent);
|
||||
}
|
||||
|
||||
this.title.string = titleText;
|
||||
this.description.string = descriptionText;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "76edae8c-16ba-482d-91fd-2833991475ac",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
import { instantiate, Prefab, _decorator, Node } from "cc";
|
||||
import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
|
||||
import { UpgradeUI } from "./UpgradeUI";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("UpgradesModalWindow")
|
||||
export class UpgradesModalWindow extends ModalWindow<Empty, Empty> {
|
||||
@property(Prefab) upgradeButtonPrefab: Prefab;
|
||||
@property(Node) upgradeButtonParent: Node;
|
||||
|
||||
public setup(params: Empty): void {
|
||||
for (let index = 0; index < 6; index++) {
|
||||
const upgradeButton: Node = instantiate(this.upgradeButtonPrefab);
|
||||
upgradeButton.getComponent(UpgradeUI).init("Title", "Description", 5);
|
||||
upgradeButton.setParent(this.upgradeButtonParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Empty {}
|
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"854a4b66-9084-4ecd-814f-0300f12f7ff3","files":[],"subMetas":{},"userData":{}}
|
@@ -1,15 +1,21 @@
|
||||
import { Animation, Component, _decorator } from "cc";
|
||||
import { UIButton } from "../UI/Button/UIButton";
|
||||
import { delay } from "../Utils/AsyncUtils";
|
||||
|
||||
const { property } = _decorator;
|
||||
|
||||
export abstract class ModalWindow<TParam, TResult> extends Component {
|
||||
@property(Animation) private animation: Animation;
|
||||
@property(UIButton) private closeButton: UIButton;
|
||||
@property(UIButton) private backgroundCloseButton: UIButton;
|
||||
|
||||
private result: TResult;
|
||||
private isDismissed = false;
|
||||
|
||||
public async runAsync(params?: TParam): Promise<TResult> {
|
||||
this.closeButton?.InteractedEvent.on(() => this.dismiss(), this);
|
||||
this.backgroundCloseButton?.InteractedEvent.on(() => this.dismiss(), this);
|
||||
|
||||
this.setup(params);
|
||||
this.animation?.play("open");
|
||||
while (!this.isDismissed) await delay(100);
|
||||
|
Reference in New Issue
Block a user