Merge branch 'update-game-tiles' into metadataScriptingApi
This commit is contained in:
commit
796a9418d3
6 changed files with 79 additions and 42 deletions
|
@ -1,4 +1,4 @@
|
|||
import {gameManager} from "./GameManager";
|
||||
import { gameManager } from "./GameManager";
|
||||
import type {
|
||||
GroupCreatedUpdatedMessageInterface,
|
||||
MessageUserJoined,
|
||||
|
@ -80,6 +80,7 @@ import CanvasTexture = Phaser.Textures.CanvasTexture;
|
|||
import GameObject = Phaser.GameObjects.GameObject;
|
||||
import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR;
|
||||
import DOMElement = Phaser.GameObjects.DOMElement;
|
||||
import EVENT_TYPE = Phaser.Scenes.Events
|
||||
import type { Subscription } from "rxjs";
|
||||
import { worldFullMessageStream } from "../../Connexion/WorldFullMessageStream";
|
||||
import { lazyLoadCompanionResource } from "../Companion/CompanionTexturesLoadingManager";
|
||||
|
@ -185,7 +186,7 @@ export class GameScene extends DirtyScene implements CenterListener {
|
|||
private characterLayers!: string[];
|
||||
private companion!: string | null;
|
||||
private messageSubscription: Subscription | null = null;
|
||||
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
||||
private popUpElements: Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
||||
private originalMapUrl: string | undefined;
|
||||
private pinchManager: PinchManager | undefined;
|
||||
private physicsEnabled: boolean = true;
|
||||
|
@ -910,12 +911,33 @@ ${escapedMessage}
|
|||
iframeListener.sendUserTagList({list: this.connection.getAllTag()});
|
||||
}))
|
||||
|
||||
/*
|
||||
this.iframeSubscriptionList.push(iframeListener.tilesetLoaderStream.subscribe((tileset) => {
|
||||
//this.load.tilemapTiledJSON('logo', tileset.imgUrl);
|
||||
this.load.image('logo', tileset.imgUrl);
|
||||
this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.imgUrl, tileset.tilewidth, tileset.tileheight, tileset.margin, tileset.spacing));
|
||||
this.gameMap.addTerrain(this.Terrains[this.Terrains.length - 1]);
|
||||
}))
|
||||
*/
|
||||
|
||||
this.iframeSubscriptionList.push(iframeListener.updateTileStream.subscribe(event => {
|
||||
for (const eventTile of event) {
|
||||
const layer = this.gameMap.findPhaserLayer(eventTile.layer);
|
||||
if (layer) {
|
||||
const tile = layer.getTileAt(eventTile.x, eventTile.y)
|
||||
if (typeof eventTile.tile == "string") {
|
||||
const tileIndex = this.getIndexForTileType(eventTile.tile);
|
||||
if (tileIndex) {
|
||||
tile.index = tileIndex
|
||||
} else {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
tile.index = eventTile.tile
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
|
@ -945,6 +967,19 @@ ${escapedMessage}
|
|||
}
|
||||
|
||||
|
||||
private getIndexForTileType(tileType: string): number | null {
|
||||
for (const tileset of this.mapFile.tilesets) {
|
||||
if (tileset.tiles) {
|
||||
for (const tilesetTile of tileset.tiles) {
|
||||
if (tilesetTile.type == tileType) {
|
||||
return tileset.firstgid + tilesetTile.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private getMapDirUrl(): string {
|
||||
return this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
|
||||
}
|
||||
|
@ -952,8 +987,8 @@ ${escapedMessage}
|
|||
private onMapExit(exitKey: string) {
|
||||
if (this.mapTransitioning) return;
|
||||
this.mapTransitioning = true;
|
||||
const {roomId, hash} = Room.getIdFromIdentifier(exitKey, this.MapUrlFile, this.instance);
|
||||
if (!roomId) throw new Error('Could not find the room from its exit key: '+exitKey);
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(exitKey, this.MapUrlFile, this.instance);
|
||||
if (!roomId) throw new Error('Could not find the room from its exit key: ' + exitKey);
|
||||
urlManager.pushStartLayerNameToUrl(hash);
|
||||
const menuScene: MenuScene = this.scene.get(MenuSceneName) as MenuScene
|
||||
menuScene.reset()
|
||||
|
@ -1155,7 +1190,7 @@ ${escapedMessage}
|
|||
this.physics.add.collider(this.CurrentPlayer, phaserLayer, (object1: GameObject, object2: GameObject) => {
|
||||
//this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name)
|
||||
});
|
||||
phaserLayer.setCollisionByProperty({collides: true});
|
||||
phaserLayer.setCollisionByProperty({ collides: true });
|
||||
if (DEBUG_MODE) {
|
||||
//debug code to see the collision hitbox of the object in the top layer
|
||||
phaserLayer.renderDebug(this.add.graphics(), {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue