When sharing user position, only position is sent now!

This commit is contained in:
David Négrier 2020-05-15 23:40:05 +02:00
parent cdfa9acf01
commit 4d1c3517ec
5 changed files with 40 additions and 55 deletions

View file

@ -17,7 +17,6 @@ export interface HasMovedEvent {
direction: string;
x: number;
y: number;
character: string;
}
export interface MapObject {
@ -71,8 +70,8 @@ export class GameManager {
this.status = StatusGameManagerEnum.CURRENT_USER_CREATED;
}
joinRoom(sceneKey : string, character: string){
this.ConnexionInstance.joinARoom(sceneKey, character);
joinRoom(sceneKey : string){
this.ConnexionInstance.joinARoom(sceneKey);
}
/**
@ -128,7 +127,7 @@ export class GameManager {
}
pushPlayerPosition(event: HasMovedEvent) {
this.ConnexionInstance.sharePosition(event.x, event.y, event.character, this.currentGameScene.scene.key, event.direction);
this.ConnexionInstance.sharePosition(event.x, event.y, event.direction);
}
loadMap(mapUrl: string, scene: ScenePlugin): string {

View file

@ -284,7 +284,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
this.createCollisionObject();
//join room
this.GameManager.joinRoom(this.scene.key, this.CurrentPlayer.PlayerTexture);
this.GameManager.joinRoom(this.scene.key);
//listen event to share position of user
this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this))

View file

@ -81,12 +81,12 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
}
if (x !== 0 || y !== 0) {
this.move(x, y);
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y});
} else {
if (this.previousMove !== PlayerAnimationNames.None) {
direction = PlayerAnimationNames.None;
this.stop();
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y});
}
}