Fix cannotMove

This commit is contained in:
oc 2018-09-22 19:45:18 +08:00
parent 6d24b98947
commit 3bbd5e523b
3 changed files with 9 additions and 2 deletions

View File

@ -1954,7 +1954,7 @@ control.prototype.replay = function () {
return; return;
} }
else if (action=='getNext') { else if (action=='getNext') {
if (core.flags.enableGentleClick && core.getBlock(core.nextX(), core.nextY())!=null) { if (core.flags.enableGentleClick && core.canMoveHero() && core.getBlock(core.nextX(), core.nextY())!=null) {
var nextX = core.nextX(), nextY = core.nextY(); var nextX = core.nextX(), nextY = core.nextY();
var block = core.getBlock(nextX, nextY); var block = core.getBlock(nextX, nextY);
if (block!=null && block.block.event.trigger=='getItem') { if (block!=null && block.block.event.trigger=='getItem') {

View File

@ -1003,6 +1003,7 @@ events.prototype.insertAction = function (action, x, y, callback) {
////// 获得面前的物品(轻按) ////// ////// 获得面前的物品(轻按) //////
events.prototype.getNextItem = function() { events.prototype.getNextItem = function() {
if (!core.status.heroStop || !core.flags.enableGentleClick) return; if (!core.status.heroStop || !core.flags.enableGentleClick) return;
if (!core.canMoveHero()) return;
var nextX = core.nextX(), nextY = core.nextY(); var nextX = core.nextX(), nextY = core.nextY();
var block = core.getBlock(nextX, nextY); var block = core.getBlock(nextX, nextY);
if (block==null) return; if (block==null) return;

View File

@ -310,11 +310,17 @@ maps.prototype.canMoveDirectly = function (destX,destY) {
visited[fromX+core.bigmap.width*fromY]=0; visited[fromX+core.bigmap.width*fromY]=0;
queue.push(fromX+core.bigmap.width*fromY); queue.push(fromX+core.bigmap.width*fromY);
var directions = [[-1,0],[1,0],[0,1],[0,-1]]; var directions = {
"left": [-1,0],
"up": [0,-1],
"right": [1,0],
"down": [0,1]
}
while (queue.length>0) { while (queue.length>0) {
var now=queue.shift(), nowX=parseInt(now%core.bigmap.width), nowY=parseInt(now/core.bigmap.width); var now=queue.shift(), nowX=parseInt(now%core.bigmap.width), nowY=parseInt(now/core.bigmap.width);
for (var dir in directions) { for (var dir in directions) {
if (!core.canMoveHero(nowX, nowY, dir)) continue;
var nx=nowX+directions[dir][0], ny=nowY+directions[dir][1]; var nx=nowX+directions[dir][0], ny=nowY+directions[dir][1];
if (nx<0||nx>=core.bigmap.width||ny<0||ny>=core.bigmap.height||visited[nx+core.bigmap.width*ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[nx+core.bigmap.width*ny]>0) continue; if (nx<0||nx>=core.bigmap.width||ny<0||ny>=core.bigmap.height||visited[nx+core.bigmap.width*ny]||core.getBlock(nx,ny)!=null||core.status.checkBlock.damage[nx+core.bigmap.width*ny]>0) continue;
visited[nx+core.bigmap.width*ny]=visited[nowX+core.bigmap.width*nowY]+1; visited[nx+core.bigmap.width*ny]=visited[nowX+core.bigmap.width*nowY]+1;