From b1f7f1a9c7f0e30c6823ae9176a65f6e063ac4d0 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 31 Mar 2019 20:19:24 +0800 Subject: [PATCH] getBgNumber --- libs/control.js | 2 +- libs/maps.js | 22 +++++++++++++++++++--- project/events.js | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libs/control.js b/libs/control.js index a3afd4fe..1aa32609 100644 --- a/libs/control.js +++ b/libs/control.js @@ -659,7 +659,7 @@ control.prototype._moveAction_moving = function (callback) { core.updateStatusBar(); // 检查该点是否是滑冰 - if (core.getBgFgNumber('bg') == 167) { + if (core.getBgNumber() == 167) { core.insertAction("滑冰事件", null, null, null, true); } diff --git a/libs/maps.js b/libs/maps.js index b2da2f6f..04287c39 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -362,12 +362,28 @@ maps.prototype.getBgFgMapArray = function (name, floorId, noCache) { return arr; } +maps.prototype.getBgMapArray = function (floorId, noCache) { + return this.getBgFgMapArray('bg', floorId, noCache); +} + +maps.prototype.getFgMapArray = function (floorId, noCache) { + return this.getBgFgMapArray('fg', floorId, noCache); +} + maps.prototype.getBgFgNumber = function (name, x, y, floorId, noCache) { if (x == null) x = core.getHeroLoc('x'); if (y == null) y = core.getHeroLoc('y'); return this.getBgFgMapArray(name, floorId, noCache)[y][x]; } +maps.prototype.getBgNumber = function (x, y, floorId, noCache) { + return this.getBgFgNumber('bg', x, y, floorId, noCache); +} + +maps.prototype.getFgNumber = function (x, y, floorId, noCache) { + return this.getBgFgNumber('fg', x, y, floorId, noCache); +} + // ------ 当前能否朝某方向移动,能否瞬间移动 ------ // ////// 生成全图的当前可移动信息 ////// @@ -375,8 +391,8 @@ maps.prototype.generateMovableArray = function (floorId, x, y, direction) { floorId = floorId || core.status.floorId; if (!floorId) return null; var width = core.floors[floorId].width, height = core.floors[floorId].height; - var bgArray = this.getBgFgMapArray('bg', floorId), - fgArray = this.getBgFgMapArray('fg', floorId), + var bgArray = this.getBgMapArray(floorId), + fgArray = this.getFgMapArray(floorId), eventArray = this.getMapArray(floorId); var generate = function (x, y, direction) { @@ -489,7 +505,7 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, ex, ey) { var canMoveArray = this.generateMovableArray(); var blocksObj = this.getMapBlocksObj(core.status.floorId); // 滑冰 - var bgMap = this.getBgFgMapArray('bg'); + var bgMap = this.getBgMapArray(); var visited = [], queue = []; visited[sx + "," + sy] = 0; diff --git a/project/events.js b/project/events.js index cfc58540..d8559846 100644 --- a/project/events.js +++ b/project/events.js @@ -223,7 +223,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = }, { "type": "if", - "condition": "core.getBgFgNumber('bg') == 167", + "condition": "core.getBgNumber() == 167", "true": [ { "type": "function",