Permit to dissociate data by room
- Update share room id. - Join room when a scene is loaded. - Add a room in constant variable.
This commit is contained in:
parent
27c6034661
commit
5f11b065e1
7 changed files with 46 additions and 27 deletions
|
@ -71,6 +71,10 @@ export class GameManager {
|
|||
this.status = StatusGameManagerEnum.CURRENT_USER_CREATED;
|
||||
}
|
||||
|
||||
joinRoom(sceneKey : string, character: string){
|
||||
this.ConnexionInstance.joinARoom(sceneKey, character);
|
||||
}
|
||||
|
||||
/**
|
||||
* Share position in game
|
||||
* @param ListMessageUserPosition
|
||||
|
@ -120,7 +124,7 @@ export class GameManager {
|
|||
}
|
||||
|
||||
pushPlayerPosition(event: HasMovedEvent) {
|
||||
this.ConnexionInstance.sharePosition(event.x, event.y, event.character, event.direction);
|
||||
this.ConnexionInstance.sharePosition(event.x, event.y, event.character, this.currentGameScene.scene.key, event.direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
|
|||
|
||||
|
||||
// Let's generate the circle for the group delimiter
|
||||
|
||||
//TODO they are error with cercle
|
||||
this.circleTexture = this.textures.createCanvas('circleSprite', 96, 96);
|
||||
if(!this.circleTexture || this.circleTexture.context){
|
||||
return;
|
||||
|
@ -268,6 +268,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
|
|||
//create collision
|
||||
this.createCollisionWithPlayer();
|
||||
this.createCollisionObject();
|
||||
|
||||
//join room
|
||||
this.GameManager.joinRoom(this.scene.key, this.CurrentPlayer.PlayerTexture);
|
||||
|
||||
//listen event to share position of user
|
||||
this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue