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", SILENT = "silent",
START = "start", START = "start",
START_LAYER = "startLayer", START_LAYER = "startLayer",
TUTORIAL = "tutorial",
URL = "url", URL = "url",
WRITABLE_BY = "writableBy", WRITABLE_BY = "writableBy",
ZONE = "zone", ZONE = "zone",

View File

@ -603,6 +603,10 @@ export class GameScene extends DirtyScene {
for (const script of scripts) { for (const script of scripts) {
scriptPromises.push(iframeListener.registerScript(script)); 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.userInputManager.spaceEvent(() => {
this.outlinedItem?.activate(); this.outlinedItem?.activate();
@ -1397,7 +1401,6 @@ ${escapedMessage}
this.connection?.emitPlayerOutlineColor(null); this.connection?.emitPlayerOutlineColor(null);
}); });
iframeListener.registerAnswerer("getPlayerPosition", () => { iframeListener.registerAnswerer("getPlayerPosition", () => {
return { return {
x: this.CurrentPlayer.x, 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 { private getProperty(layer: ITiledMapLayer | ITiledMap, name: string): string | boolean | number | undefined {
const properties: ITiledMapProperty[] | undefined = layer.properties; const properties: ITiledMapProperty[] | undefined = layer.properties;
if (!properties) { if (!properties) {