transmit companion to remote players
This commit is contained in:
parent
2ad712807b
commit
c07079051a
19 changed files with 96 additions and 40 deletions
|
@ -6,4 +6,5 @@ export interface AddPlayerInterface {
|
|||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
companion: string|null;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,14 @@ export interface HasMovedEvent {
|
|||
export class GameManager {
|
||||
private playerName: string|null;
|
||||
private characterLayers: string[]|null;
|
||||
private companion: string|null;
|
||||
private startRoom!:Room;
|
||||
currentGameSceneName: string|null = null;
|
||||
|
||||
constructor() {
|
||||
this.playerName = localUserStore.getName();
|
||||
this.characterLayers = localUserStore.getCharacterLayers();
|
||||
this.companion = localUserStore.getCompanion();
|
||||
}
|
||||
|
||||
public async init(scenePlugin: Phaser.Scenes.ScenePlugin): Promise<string> {
|
||||
|
@ -63,6 +65,9 @@ export class GameManager {
|
|||
return this.characterLayers;
|
||||
}
|
||||
|
||||
getCompanion(): string|null {
|
||||
return this.companion;
|
||||
}
|
||||
|
||||
public async loadMap(room: Room, scenePlugin: Phaser.Scenes.ScenePlugin): Promise<void> {
|
||||
const roomID = room.id;
|
||||
|
|
|
@ -159,6 +159,7 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
private openChatIcon!: OpenChatIcon;
|
||||
private playerName!: string;
|
||||
private characterLayers!: string[];
|
||||
private companion!: string|null;
|
||||
private messageSubscription: Subscription|null = null;
|
||||
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
||||
|
||||
|
@ -335,7 +336,7 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
}
|
||||
this.playerName = playerName;
|
||||
this.characterLayers = gameManager.getCharacterLayers();
|
||||
|
||||
this.companion = gameManager.getCompanion();
|
||||
|
||||
//initalise map
|
||||
this.Map = this.add.tilemap(this.MapUrlFile);
|
||||
|
@ -459,7 +460,9 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
top: camera.scrollY,
|
||||
right: camera.scrollX + camera.width,
|
||||
bottom: camera.scrollY + camera.height,
|
||||
}).then((onConnect: OnConnectInterface) => {
|
||||
},
|
||||
this.companion
|
||||
).then((onConnect: OnConnectInterface) => {
|
||||
this.connection = onConnect.connection;
|
||||
|
||||
this.connection.onUserJoins((message: MessageUserJoined) => {
|
||||
|
@ -467,7 +470,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
userId: message.userId,
|
||||
characterLayers: message.characterLayers,
|
||||
name: message.name,
|
||||
position: message.position
|
||||
position: message.position,
|
||||
companion: message.companion
|
||||
}
|
||||
this.addPlayer(userMessage);
|
||||
});
|
||||
|
@ -1019,7 +1023,8 @@ ${escapedMessage}
|
|||
texturesPromise,
|
||||
PlayerAnimationDirections.Down,
|
||||
false,
|
||||
this.userInputManager
|
||||
this.userInputManager,
|
||||
this.companion
|
||||
);
|
||||
}catch (err){
|
||||
if(err instanceof TextureError) {
|
||||
|
@ -1211,7 +1216,8 @@ ${escapedMessage}
|
|||
addPlayerData.name,
|
||||
texturesPromise,
|
||||
addPlayerData.position.direction as PlayerAnimationDirections,
|
||||
addPlayerData.position.moving
|
||||
addPlayerData.position.moving,
|
||||
addPlayerData.companion
|
||||
);
|
||||
this.MapPlayers.add(player);
|
||||
this.MapPlayersByKey.set(player.userId, player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue