diff --git a/libs/core.js b/libs/core.js index 09b90cab..bba8f4fc 100644 --- a/libs/core.js +++ b/libs/core.js @@ -228,7 +228,7 @@ core.prototype.init = function (coreData, callback) { this._init_flags(); this._init_platform(); this._init_others(); - this._initPlugins(); + this._init_plugins(); // 初始化画布 for (var name in core.canvas) { @@ -410,7 +410,7 @@ core.prototype._afterLoadResources = function (callback) { if (callback) callback(); } -core.prototype._initPlugins = function () { +core.prototype._init_plugins = function () { core.plugin = new function () {}; for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) { diff --git a/libs/maps.js b/libs/maps.js index 0038f666..6e89dd65 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -704,6 +704,7 @@ maps.prototype._automaticRoute_bfs = function (startX, startY, destX, destY) { var queue = new PriorityQueue({comparator: function (a,b) { return a.depth - b.depth; }}); route[startX + "," + startY] = ''; queue.queue({depth: 0, x: startX, y: startY}); + var blocks = core.getMapBlocksObj(); while (queue.length!=0) { var curr = queue.dequeue(), deep = curr.depth, nowX = curr.x, nowY = curr.y; for (var direction in core.utils.scan) { @@ -719,17 +720,17 @@ maps.prototype._automaticRoute_bfs = function (startX, startY, destX, destY) { // 不可通行 if (core.noPass(nx, ny)) continue; route[nx+","+ny] = direction; - queue.queue({depth: deep + this._automaticRoute_deepAdd(nx, ny), x: nx, y: ny}); + queue.queue({depth: deep + this._automaticRoute_deepAdd(nx, ny, blocks), x: nx, y: ny}); } if (route[destX+","+destY] != null) break; } return route; } -maps.prototype._automaticRoute_deepAdd = function (x, y) { +maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) { // 判定每个可通行点的损耗值,越高越应该绕路 var deepAdd = 1; - var block = core.getBlock(x,y); + var block = blocks[x+","+y]; if (block != null){ var id = block.block.event.id; // 绕过亮灯