Putting the name in GameManager rather than passing it from scene to scene.
This commit is contained in:
parent
5601e5e134
commit
76b745ebea
@ -15,14 +15,16 @@ export class GameManager {
|
|||||||
status: number;
|
status: number;
|
||||||
private ConnexionInstance: Connexion;
|
private ConnexionInstance: Connexion;
|
||||||
private currentGameScene: GameScene;
|
private currentGameScene: GameScene;
|
||||||
|
private playerName: string;
|
||||||
SimplePeer : SimplePeerInterface;
|
SimplePeer : SimplePeerInterface;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.status = StatusGameManagerEnum.IN_PROGRESS;
|
this.status = StatusGameManagerEnum.IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(email:string) {
|
connect(name:string) {
|
||||||
this.ConnexionInstance = new Connexion(email, this);
|
this.playerName = name;
|
||||||
|
this.ConnexionInstance = new Connexion(name, this);
|
||||||
ConnexionInstance = this.ConnexionInstance;
|
ConnexionInstance = this.ConnexionInstance;
|
||||||
return this.ConnexionInstance.createConnexion().then(() => {
|
return this.ConnexionInstance.createConnexion().then(() => {
|
||||||
this.SimplePeer = new SimplePeer(ConnexionInstance);
|
this.SimplePeer = new SimplePeer(ConnexionInstance);
|
||||||
@ -57,6 +59,10 @@ export class GameManager {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayerName(): string {
|
||||||
|
return this.playerName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gameManager = new GameManager();
|
export const gameManager = new GameManager();
|
@ -5,7 +5,6 @@ import {DEBUG_MODE, RESOLUTION, ROOM, ZOOM_LEVEL} from "../../Enum/EnvironmentVa
|
|||||||
import Tile = Phaser.Tilemaps.Tile;
|
import Tile = Phaser.Tilemaps.Tile;
|
||||||
import {ITiledMap, ITiledTileSet} from "../Map/ITiledMap";
|
import {ITiledMap, ITiledTileSet} from "../Map/ITiledMap";
|
||||||
import {cypressAsserter} from "../../Cypress/CypressAsserter";
|
import {cypressAsserter} from "../../Cypress/CypressAsserter";
|
||||||
import { GameSceneInitDataInterface } from "./GameSceneInitDataInterface";
|
|
||||||
|
|
||||||
export const GameSceneName = "GameScene";
|
export const GameSceneName = "GameScene";
|
||||||
export enum Textures {
|
export enum Textures {
|
||||||
@ -29,7 +28,6 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||||||
map: ITiledMap;
|
map: ITiledMap;
|
||||||
startX = (window.innerWidth / 2) / RESOLUTION;
|
startX = (window.innerWidth / 2) / RESOLUTION;
|
||||||
startY = (window.innerHeight / 2) / RESOLUTION;
|
startY = (window.innerHeight / 2) / RESOLUTION;
|
||||||
playerName: string;
|
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -69,8 +67,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//hook initialisation
|
//hook initialisation
|
||||||
init(data: GameSceneInitDataInterface) {
|
init() {
|
||||||
this.playerName = data.name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//hook create scene
|
//hook create scene
|
||||||
@ -168,7 +165,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||||||
this,
|
this,
|
||||||
this.startX,
|
this.startX,
|
||||||
this.startY,
|
this.startY,
|
||||||
this.playerName
|
this.GameManager.getPlayerName()
|
||||||
);
|
);
|
||||||
this.CurrentPlayer.initAnimation();
|
this.CurrentPlayer.initAnimation();
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export interface GameSceneInitDataInterface {
|
|
||||||
name: string
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user