Adding a "openWebsite" property that opens websites when we walk over the zone.

This commit is contained in:
David Négrier 2020-08-30 17:37:38 +02:00
parent 168697eb46
commit 01319b50ca
4 changed files with 36 additions and 9 deletions

View file

@ -1,6 +1,6 @@
import {ITiledMap} from "../Map/ITiledMap";
export type PropertyChangeCallback = (oldValue: string | number | boolean | undefined, newValue: string | number | boolean | undefined) => void;
export type PropertyChangeCallback = (newValue: string | number | boolean | undefined, oldValue: string | number | boolean | undefined) => void;
/**
* A wrapper around a ITiledMap interface to provide additional capabilities.
@ -78,7 +78,7 @@ export class GameMap {
let callbacksArray = this.callbacks.get(propName);
if (callbacksArray !== undefined) {
for (const callback of callbacksArray) {
callback(oldValue, newValue);
callback(newValue, oldValue);
}
}
}

View file

@ -29,6 +29,7 @@ import CanvasTexture = Phaser.Textures.CanvasTexture;
import GameObject = Phaser.GameObjects.GameObject;
import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR;
import {GameMap} from "./GameMap";
import {CoWebsiteManager} from "../../WebRtc/CoWebsiteManager";
export enum Textures {
@ -415,8 +416,12 @@ export class GameScene extends Phaser.Scene implements CenterListener {
// From now, this game scene will be notified of reposition events
layoutManager.setListener(this);
this.gameMap.onPropertyChange('startLayer', (oldValue, newValue) => {
console.log('startLayer', oldValue, newValue);
this.gameMap.onPropertyChange('openWebsite', (newValue, oldValue) => {
if (newValue === undefined) {
CoWebsiteManager.closeCoWebsite();
} else {
CoWebsiteManager.loadCoWebsite(newValue as string);
}
});
}