Start visio with user colision
When user enter in colision with other colision, webrtc start visio
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {GameSceneInterface, GameScene} from "./GameScene";
|
||||
import {ROOM} from "../../Enum/EnvironmentVariable"
|
||||
import {Connexion, ConnexionInterface, ListMessageUserPositionInterface} from "../../Connexion";
|
||||
import {SimplePeer} from "../../WebRtc/SimplePeer";
|
||||
import {SimplePeerInterface, SimplePeer} from "../../WebRtc/SimplePeer";
|
||||
|
||||
export enum StatusGameManagerEnum {
|
||||
IN_PROGRESS = 1,
|
||||
@@ -13,12 +13,15 @@ export let ConnexionInstance : ConnexionInterface;
|
||||
export interface GameManagerInterface {
|
||||
GameScenes: Array<GameSceneInterface>;
|
||||
status : number;
|
||||
SimplePeer: SimplePeerInterface;
|
||||
createCurrentPlayer() : void;
|
||||
startWebRtc() : void;
|
||||
shareUserPosition(ListMessageUserPosition : ListMessageUserPositionInterface): void;
|
||||
}
|
||||
export class GameManager implements GameManagerInterface {
|
||||
GameScenes: Array<GameSceneInterface> = [];
|
||||
status: number;
|
||||
SimplePeer : SimplePeerInterface;
|
||||
|
||||
constructor() {
|
||||
this.status = StatusGameManagerEnum.IN_PROGRESS;
|
||||
@@ -29,8 +32,8 @@ export class GameManager implements GameManagerInterface {
|
||||
return ConnexionInstance.createConnexion().then(() => {
|
||||
this.configureGame();
|
||||
/** TODO add loader in the page **/
|
||||
//initialise cam
|
||||
new SimplePeer(ConnexionInstance);
|
||||
//initialise Pear Connexion of game
|
||||
this.SimplePeer = new SimplePeer(ConnexionInstance);
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
@@ -59,6 +62,10 @@ export class GameManager implements GameManagerInterface {
|
||||
this.status = StatusGameManagerEnum.CURRENT_USER_CREATED;
|
||||
}
|
||||
|
||||
startWebRtc() : void {
|
||||
this.SimplePeer.startWebRtc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Share position in game
|
||||
* @param ListMessageUserPosition
|
||||
|
||||
@@ -253,6 +253,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
||||
//init colision
|
||||
this.physics.add.collider(this.CurrentPlayer, player, (CurrentPlayer: CurrentGamerInterface, MapPlayer: GamerInterface) => {
|
||||
CurrentPlayer.say("Hello, how are you ? ");
|
||||
this.GameManager.startWebRtc();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user