From b18b2fe0e31c5c6481f184b754c581ac2e4cd6a7 Mon Sep 17 00:00:00 2001 From: GRL Date: Tue, 25 May 2021 09:50:59 +0200 Subject: [PATCH] preparation for merge with metadataScriptApi --- .../{ApiUpdateTileEvent.ts => ChangeTileEvent.ts} | 6 ++---- front/src/Api/IframeListener.ts | 6 +++--- front/src/Phaser/Game/GameScene.ts | 10 +++++----- 3 files changed, 10 insertions(+), 12 deletions(-) rename front/src/Api/Events/{ApiUpdateTileEvent.ts => ChangeTileEvent.ts} (70%) diff --git a/front/src/Api/Events/ApiUpdateTileEvent.ts b/front/src/Api/Events/ChangeTileEvent.ts similarity index 70% rename from front/src/Api/Events/ApiUpdateTileEvent.ts rename to front/src/Api/Events/ChangeTileEvent.ts index 094596a4..5a9183ca 100644 --- a/front/src/Api/Events/ApiUpdateTileEvent.ts +++ b/front/src/Api/Events/ChangeTileEvent.ts @@ -1,9 +1,7 @@ - import * as tg from "generic-type-guard"; -export const updateTile = "updateTile" -export const isUpdateTileEvent = tg.isArray( +export const isChangeTileEvent = tg.isArray( new tg.IsInterface().withProperties({ x: tg.isNumber, y: tg.isNumber, @@ -14,4 +12,4 @@ export const isUpdateTileEvent = tg.isArray( /** * A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property. */ -export type UpdateTileEvent = tg.GuardedType; \ No newline at end of file +export type ChangeTileEvent = tg.GuardedType; \ No newline at end of file diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index f97e80ae..d59c9140 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -13,7 +13,7 @@ import { scriptUtils } from "./ScriptUtils"; import { GoToPageEvent, isGoToPageEvent } from "./Events/GoToPageEvent"; import { isOpenCoWebsite, OpenCoWebSiteEvent } from "./Events/OpenCoWebSiteEvent"; import { isLoadPageEvent } from './Events/LoadPageEvent'; -import { isUpdateTileEvent, UpdateTileEvent } from './Events/ApiUpdateTileEvent'; +import { isChangeTileEvent, ChangeTileEvent } from './Events/ChangeTileEvent'; /** @@ -58,7 +58,7 @@ class IframeListener { private readonly _removeBubbleStream: Subject = new Subject(); public readonly removeBubbleStream = this._removeBubbleStream.asObservable(); - private readonly _updateTileEvent: Subject = new Subject(); + private readonly _updateTileEvent: Subject = new Subject(); public readonly updateTileEvent = this._updateTileEvent.asObservable(); private readonly iframes = new Set(); @@ -114,7 +114,7 @@ class IframeListener { this._removeBubbleStream.next(); } else if (payload.type === 'loadPage' && isLoadPageEvent(payload.data)) { this._loadPageStream.next(payload.data.url); - } else if (payload.type == "updateTile" && isUpdateTileEvent(payload.data)) { + } else if (payload.type == "updateTile" && isChangeTileEvent(payload.data)) { this._updateTileEvent.next(payload.data) } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 674087e0..fc5bf80f 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -134,7 +134,7 @@ export class GameScene extends ResizableScene implements CenterListener { MapPlayers!: Phaser.Physics.Arcade.Group; MapPlayersByKey: Map = new Map(); Map!: Phaser.Tilemaps.Tilemap; - Layers!: Array; + Layers!: Array; Objects!: Array; mapFile!: ITiledMap; groups: Map; @@ -395,12 +395,12 @@ export class GameScene extends ResizableScene implements CenterListener { this.physics.world.setBounds(0, 0, this.Map.widthInPixels, this.Map.heightInPixels); //add layer on map - this.Layers = new Array(); + this.Layers = new Array(); let depth = -2; for (const layer of this.gameMap.layersIterator) { if (layer.type === 'tilelayer') { - this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); + this.addLayer(this.Map.createLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); const exitSceneUrl = this.getExitSceneUrl(layer); if (exitSceneUrl !== undefined) { @@ -1105,13 +1105,13 @@ ${escapedMessage} this.cameras.main.setZoom(ZOOM_LEVEL); } - addLayer(Layer: Phaser.Tilemaps.StaticTilemapLayer) { + addLayer(Layer: Phaser.Tilemaps.TilemapLayer) { this.Layers.push(Layer); } createCollisionWithPlayer() { //add collision layer - this.Layers.forEach((Layer: Phaser.Tilemaps.StaticTilemapLayer) => { + this.Layers.forEach((Layer: Phaser.Tilemaps.TilemapLayer) => { this.physics.add.collider(this.CurrentPlayer, Layer, (object1: GameObject, object2: GameObject) => { //this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name) });