From 8547e946ebf5c37d1fcaacb98f969e3354a4e716 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sat, 4 Jul 2020 19:13:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=98=E6=A1=A3=E6=97=B6?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=8E=8B=E7=BC=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/maps.js | 21 +++++++++++++++------ project/plugins.js | 6 ++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libs/maps.js b/libs/maps.js index 351aa96f..86bccf70 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -43,8 +43,7 @@ maps.prototype.loadFloor = function (floorId, map) { map = {"map": map}; } var content = {}; - var notCopy = ["firstArrive", "eachArrive", "parallelDo", "map", "bgmap", "fgmap", - "events", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove"]; + var notCopy = this._loadFloor_doNotCopy(); for (var name in floor) { if (notCopy.indexOf(name) == -1 && floor[name] != null) content[name] = core.clone(floor[name]); @@ -60,6 +59,13 @@ maps.prototype.loadFloor = function (floorId, map) { return content; } +maps.prototype._loadFloor_doNotCopy = function () { + return [ + "firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", + "events", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove" + ]; +} + /// 根据需求解析出blocks maps.prototype.extractBlocks = function (map) { map = map || core.status.floorId; @@ -353,7 +359,7 @@ maps.prototype.saveMap = function (floorId) { var map = maps[floorId]; var thisFloor = this._compressFloorData(map, core.floors[floorId]); if (map.blocks) { - var mapArr = this.compressMap(this._getMapArrayFromBlocks(map.blocks, map.width, map.height), floorId); + var mapArr = this.compressMap(this._getMapArrayFromBlocks(map.blocks, map.width, map.height, true), floorId); if (mapArr != null) thisFloor.map = mapArr; } return thisFloor; @@ -361,8 +367,9 @@ maps.prototype.saveMap = function (floorId) { maps.prototype._compressFloorData = function (map, floor) { var thisFloor = {}; + var notCopy = this._loadFloor_doNotCopy(); for (var name in map) { - if (name != 'blocks') { + if (notCopy.indexOf(name) == -1) { var floorData = floor[name]; if (!core.utils.same(map[name], floorData)) { thisFloor[name] = core.clone(map[name]); @@ -432,12 +439,13 @@ maps.prototype._updateMapArray = function (floorId, x, y) { else map.map[y][x] = block.id; } -maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height) { +maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height, showDisable) { var blocks = []; for (var x = 0; x < height; x++) blocks.push(Array(width).fill(0)); blockArray.forEach(function (block) { - blocks[block.y][block.x] = block.id; + if (showDisable || !block.disable) + blocks[block.y][block.x] = block.id; }); return blocks; } @@ -1714,6 +1722,7 @@ maps.prototype.hideBlock = function (x, y, floorId) { block.disable = true; core.setMapBlockDisabled(floorId, block.x, block.y, true); + this._updateMapArray(floorId, block.x, block.y); // 删除动画,清除地图 this._removeBlockFromMap(floorId, block); diff --git a/project/plugins.js b/project/plugins.js index 7eded405..c47994b6 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -420,6 +420,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = parent.appendChild(input2); } } + core.maps._loadFloor_doNotCopy = function () { + return [ + "firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", "bg2map", "fg2map", + "events", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor", "cannotMove" + ]; + } ////// 绘制背景和前景层 ////// core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {