Merge
This commit is contained in:
commit
df5b183cba
3 changed files with 22 additions and 13 deletions
|
@ -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;
|
||||
|
@ -25,9 +29,8 @@ export class GameManager {
|
|||
connect(name:string) {
|
||||
this.playerName = name;
|
||||
this.ConnexionInstance = new Connexion(name, this);
|
||||
ConnexionInstance = this.ConnexionInstance;
|
||||
return this.ConnexionInstance.createConnexion().then(() => {
|
||||
this.SimplePeer = new SimplePeer(ConnexionInstance);
|
||||
this.SimplePeer = new SimplePeer(this.ConnexionInstance);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -63,6 +66,10 @@ export class GameManager {
|
|||
getPlayerName(): string {
|
||||
return this.playerName;
|
||||
}
|
||||
|
||||
pushPlayerPosition(event: HasMovedEvent) {
|
||||
this.ConnexionInstance.sharePosition(event.x, event.y, event.direction);
|
||||
}
|
||||
}
|
||||
|
||||
export const gameManager = new GameManager();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {GameManager, gameManager, StatusGameManagerEnum} from "./GameManager";
|
||||
import {GameManager, gameManager, HasMovedEvent, StatusGameManagerEnum} from "./GameManager";
|
||||
import {MessageUserPositionInterface} from "../../Connexion";
|
||||
import {CurrentGamerInterface, GamerInterface, Player} from "../Player/Player";
|
||||
import {CurrentGamerInterface, GamerInterface, hasMovedEventName, Player} from "../Player/Player";
|
||||
import {DEBUG_MODE, RESOLUTION, ROOM, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable";
|
||||
import Tile = Phaser.Tilemaps.Tile;
|
||||
import {ITiledMap, ITiledTileSet} from "../Map/ITiledMap";
|
||||
|
@ -172,6 +172,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||
//create collision
|
||||
this.createCollisionWithPlayer();
|
||||
this.createCollisionObject();
|
||||
this.CurrentPlayer.on(hasMovedEventName, this.pushPlayerPosition.bind(this))
|
||||
}
|
||||
|
||||
pushPlayerPosition(event: HasMovedEvent) {
|
||||
this.GameManager.pushPlayerPosition(event);
|
||||
}
|
||||
|
||||
EventToClickOnTile(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue