Adding a notion of instances per mapAdding a notion of instances to room

The URL signature becomes:

https://workadventu.re/_/[instance]/[path_to_map.json]

This allows us to create many instances of the same map (and therefore to create several different worlds for different people)

An exit on a map can target another "instance" by passing the "exitInstance" property.
This commit is contained in:
David Négrier 2020-05-23 17:27:49 +02:00
parent 1f2b33baec
commit 2448fef53a
6 changed files with 66 additions and 42 deletions

View file

@ -10,8 +10,6 @@ import {
PointInterface
} from "../../Connexion";
import {SimplePeerInterface, SimplePeer} from "../../WebRtc/SimplePeer";
import {getMapKeyByUrl} from "../Login/LogincScene";
import ScenePlugin = Phaser.Scenes.ScenePlugin;
import {AddPlayerInterface} from "./AddPlayerInterface";
import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
@ -169,13 +167,13 @@ export class GameManager {
this.ConnexionInstance.sharePosition(event.x, event.y, event.direction, event.moving);
}
loadMap(mapUrl: string, scene: ScenePlugin): string {
let sceneKey = getMapKeyByUrl(mapUrl);
loadMap(mapUrl: string, scene: Phaser.Scenes.ScenePlugin, instance: string): string {
let sceneKey = GameScene.getMapKeyByUrl(mapUrl);
let gameIndex = scene.getIndex(sceneKey);
let game : Phaser.Scene = null;
if(gameIndex === -1){
game = new GameScene(sceneKey, mapUrl);
game = GameScene.createFromUrl(mapUrl, instance);
scene.add(sceneKey, game, false);
}
return sceneKey;