main-menu-scene.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. import {GameDeckMode} from '../../common/utils/const/game-deck-mode-enum';
  3. import { PhaserScene } from '../../common/utils/const/phaser-scene-enum';
  4. import Phaser from 'phaser';
  5. import * as Utils from '../../common/utils/prompt-renderer';
  6. export default class MainMenuScene extends Phaser.Scene {
  7. constructor(menuEventListener) {
  8. super({ key: PhaserScene.MAIN_MENU, active: false });
  9. this.menuEventListener = menuEventListener;
  10. }
  11. preload() {
  12. console.log('Preload');
  13. this.load.image('game-cover', '../../assets/twelveHeroes_cover.png');
  14. }
  15. create() {
  16. console.log('create');
  17. let logo = this.add.image(0,0,'game-cover');
  18. logo.setOrigin(0,0);
  19. //this.add.dom
  20. // TODO : Display main menu
  21. // Create new scenes : Local player room / Multi player room
  22. // Pass to them the event listener
  23. // On local player room, user can enter player names, selected color, game deck mode & rules
  24. // FOR TESTING
  25. this.fakeNewPnpGameSelected();
  26. }
  27. update() {
  28. }
  29. fakeNewPnpGameSelected() {
  30. setTimeout(() => {
  31. let pBlueName = prompt("Player blue name : ");
  32. let pRedName = prompt("Player red name : ");
  33. let gameDeckModeOptions = Object.values(GameDeckMode);
  34. let gameDeckMode = Utils.promptSelectAmongOptions("Select Deck Mode", gameDeckModeOptions);
  35. let advancedRules = [];
  36. console.log("Calling listener");
  37. this.menuEventListener.onNewPnpGame(pBlueName, pRedName, gameDeckMode, advancedRules);
  38. }, 1000);
  39. }
  40. }