From 358d9a79d31fc22c6b616a35bff733218cd2de05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Tue, 5 Oct 2021 23:34:18 +0200 Subject: [PATCH] Add condition Hash for start layer (#1506) Signed-off-by: Gregoire Parant --- .../Phaser/Game/StartPositionCalculator.ts | 11 +- maps/tests/index.html | 8 + maps/tests/start-tile-teleport.json | 166 ++++++++++++++++++ 3 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 maps/tests/start-tile-teleport.json diff --git a/front/src/Phaser/Game/StartPositionCalculator.ts b/front/src/Phaser/Game/StartPositionCalculator.ts index b9802662..a5f96314 100644 --- a/front/src/Phaser/Game/StartPositionCalculator.ts +++ b/front/src/Phaser/Game/StartPositionCalculator.ts @@ -55,10 +55,13 @@ export class StartPositionCalculator { for (const layer of this.gameMap.flatLayers) { if (layer.type !== "tilelayer") continue; //we want to prioritize the selectedLayer other the start layer - if (selectedOrDefaultLayer === layer.name || layer.name.endsWith("/" + selectedOrDefaultLayer)) { - foundLayer = layer; - break; - } else if (selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer)) { + if ( + (selectedOrDefaultLayer === layer.name || + selectedOrDefaultLayer === `#${layer.name}` || + layer.name.endsWith("/" + selectedOrDefaultLayer)) && + layer.type === "tilelayer" && + (selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer)) + ) { foundLayer = layer; break; } diff --git a/maps/tests/index.html b/maps/tests/index.html index 3c9538d5..149e2868 100644 --- a/maps/tests/index.html +++ b/maps/tests/index.html @@ -55,6 +55,14 @@ Test start tile (S2) + + + Success Failure Pending + + + Test teleport into the map + + Success Failure Pending diff --git a/maps/tests/start-tile-teleport.json b/maps/tests/start-tile-teleport.json new file mode 100644 index 00000000..269d5ebc --- /dev/null +++ b/maps/tests/start-tile-teleport.json @@ -0,0 +1,166 @@ +{ "compressionlevel":-1, + "height":5, + "infinite":false, + "layers":[ + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":1, + "name":"start", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], + "height":5, + "id":4, + "name":"background", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0], + "height":5, + "id":7, + "name":"S2", + "opacity":1, + "properties":[ + { + "name":"startLayer", + "type":"bool", + "value":true + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":8, + "name":"S1", + "opacity":1, + "properties":[ + { + "name":"startLayer", + "type":"bool", + "value":true + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":5, + "name":"floor", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":5, + "id":6, + "name":"exitLayer-toS2", + "opacity":1, + "properties":[ + { + "name":"exitUrl", + "type":"string", + "value":".\/start-tile-teleport.json#S2" + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], + "height":5, + "id":9, + "name":"exitLayer-toS1", + "opacity":1, + "properties":[ + { + "name":"exitUrl", + "type":"string", + "value":".\/start-tile-teleport.json#S1" + }], + "type":"tilelayer", + "visible":true, + "width":5, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"floorLayer", + "objects":[ + { + "height":66.6666666666667, + "id":1, + "name":"", + "rotation":0, + "text": + { + "fontfamily":"Sans Serif", + "pixelsize":11, + "text":"Go to X above S1 and teleport on S2\nGo to X above S2 and teleport on S1", + "wrap":true + }, + "type":"", + "visible":true, + "width":155.104166666667, + "x":3.28125, + "y":2.5 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":10, + "nextobjectid":2, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.7.2", + "tileheight":32, + "tilesets":[ + { + "columns":2, + "firstgid":1, + "image":"function_tiles.png", + "imageheight":64, + "imagewidth":64, + "margin":0, + "name":"function_tiles", + "spacing":0, + "tilecount":4, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "type":"map", + "version":"1.6", + "width":5 +} \ No newline at end of file