优化generateMovableArray的调用
This commit is contained in:
parent
1574e189b8
commit
6f0a66bb11
@ -770,7 +770,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
|
||||
if (this.nearHero(destX, destY)) return false;
|
||||
var canMoveArray = core.maps.generateMovableArray();
|
||||
var dirs = [[destX,destY],[destX-1,destY,"right"],[destX,destY-1,"down"],[destX,destY+1,"up"],[destX+1,destY,"left"]];
|
||||
var canMoveDirectlyArray = core.canMoveDirectlyArray(dirs);
|
||||
var canMoveDirectlyArray = core.canMoveDirectlyArray(dirs, canMoveArray);
|
||||
|
||||
for (var i = 0; i < dirs.length; ++i) {
|
||||
var d = dirs[i], dx = d[0], dy = d[1], dir = d[2];
|
||||
|
||||
@ -569,7 +569,7 @@ maps.prototype.canMoveDirectly = function (destX, destY) {
|
||||
return this.canMoveDirectlyArray([[destX,destY]])[0];
|
||||
}
|
||||
|
||||
maps.prototype.canMoveDirectlyArray = function (locs) {
|
||||
maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) {
|
||||
var ans = [], number = locs.length;
|
||||
|
||||
var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y');
|
||||
@ -598,7 +598,7 @@ maps.prototype.canMoveDirectlyArray = function (locs) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
return this._canMoveDirectly_bfs(fromX, fromY, locs, number, ans);
|
||||
return this._canMoveDirectly_bfs(fromX, fromY, locs, number, ans, canMoveArray);
|
||||
}
|
||||
|
||||
maps.prototype._canMoveDirectly_checkGlobal = function () {
|
||||
@ -622,8 +622,8 @@ maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
|
||||
return true;
|
||||
}
|
||||
|
||||
maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans) {
|
||||
var canMoveArray = this.generateMovableArray();
|
||||
maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray) {
|
||||
canMoveArray = canMoveArray || this.generateMovableArray();
|
||||
var blocksObj = this.getMapBlocksObj(core.status.floorId);
|
||||
// 滑冰
|
||||
var bgMap = this.getBgMapArray();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user