Pause menu
This commit is contained in:
parent
ea2d3b41b2
commit
f1148e1d07
57
src/classes/gui/GamePausedDialog.ts
Normal file
57
src/classes/gui/GamePausedDialog.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ import TowerPanel, { VisualGemSlot } from '../classes/gui/TowerPanel';
|
|||||||
import Gem from '../classes/game/Gem';
|
import Gem from '../classes/game/Gem';
|
||||||
import EndGameDialog from '../classes/gui/EndGameDialog';
|
import EndGameDialog from '../classes/gui/EndGameDialog';
|
||||||
import HighScoreDialog, { HighScoreDialogButtons } from '../classes/gui/HighScoreDialog';
|
import HighScoreDialog, { HighScoreDialogButtons } from '../classes/gui/HighScoreDialog';
|
||||||
|
import GamePausedDialog from '../classes/gui/GamePausedDialog';
|
||||||
|
|
||||||
enum RoundMode {
|
enum RoundMode {
|
||||||
Purchase = 0,
|
Purchase = 0,
|
||||||
@ -289,7 +290,8 @@ export class GameScene extends Scene {
|
|||||||
this.ticker.start();
|
this.ticker.start();
|
||||||
}
|
}
|
||||||
public ShowPauseDialog() {
|
public ShowPauseDialog() {
|
||||||
console.warn("Pause dialog doesn't exist.");
|
const gamePausedDialog = new GamePausedDialog();
|
||||||
|
gamePausedDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ShowEndgameDialog(lost) {
|
private async ShowEndgameDialog(lost) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user