Refactor to include connexion
This commit is contained in:
parent
5d463d097a
commit
bac1e804ad
8 changed files with 88 additions and 24 deletions
31
front/src/Phaser/Game/GameManager.ts
Normal file
31
front/src/Phaser/Game/GameManager.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {GameSceneInterface, GameScene} from "./GameScene";
|
||||
import {ROOM} from "../../Enum/EnvironmentVariable"
|
||||
import {Connexion} from "../../Connexion";
|
||||
|
||||
export let ConnexionInstance : Connexion;
|
||||
|
||||
export interface GameManagerInterface {
|
||||
GameScenes: Array<GameSceneInterface>;
|
||||
|
||||
sharedUserPosition(UserPositions: any): void;
|
||||
}
|
||||
export class GameManager implements GameManagerInterface {
|
||||
GameScenes: Array<GameSceneInterface> = [];
|
||||
|
||||
constructor() {
|
||||
this.configureGame();
|
||||
ConnexionInstance = new Connexion("test@gmail.com", this);
|
||||
}
|
||||
|
||||
configureGame() {
|
||||
ROOM.forEach((roomId) => {
|
||||
let newGame = new GameScene(roomId, this);
|
||||
this.GameScenes.push(newGame);
|
||||
});
|
||||
}
|
||||
|
||||
sharedUserPosition(UserPositions: any) {
|
||||
let Game: GameSceneInterface = this.GameScenes.find((Game: GameSceneInterface) => Game.RoomId === UserPositions.roomId);
|
||||
Game.sharedUserPosition(UserPositions)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue