we can now trigger events when stepping on tiled rectangular objects. WIP
This commit is contained in:
parent
4bd8be89c1
commit
6a394945f3
@ -76,7 +76,8 @@ export class GameMap {
|
|||||||
) {
|
) {
|
||||||
this.flatLayers = flattenGroupLayersMap(map);
|
this.flatLayers = flattenGroupLayersMap(map);
|
||||||
this.tiledObjects = this.getObjectsFromLayers(this.flatLayers);
|
this.tiledObjects = this.getObjectsFromLayers(this.flatLayers);
|
||||||
this.zones = this.tiledObjects.filter((object) => object.type === "zone");
|
this.zones = this.tiledObjects.filter((object) => object.width > 0);
|
||||||
|
console.log(this.zones);
|
||||||
|
|
||||||
let depth = -2;
|
let depth = -2;
|
||||||
for (const layer of this.flatLayers) {
|
for (const layer of this.flatLayers) {
|
||||||
@ -469,6 +470,26 @@ export class GameMap {
|
|||||||
private getProperties(key: number): Map<string, string | boolean | number> {
|
private getProperties(key: number): Map<string, string | boolean | number> {
|
||||||
const properties = new Map<string, string | boolean | number>();
|
const properties = new Map<string, string | boolean | number>();
|
||||||
|
|
||||||
|
const zonesByNewPosition = this.position
|
||||||
|
? this.zones.filter((zone) => {
|
||||||
|
if (!this.position) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return MathUtils.isOverlappingWithRectangle(this.position, zone);
|
||||||
|
})
|
||||||
|
: [];
|
||||||
|
|
||||||
|
for (const zone of zonesByNewPosition) {
|
||||||
|
if (zone.properties !== undefined) {
|
||||||
|
for (const property of zone.properties) {
|
||||||
|
if (property.value === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
properties.set(property.name, property.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const layer of this.flatLayers) {
|
for (const layer of this.flatLayers) {
|
||||||
if (layer.type !== "tilelayer") {
|
if (layer.type !== "tilelayer") {
|
||||||
continue;
|
continue;
|
||||||
|
@ -66,6 +66,8 @@ export class GameMapPropertiesListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log("START JITSI");
|
||||||
|
console.log(newValue, oldValue, allProps);
|
||||||
const openJitsiRoomFunction = () => {
|
const openJitsiRoomFunction = () => {
|
||||||
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.instance);
|
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.instance);
|
||||||
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
||||||
|
@ -893,6 +893,7 @@ export class GameScene extends DirtyScene {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.gameMap.onEnterZone((zones) => {
|
this.gameMap.onEnterZone((zones) => {
|
||||||
|
console.log("ZONE ENTERED");
|
||||||
for (const zone of zones) {
|
for (const zone of zones) {
|
||||||
const focusable = zone.properties?.find((property) => property.name === "focusable");
|
const focusable = zone.properties?.find((property) => property.name === "focusable");
|
||||||
if (focusable && focusable.value === true) {
|
if (focusable && focusable.value === true) {
|
||||||
|
@ -44,29 +44,6 @@
|
|||||||
"x":0,
|
"x":0,
|
||||||
"y":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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 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, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":17,
|
|
||||||
"id":38,
|
|
||||||
"name":"jitsiChillzone",
|
|
||||||
"opacity":1,
|
|
||||||
"properties":[
|
|
||||||
{
|
|
||||||
"name":"jitsiRoom",
|
|
||||||
"type":"string",
|
|
||||||
"value":"ChillZone"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"jitsiTrigger",
|
|
||||||
"type":"string",
|
|
||||||
"value":"onaction"
|
|
||||||
}],
|
|
||||||
"type":"tilelayer",
|
|
||||||
"visible":true,
|
|
||||||
"width":31,
|
|
||||||
"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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 446, 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, 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, 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,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, 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, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
"height":17,
|
"height":17,
|
||||||
@ -148,6 +125,28 @@
|
|||||||
"width":128,
|
"width":128,
|
||||||
"x":512,
|
"x":512,
|
||||||
"y":0
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":39.2648412257873,
|
||||||
|
"id":9,
|
||||||
|
"name":"jitsiChillZone",
|
||||||
|
"properties":[
|
||||||
|
{
|
||||||
|
"name":"jitsiRoom",
|
||||||
|
"type":"string",
|
||||||
|
"value":"MeetingRoom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"jitsiTrigger",
|
||||||
|
"type":"string",
|
||||||
|
"value":"onaction"
|
||||||
|
}],
|
||||||
|
"rotation":0.513253840280061,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":76.5390990955655,
|
||||||
|
"x":59.0274706237854,
|
||||||
|
"y":91.8390566468795
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
@ -192,7 +191,7 @@
|
|||||||
"y":0
|
"y":0
|
||||||
}],
|
}],
|
||||||
"nextlayerid":39,
|
"nextlayerid":39,
|
||||||
"nextobjectid":9,
|
"nextobjectid":10,
|
||||||
"orientation":"orthogonal",
|
"orientation":"orthogonal",
|
||||||
"properties":[
|
"properties":[
|
||||||
{
|
{
|
||||||
@ -200,33 +199,33 @@
|
|||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"Credits: Valdo Romao https:\/\/www.linkedin.com\/in\/valdo-romao\/ \nLicense: CC-BY-SA 3.0 (http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/)"
|
"value":"Credits: Valdo Romao https:\/\/www.linkedin.com\/in\/valdo-romao\/ \nLicense: CC-BY-SA 3.0 (http:\/\/creativecommons.org\/licenses\/by-sa\/3.0\/)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"mapDescription",
|
"name":"mapDescription",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"A perfect virtual office to get started with WorkAdventure!"
|
"value":"A perfect virtual office to get started with WorkAdventure!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"mapImage",
|
"name":"mapImage",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"map.png"
|
"value":"map.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"mapLink",
|
"name":"mapLink",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"https:\/\/thecodingmachine.github.io\/workadventure-map-starter-kit\/map.json"
|
"value":"https:\/\/thecodingmachine.github.io\/workadventure-map-starter-kit\/map.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"mapName",
|
"name":"mapName",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"Starter kit"
|
"value":"Starter kit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"script",
|
"name":"script",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"value":"..\/dist\/script.js"
|
"value":"..\/dist\/script.js"
|
||||||
}],
|
}],
|
||||||
"renderorder":"right-down",
|
"renderorder":"right-down",
|
||||||
"tiledversion":"1.7.0",
|
"tiledversion":"1.7.2",
|
||||||
"tileheight":32,
|
"tileheight":32,
|
||||||
"tilesets":[
|
"tilesets":[
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user