Pause menu

This commit is contained in:
Dalibor Čarapić 2025-02-10 16:50:26 +01:00
parent ea2d3b41b2
commit f1148e1d07
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,57 @@
import * as PIXI from 'pixi.js';
import ModalDialogBase from './ModalDialog';
import Button, { ButtonTexture } from './Button';
import { Engine } from '../Bastion';
import { MissionPickerScene } from '../../scenes/MissionPicker';
import { GameScene } from '../../scenes/Game';
import KeyboardManager from '../game/KeyboardManager';
export default class GamePausedDialog extends ModalDialogBase {
private btnMainMenu: Button;
private btnRetry: Button;
private btnContinue: Button;
private _unsubKeypress: () => void;
constructor() {
super([]);
this._unsubKeypress = KeyboardManager.onKeyPressed(this.onContinueClick.bind(this));
}
protected override createContent(): PIXI.Container {
const container = new PIXI.Container();
this.btnMainMenu = new Button(new PIXI.Rectangle(0, 0, 300, 60), 'Main Menu', ButtonTexture.Button01);
this.btnMainMenu.onClick = this.onMainMenuClick.bind(this);
container.addChild(this.btnMainMenu.container);
this.btnRetry = new Button(new PIXI.Rectangle(0, 70, 300, 60), 'Retry', ButtonTexture.Button01);
this.btnRetry.onClick = this.onRetryClick.bind(this);
container.addChild(this.btnRetry.container);
this.btnContinue = new Button(new PIXI.Rectangle(0, 140, 300, 60), 'Continue', ButtonTexture.Button01);
this.btnContinue.onClick = this.onContinueClick.bind(this);
container.addChild(this.btnContinue.container);
return container;
}
private onMainMenuClick(): void {
this.close();
this._unsubKeypress();
Engine.GameScene.destroy();
Engine.GameMaster.changeScene(new MissionPickerScene());
}
private onRetryClick(): void {
const missionName = Engine.GameScene.mission.name;
this.close();
this._unsubKeypress();
Engine.GameScene.destroy();
Engine.GameMaster.changeScene(new MissionPickerScene());
Engine.GameMaster.changeScene(new GameScene(missionName));
Engine.NotificationManager.Notify('Retrying mission.', 'green');
}
private onContinueClick(): void {
this.close();
Engine.GameScene.UnpauseGame();
}
}

View File

@ -18,6 +18,7 @@ import TowerPanel, { VisualGemSlot } from '../classes/gui/TowerPanel';
import Gem from '../classes/game/Gem';
import EndGameDialog from '../classes/gui/EndGameDialog';
import HighScoreDialog, { HighScoreDialogButtons } from '../classes/gui/HighScoreDialog';
import GamePausedDialog from '../classes/gui/GamePausedDialog';
enum RoundMode {
Purchase = 0,
@ -289,7 +290,8 @@ export class GameScene extends Scene {
this.ticker.start();
}
public ShowPauseDialog() {
console.warn("Pause dialog doesn't exist.");
const gamePausedDialog = new GamePausedDialog();
gamePausedDialog.show();
}
private async ShowEndgameDialog(lost) {