Reformat maps

This commit is contained in:
oc 2019-03-16 23:10:29 +08:00
parent 02934cad46
commit e208baab84

View File

@ -651,7 +651,9 @@ maps.prototype.drawEvents = function (floorId, blocks, ctx) {
var arr = this.getMapArray(blocks, core.floors[floorId].width, core.floors[floorId].height); var arr = this.getMapArray(blocks, core.floors[floorId].width, core.floors[floorId].height);
var onMap = !core.isset(ctx); var onMap = !core.isset(ctx);
if (onMap) ctx = core.canvas.event; if (onMap) ctx = core.canvas.event;
blocks.filter(function (block) { return block.event && !block.disable; }) blocks.filter(function (block) {
return block.event && !block.disable;
})
.forEach(function (block) { .forEach(function (block) {
core.maps._drawMap_drawBlockInfo(ctx, block, core.maps.getBlockInfo(block), arr, onMap); core.maps._drawMap_drawBlockInfo(ctx, block, core.maps.getBlockInfo(block), arr, onMap);
}); });
@ -988,7 +990,8 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) {
else { else {
// 只绘制可见窗口 // 只绘制可见窗口
var halfWidth = parseInt(this.DEFAULT_WIDTH / 2), halfHeight = parseInt(this.DEFAULT_HEIGHT / 2); var halfWidth = parseInt(this.DEFAULT_WIDTH / 2), halfHeight = parseInt(this.DEFAULT_HEIGHT / 2);
var offsetX = core.clamp(centerX - halfWidth, 0, width - this.DEFAULT_WIDTH), offsetY = core.clamp(centerY - halfHeight, 0, height - this.DEFAULT_HEIGHT); var offsetX = core.clamp(centerX - halfWidth, 0, width - this.DEFAULT_WIDTH),
offsetY = core.clamp(centerY - halfHeight, 0, height - this.DEFAULT_HEIGHT);
ctx.drawImage(tempCanvas.canvas, offsetX * 32, offsetY * 32, this.DEFAULT_PIXEL_WIDTH, this.DEFAULT_PIXEL_HEIGHT, x, y, size, size); ctx.drawImage(tempCanvas.canvas, offsetX * 32, offsetY * 32, this.DEFAULT_PIXEL_WIDTH, this.DEFAULT_PIXEL_HEIGHT, x, y, size, size);
} }
} }
@ -1217,7 +1220,9 @@ maps.prototype.canRemoveBlock = function (block, floorId) {
maps.prototype.removeBlockByIds = function (floorId, ids) { maps.prototype.removeBlockByIds = function (floorId, ids) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
if (!core.isset(floorId)) return; if (!core.isset(floorId)) return;
ids.sort(function (a,b) {return b-a}).forEach(function (id) { ids.sort(function (a, b) {
return b - a
}).forEach(function (id) {
core.removeBlockById(id, floorId); core.removeBlockById(id, floorId);
}); });
} }
@ -1391,7 +1396,8 @@ maps.prototype._initDetachedBlock = function (blockInfo, x, y, displayDamage) {
var damage = null, damageColor = null; var damage = null, damageColor = null;
if (blockInfo.cls.indexOf('enemy') == 0 && core.hasItem('book') && displayDamage) { if (blockInfo.cls.indexOf('enemy') == 0 && core.hasItem('book') && displayDamage) {
var damageString = core.enemys.getDamageString(blockInfo.id, x, y); var damageString = core.enemys.getDamageString(blockInfo.id, x, y);
damage = damageString.damage; damageColor = damageString.color; damage = damageString.damage;
damageColor = damageString.color;
} }
if (damage != null) { if (damage != null) {
damageCanvas = "__damage_" + x + "_" + y; damageCanvas = "__damage_" + x + "_" + y;
@ -1674,11 +1680,15 @@ maps.prototype.removeGlobalAnimate = function (x, y, name) {
return; return;
} }
core.status.globalAnimateObjs = core.status.globalAnimateObjs.filter(function (block) {return block.x!=x || block.y!=y || block.name!=name;}); core.status.globalAnimateObjs = core.status.globalAnimateObjs.filter(function (block) {
return block.x != x || block.y != y || block.name != name;
});
// 检查Autotile // 检查Autotile
if (core.isset(core.status.autotileAnimateObjs.blocks)) { if (core.isset(core.status.autotileAnimateObjs.blocks)) {
core.status.autotileAnimateObjs.blocks = core.status.autotileAnimateObjs.blocks.filter(function (block) {return block.x!=x || block.y!=y || block.name!=name;}); core.status.autotileAnimateObjs.blocks = core.status.autotileAnimateObjs.blocks.filter(function (block) {
return block.x != x || block.y != y || block.name != name;
});
core.status.autotileAnimateObjs.map[y][x] = 0; core.status.autotileAnimateObjs.map[y][x] = 0;
} }