used the vent system to remove the dependency of Player on Connexion

This commit is contained in:
kharhamel 2020-05-02 16:54:52 +02:00
parent d2f94e9406
commit ad65de75fd
3 changed files with 22 additions and 13 deletions

View file

@ -9,7 +9,11 @@ export enum StatusGameManagerEnum {
CURRENT_USER_CREATED = 2
}
export let ConnexionInstance : ConnexionInterface;
export interface HasMovedEvent {
direction: string;
x: number;
y: number;
}
export class GameManager {
status: number;
@ -23,9 +27,8 @@ export class GameManager {
connect(email:string) {
this.ConnexionInstance = new Connexion(email, this);
ConnexionInstance = this.ConnexionInstance;
return this.ConnexionInstance.createConnexion().then(() => {
this.SimplePeer = new SimplePeer(ConnexionInstance);
this.SimplePeer = new SimplePeer(this.ConnexionInstance);
});
}
@ -57,6 +60,10 @@ export class GameManager {
console.error(e);
}
}
pushPlayerPosition(event: HasMovedEvent) {
this.ConnexionInstance.sharePosition(event.x, event.y, event.direction);
}
}
export const gameManager = new GameManager();