WIP enable/disable tutorial according to the map 'tutorial' property

This commit is contained in:
Benedicte Quimbert 2021-12-29 17:46:46 +01:00
parent 99f9d56c5c
commit d9482d484b
2 changed files with 9 additions and 1 deletions

View file

@ -31,6 +31,7 @@ export enum GameMapProperties {
SILENT = "silent",
START = "start",
START_LAYER = "startLayer",
TUTORIAL = "tutorial",
URL = "url",
WRITABLE_BY = "writableBy",
ZONE = "zone",

View file

@ -603,6 +603,10 @@ export class GameScene extends DirtyScene {
for (const script of scripts) {
scriptPromises.push(iframeListener.registerScript(script));
}
if (this.isTutorialEnabled()) {
//TODO: split tutorial and bundle scripts
scriptPromises.push(iframeListener.registerScript(new URL("bundle.js", this.MapUrlFile).toString()));
}
this.userInputManager.spaceEvent(() => {
this.outlinedItem?.activate();
@ -1397,7 +1401,6 @@ ${escapedMessage}
this.connection?.emitPlayerOutlineColor(null);
});
iframeListener.registerAnswerer("getPlayerPosition", () => {
return {
x: this.CurrentPlayer.x,
@ -1569,6 +1572,10 @@ ${escapedMessage}
);
}
private isTutorialEnabled(): boolean {
return this.getProperty(this.mapFile, GameMapProperties.TUTORIAL) as boolean;
}
private getProperty(layer: ITiledMapLayer | ITiledMap, name: string): string | boolean | number | undefined {
const properties: ITiledMapProperty[] | undefined = layer.properties;
if (!properties) {