Adding support for putting the hash in a map referenced in an exit scene.
This commit is contained in:
parent
db3ef81842
commit
c0809e28db
@ -272,14 +272,21 @@ export class GameScene extends Phaser.Scene {
|
|||||||
let absoluteExitSceneUrl = new URL(exitSceneUrl, this.MapUrlFile).href;
|
let absoluteExitSceneUrl = new URL(exitSceneUrl, this.MapUrlFile).href;
|
||||||
let exitSceneKey = gameManager.loadMap(absoluteExitSceneUrl, this.scene, instance);
|
let exitSceneKey = gameManager.loadMap(absoluteExitSceneUrl, this.scene, instance);
|
||||||
|
|
||||||
let tiles : any = layer.data;
|
let tiles : number[] = layer.data as number[];
|
||||||
tiles.forEach((objectKey : number, key: number) => {
|
for (let key=0; key < tiles.length; key++) {
|
||||||
|
let objectKey = tiles[key];
|
||||||
if(objectKey === 0){
|
if(objectKey === 0){
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
//key + 1 because the start x = 0;
|
//key + 1 because the start x = 0;
|
||||||
let y : number = parseInt(((key + 1) / mapWidth).toString());
|
let y : number = parseInt(((key + 1) / mapWidth).toString());
|
||||||
let x : number = key - (y * mapWidth);
|
let x : number = key - (y * mapWidth);
|
||||||
|
|
||||||
|
let hash = new URL(exitSceneUrl, this.MapUrlFile).hash;
|
||||||
|
if (hash) {
|
||||||
|
hash = hash.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
//push and save switching case
|
//push and save switching case
|
||||||
// TODO: this is not efficient. We should refactor that to enable a search by key. For instance: this.PositionNextScene[y][x] = exitSceneKey
|
// TODO: this is not efficient. We should refactor that to enable a search by key. For instance: this.PositionNextScene[y][x] = exitSceneKey
|
||||||
this.PositionNextScene.push({
|
this.PositionNextScene.push({
|
||||||
@ -287,9 +294,10 @@ export class GameScene extends Phaser.Scene {
|
|||||||
yStart: (y * tileWidth),
|
yStart: (y * tileWidth),
|
||||||
xEnd: ((x +1) * tileHeight),
|
xEnd: ((x +1) * tileHeight),
|
||||||
yEnd: ((y + 1) * tileHeight),
|
yEnd: ((y + 1) * tileHeight),
|
||||||
key: exitSceneKey
|
key: exitSceneKey,
|
||||||
|
hash
|
||||||
})
|
})
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -454,7 +462,9 @@ export class GameScene extends Phaser.Scene {
|
|||||||
if(nextSceneKey){
|
if(nextSceneKey){
|
||||||
// We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map.
|
// We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map.
|
||||||
this.scene.remove(this.scene.key);
|
this.scene.remove(this.scene.key);
|
||||||
this.scene.start(nextSceneKey.key);
|
this.scene.start(nextSceneKey.key, {
|
||||||
|
startLayerName: nextSceneKey.hash
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user