Shaun 3 лет назад
Родитель
Сommit
ce8cab9ad3
3 измененных файлов: 33 добавлений и 11 удалений
  1. +14
    -11
      src/client/js/rendering/renderer.js
  2. +18
    -0
      src/server/config/maps/sewer/map.json
  3. +1
    -0
      src/server/world/map.js

+ 14
- 11
src/client/js/rendering/renderer.js Просмотреть файл

@@ -372,12 +372,11 @@ define([

const { player: { x: px, y: py } } = window;

let foundVisible = false;
let foundHidden = false;
let foundVisibleLayer = null;
let foundHiddenLayer = null;

hiddenRooms.forEach(h => {
const discovered = h.discovered;

const { discovered, layer } = h;
const { x: hx, y: hy, width, height, area } = h;

//Is the tile outside the hider
@@ -393,6 +392,12 @@ define([
if (!physics.isInPolygon(x, y, area))
return;

if (discovered) {
foundVisibleLayer = layer;

return;
}

//Is the player outside the hider
if (
px < hx ||
@@ -400,25 +405,23 @@ define([
py < hy ||
py >= hy + height
) {
if (!discovered)
foundHidden = true;
foundHiddenLayer = layer;

return;
}

//Is the player inside the hider
if (!physics.isInPolygon(px, py, area)) {
if (!discovered)
foundHidden = true;
foundHiddenLayer = layer;

return;
}

foundVisible = true;
foundVisibleLayer = layer;
});

//If two hiders hide the same tile but you're in one of them, the tile should be visible
return foundHidden && !foundVisible;
//We compare hider layers to cater for hiders inside hiders
return (foundHiddenLayer > foundVisibleLayer) || (foundHiddenLayer === 0 && foundVisibleLayer === null);
},

updateSprites: function () {


+ 18
- 0
src/server/config/maps/sewer/map.json Просмотреть файл

@@ -373,6 +373,12 @@
"x":24,
"y":0
}],
"properties":[
{
"name":"layer",
"type":"string",
"value":"1"
}],
"rotation":0,
"type":"",
"visible":true,
@@ -401,6 +407,12 @@
"x":40,
"y":0
}],
"properties":[
{
"name":"layer",
"type":"string",
"value":"1"
}],
"rotation":0,
"type":"",
"visible":true,
@@ -437,6 +449,12 @@
"x":32,
"y":0
}],
"properties":[
{
"name":"layer",
"type":"string",
"value":"1"
}],
"rotation":0,
"type":"",
"visible":true,


+ 1
- 0
src/server/world/map.js Просмотреть файл

@@ -460,6 +460,7 @@ module.exports = {
} else if (layerName === 'hiddenRooms') {
blueprint.fog = (cell.properties || {}).fog;
blueprint.discoverable = (cell.properties || {}).discoverable;
blueprint.layer = ~~((cell.properties || {}).layer || 0);

if (!mapFile.properties.isRandom)
this.hiddenRooms.push(blueprint);


Загрузка…
Отмена
Сохранить