1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 'use strict';
- import MainMenuScene from '../views/main-menu-scene';
- import { PhaserScene } from '../../common/utils/const/phaser-scene-enum';
- import GameParams from '../../common/game-params';
- import GameControllerPnp from '../../game/control/game-controller-pnp';
- import SocketService from '../../common/socket-service';
- export default class MenuController {
- constructor(phaserEngine) {
- this.phaserEngine = phaserEngine;
- this.socketService = new SocketService();
- this.mainMenuScene = new MainMenuScene(this.menuEventListener());
- }
- displayMainMenu() {
- this.phaserEngine.scene.add(PhaserScene.MAIN_MENU,this.mainMenuScene);
- this.phaserEngine.scene.start(PhaserScene.MAIN_MENU);
- }
- tryConnect(username) {
- return this.socketService.connect(username);
- }
- onRequestDisconnection() {
- this.socketService.disconnect();
- }
- menuEventListener() {
- return {
- onNewPnpGame: this.onNewPnpGame.bind(this),
- onOnlineGamesListRequested: this.onOnlineGamesListRequested.bind(this),
- onTryConnect: this.tryConnect.bind(this),
- onRequestDisconnection: this.onRequestDisconnection.bind(this),
- };
- }
- onNewPnpGame(pBlueName, pRedName, gameMode, advancedRules) {
- console.log("onNewPnpGame this : " + this);
- let gameParams = new GameParams(pBlueName,pRedName,gameMode,advancedRules);
- let gameControllerPnp = new GameControllerPnp(this.phaserEngine, gameParams);
- gameControllerPnp.displayDeckBuilding();
- }
- onOnlineGamesListRequested(playername) {
- return this.socketService.getGamesList(playername);
- }
- }
|