|
|
@@ -127,7 +127,7 @@ define([ |
|
|
|
let container = new pixi.Container(); |
|
|
|
|
|
|
|
let totalHeight = 0; |
|
|
|
['tiles', 'walls', 'objects'].forEach(function (t) { |
|
|
|
['tiles', 'walls', 'objects'].forEach(t => { |
|
|
|
let texture = this.textures[t]; |
|
|
|
let tile = new pixi.Sprite(new pixi.Texture(texture)); |
|
|
|
tile.width = texture.width; |
|
|
@@ -138,7 +138,7 @@ define([ |
|
|
|
container.addChild(tile); |
|
|
|
|
|
|
|
totalHeight += tile.height; |
|
|
|
}, this); |
|
|
|
}); |
|
|
|
|
|
|
|
let renderTexture = pixi.RenderTexture.create(this.textures.tiles.width, totalHeight); |
|
|
|
this.renderer.render(container, renderTexture); |
|
|
@@ -280,7 +280,7 @@ define([ |
|
|
|
container.layer = 'tiles'; |
|
|
|
this.stage.addChild(container); |
|
|
|
|
|
|
|
this.stage.children.sort(function (a, b) { |
|
|
|
this.stage.children.sort((a, b) => { |
|
|
|
if (a.layer === 'hiders') |
|
|
|
return 1; |
|
|
|
else if (b.layer === 'hiders') |
|
|
@@ -341,22 +341,22 @@ define([ |
|
|
|
|
|
|
|
this.sprites = _.get2dArray(w, h, 'array'); |
|
|
|
|
|
|
|
this.stage.children.sort(function (a, b) { |
|
|
|
this.stage.children.sort((a, b) => { |
|
|
|
if (a.layer === 'tiles') |
|
|
|
return -1; |
|
|
|
else if (b.layer === 'tiles') |
|
|
|
return 1; |
|
|
|
return 0; |
|
|
|
}, this); |
|
|
|
}); |
|
|
|
|
|
|
|
if (this.zoneId !== null) |
|
|
|
events.emit('onRezone', this.zoneId); |
|
|
|
this.zoneId = msg.zoneId; |
|
|
|
|
|
|
|
msg.clientObjects.forEach(function (c) { |
|
|
|
msg.clientObjects.forEach(c => { |
|
|
|
c.zoneId = this.zoneId; |
|
|
|
events.emit('onGetObject', c); |
|
|
|
}, this); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
setPosition: function (pos, instant) { |
|
|
@@ -459,25 +459,22 @@ define([ |
|
|
|
if (this.titleScreen) |
|
|
|
return; |
|
|
|
|
|
|
|
let player = window.player; |
|
|
|
const player = window.player; |
|
|
|
if (!player) |
|
|
|
return; |
|
|
|
|
|
|
|
let w = this.w; |
|
|
|
let h = this.h; |
|
|
|
const { w, h, width, height, stage, map, sprites } = this; |
|
|
|
|
|
|
|
let x = ~~((-this.stage.x / scale) + (this.width / (scale * 2))); |
|
|
|
let y = ~~((-this.stage.y / scale) + (this.height / (scale * 2))); |
|
|
|
const x = ~~((-stage.x / scale) + (width / (scale * 2))); |
|
|
|
const y = ~~((-stage.y / scale) + (height / (scale * 2))); |
|
|
|
|
|
|
|
this.lastUpdatePos.x = this.stage.x; |
|
|
|
this.lastUpdatePos.y = this.stage.y; |
|
|
|
this.lastUpdatePos.x = stage.x; |
|
|
|
this.lastUpdatePos.y = stage.y; |
|
|
|
|
|
|
|
let sprites = this.sprites; |
|
|
|
let map = this.map; |
|
|
|
let container = this.layers.tileSprites; |
|
|
|
const container = this.layers.tileSprites; |
|
|
|
|
|
|
|
let sw = this.showTilesW; |
|
|
|
let sh = this.showTilesH; |
|
|
|
const sw = this.showTilesW; |
|
|
|
const sh = this.showTilesH; |
|
|
|
|
|
|
|
let lowX = Math.max(0, x - sw + 1); |
|
|
|
let lowY = Math.max(0, y - sh + 2); |
|
|
@@ -486,33 +483,34 @@ define([ |
|
|
|
|
|
|
|
let addedSprite = false; |
|
|
|
|
|
|
|
let checkHidden = this.isHidden.bind(this); |
|
|
|
const checkHidden = this.isHidden.bind(this); |
|
|
|
const buildTile = this.buildTile.bind(this); |
|
|
|
|
|
|
|
let newVisible = []; |
|
|
|
let newHidden = []; |
|
|
|
const newVisible = []; |
|
|
|
const newHidden = []; |
|
|
|
|
|
|
|
for (let i = lowX; i < highX; i++) { |
|
|
|
let mapRow = map[i]; |
|
|
|
let spriteRow = sprites[i]; |
|
|
|
|
|
|
|
for (let j = lowY; j < highY; j++) { |
|
|
|
let cell = mapRow[j]; |
|
|
|
const cell = mapRow[j]; |
|
|
|
if (!cell) |
|
|
|
continue; |
|
|
|
|
|
|
|
let cLen = cell.length; |
|
|
|
const cLen = cell.length; |
|
|
|
if (!cLen) |
|
|
|
return; |
|
|
|
|
|
|
|
let rendered = spriteRow[j]; |
|
|
|
let isHidden = checkHidden(i, j); |
|
|
|
const rendered = spriteRow[j]; |
|
|
|
const isHidden = checkHidden(i, j); |
|
|
|
|
|
|
|
if (isHidden) { |
|
|
|
const nonFakeRendered = rendered.filter(r => !r.isFake); |
|
|
|
|
|
|
|
let rLen = nonFakeRendered.length; |
|
|
|
const rLen = nonFakeRendered.length; |
|
|
|
for (let k = 0; k < rLen; k++) { |
|
|
|
let sprite = nonFakeRendered[k]; |
|
|
|
const sprite = nonFakeRendered[k]; |
|
|
|
|
|
|
|
sprite.visible = false; |
|
|
|
spritePool.store(sprite); |
|
|
@@ -534,9 +532,9 @@ define([ |
|
|
|
} else { |
|
|
|
const fakeRendered = rendered.filter(r => r.isFake); |
|
|
|
|
|
|
|
let rLen = fakeRendered.length; |
|
|
|
const rLen = fakeRendered.length; |
|
|
|
for (let k = 0; k < rLen; k++) { |
|
|
|
let sprite = fakeRendered[k]; |
|
|
|
const sprite = fakeRendered[k]; |
|
|
|
|
|
|
|
sprite.visible = false; |
|
|
|
spritePool.store(sprite); |
|
|
@@ -581,7 +579,7 @@ define([ |
|
|
|
|
|
|
|
let tile = spritePool.getSprite(flipped + c); |
|
|
|
if (!tile) { |
|
|
|
tile = this.buildTile(c, i, j); |
|
|
|
tile = buildTile(c, i, j); |
|
|
|
container.addChild(tile); |
|
|
|
tile.type = c; |
|
|
|
tile.sheetNum = tileOpacity.getSheetNum(c); |
|
|
@@ -726,6 +724,8 @@ define([ |
|
|
|
}, |
|
|
|
|
|
|
|
buildObject: function (obj) { |
|
|
|
const { sheetName } = obj; |
|
|
|
|
|
|
|
let w = 8; |
|
|
|
let h = 8; |
|
|
|
if (obj.w) { |
|
|
@@ -734,7 +734,7 @@ define([ |
|
|
|
} |
|
|
|
|
|
|
|
let bigSheets = ['bosses', 'bigObjects', 'animBigObjects']; |
|
|
|
if ((bigSheets.indexOf(obj.sheetName) > -1) || (obj.sheetName.indexOf('bosses') > -1)) { |
|
|
|
if (bigSheets.includes(sheetName) || sheetName.includes('bosses') || sheetName.includes('BigObjects')) { |
|
|
|
obj.layerName = 'mobs'; |
|
|
|
w = 24; |
|
|
|
h = 24; |
|
|
|