Explorar o código

rename-file and create mvc dirs

Johan LE BAUT %!s(int64=5) %!d(string=hai) anos
pai
achega
2e9e384831

+ 0 - 18
src/GameCreator.js

@@ -1,18 +0,0 @@
-'use strict';
-import HeroFactory from './heroes/HeroFactory';
-import PhaserGame from './view/PhaserGame';
-import { Faction } from './model/const/faction-enum';
-
-export default class GameCreator {
-  constructor() {
-    let heroFactory = new HeroFactory();
-
-
-    let heroesSet = heroFactory.getFactionRandom(Faction.MECA);
-    console.log('Faction Set : ', heroesSet);
-
-    let phaser = new PhaserGame(heroesSet);
-
-
-  }
-}

+ 20 - 0
src/game/controller/game-generator.js

@@ -0,0 +1,20 @@
+'use strict';
+import HeroFactory from '../model/hero-factory';
+import PhaserGame from '../../phaser-engine';
+import { Faction } from '../model/const/faction-enum';
+
+export default class GameGenerator {
+  constructor(gameType) {
+    let heroFactory = new HeroFactory();
+
+
+    this.heroesSet = heroFactory.getFactionRandom(Faction.MECA);
+    console.log('Faction Set : ', this.heroesSet);
+
+
+
+  }
+  getHeroesSet(){
+    return this.heroesSet;
+  }
+}

+ 0 - 0
src/view/WorldGameView.js → src/game/controller/scenes/game-world-scene.js


+ 0 - 0
src/model/const/faction-enum.js → src/game/model/const/faction-enum.js


+ 6 - 0
src/game/model/const/game-type-enum.js

@@ -0,0 +1,6 @@
+'use strict';
+
+export const GameType = Object.freeze({
+    PASSNPLAY : "PassNPlay",
+    MULTI: "Multi"
+  });

+ 0 - 0
src/heroes/HeroAbility.js → src/game/model/hero-ability.js


+ 3 - 3
src/heroes/HeroFactory.js → src/game/model/hero-factory.js

@@ -1,7 +1,7 @@
 'use strict';
-import allHeroesJson from "../assets/all-heroes.json";
-import Hero from './Hero';
-import HeroAbility from './HeroAbility';
+import allHeroesJson from "../../assets/all-heroes.json";
+import Hero from './hero';
+import HeroAbility from './hero-ability';
 
 export default class HeroFactory {
   constructor() {

+ 0 - 0
src/heroes/Hero.js → src/game/model/hero.js


+ 3 - 13
src/main.js

@@ -2,22 +2,11 @@
 
 /* eslint-disable no-unused-vars */
 /* eslint-disable no-console */
-import Phaser from "phaser";
-import logoImg from "./assets/twelveHeroes_cover.png";
 
 import '@babel/polyfill';
 
-import GameCreator from './GameCreator';
+import PhaserEngine from './phaser-engine';
 
-// const Faction = {
-//   HUMANS: 'Humans',
-//   ELVES: 'Elves',
-//   ORCS: 'Orcs',
-//   MECA: 'Meca',
-//   NONE: 'None',
-
-// };
-// Object.freeze(Faction);
 var app = {
   // Application Constructor
   initialize: function() {
@@ -30,7 +19,8 @@ var app = {
   // 'pause', 'resume', etc.
   onDeviceReady: function() {
       this.receivedEvent('deviceready');
-      let gameCreator = new GameCreator();
+      let phaserEngine = new PhaserEngine();
+      phaserEngine.start();
   },
 
   // Update DOM on a Received Event

+ 33 - 0
src/menu/controller/scenes/main-menu-scene.js

@@ -0,0 +1,33 @@
+'use strict';
+import GameGenerator from '../../../game/controller/game-generator';
+import {GameType} from '../../../game/model/const/game-type-enum';
+import logo from '../../../assets/twelveHeroes_cover.png';
+export default class MainMenu extends Phaser.Scene {
+
+  constructor() {
+    super({ key: 'MainMenu', active: false });
+  }
+
+  init(data){
+    console.log('Init');
+  }
+  preload() {
+    console.log('Preload');
+    this.load.image('logo', logo);
+  }
+
+  create() {
+    console.log('create');
+    let logo = this.add.sprite(0,0,'logo');
+    logo.setOrigin(0,0);
+    setTimeout(() => {
+      console.log('timeout end');
+      let gameGen = new GameGenerator(GameType.PASSNPLAY);
+      this.scene.start('World',{heroesSet:gameGen.getHeroesSet()});
+    }, 5000);
+  }
+
+  update() {
+
+  }
+}

+ 25 - 0
src/phaser-engine.js

@@ -0,0 +1,25 @@
+import Phaser from "phaser";
+
+import World from './game/controller/scenes/game-world-scene';
+import MainMenu from'./menu/controller/scenes/main-menu-scene';
+
+export default class PhaserEngine {
+  constructor() {
+
+    // our game's configuration
+    let config = {
+      type: Phaser.CANVAS,
+      width: 1200,
+      height: 500,
+      scene: [MainMenu,World],
+      backgroundColor: 'rgba(34,139,34 ,1 )'
+    };
+
+    this.gameEngine = new Phaser.Game(config);
+  }
+
+  start() {
+    this.gameEngine.scene.start('MainMenu');
+  }
+
+}

+ 0 - 25
src/view/PhaserGame.js

@@ -1,25 +0,0 @@
-import Phaser from "phaser";
-// import logoImg from "../assets/twelveHeroes_cover.png";
-
-import World from './WorldGameView';
-
-export default class PhaserGameScene {
-  constructor(heroesSet) {
-    this.heroesSet = heroesSet;
-
-
-    // our game's configuration
-    let config = {
-      type: Phaser.AUTO,  //Phaser will decide how to render our game (WebGL or Canvas)
-      width: 1200, // game width
-      height: 500, // game height
-      scene: World, // our newly created scene
-      backgroundColor: 'rgba(34,139,34 ,1 )'
-    };
-
-    // create the game, and pass it the configuration
-    this.game = new Phaser.Game(config);
-    this.game.scene.start('World',{heroesSet:this.heroesSet});
-  }
-
-}