fix move directly bug
This commit is contained in:
parent
f5ca89e27a
commit
67c9c6cd21
@ -377,7 +377,7 @@ control.prototype.clearContinueAutomaticRoute = function () {
|
|||||||
////// 瞬间移动 //////
|
////// 瞬间移动 //////
|
||||||
control.prototype.moveDirectly = function (destX, destY) {
|
control.prototype.moveDirectly = function (destX, destY) {
|
||||||
var ignoreSteps = core.canMoveDirectly(destX, destY);
|
var ignoreSteps = core.canMoveDirectly(destX, destY);
|
||||||
if (ignoreSteps>0) {
|
if (ignoreSteps>=0) {
|
||||||
core.clearMap('hero', 0, 0, 416, 416);
|
core.clearMap('hero', 0, 0, 416, 416);
|
||||||
var lastDirection = core.status.route[core.status.route.length-1];
|
var lastDirection = core.status.route[core.status.route.length-1];
|
||||||
if (['left', 'right', 'up', 'down'].indexOf(lastDirection)>=0)
|
if (['left', 'right', 'up', 'down'].indexOf(lastDirection)>=0)
|
||||||
@ -395,6 +395,8 @@ control.prototype.moveDirectly = function (destX, destY) {
|
|||||||
|
|
||||||
////// 尝试瞬间移动 //////
|
////// 尝试瞬间移动 //////
|
||||||
control.prototype.tryMoveDirectly = function (destX, destY) {
|
control.prototype.tryMoveDirectly = function (destX, destY) {
|
||||||
|
if (Math.abs(core.getHeroLoc('x')-destX)+Math.abs(core.getHeroLoc('y')-destY)<=1)
|
||||||
|
return false;
|
||||||
var testMove = function (dx, dy, dir) {
|
var testMove = function (dx, dy, dir) {
|
||||||
if (dx<0 || dx>12 || dy<0 || dy>12) return false;
|
if (dx<0 || dx>12 || dy<0 || dy>12) return false;
|
||||||
if (core.control.moveDirectly(dx, dy)) {
|
if (core.control.moveDirectly(dx, dy)) {
|
||||||
@ -403,8 +405,8 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(!testMove(destX,destY) && !testMove(destX-1, destY, "right") && !testMove(destX,destY-1,"down")
|
return testMove(destX,destY) || testMove(destX-1, destY, "right") || testMove(destX,destY-1,"down")
|
||||||
&& !testMove(destX,destY+1,"up") && !testMove(destX+1,destY,"left"));
|
|| testMove(destX,destY+1,"up") || testMove(destX+1,destY,"left");
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 设置自动寻路路线 //////
|
////// 设置自动寻路路线 //////
|
||||||
|
|||||||
@ -257,17 +257,17 @@ maps.prototype.canMoveHero = function(x,y,direction,floorId) {
|
|||||||
maps.prototype.canMoveDirectly = function (destX,destY) {
|
maps.prototype.canMoveDirectly = function (destX,destY) {
|
||||||
|
|
||||||
// 不可瞬间移动请返回0
|
// 不可瞬间移动请返回0
|
||||||
if (!core.flags.enableMoveDirectly) return 0;
|
if (!core.flags.enableMoveDirectly) return -1;
|
||||||
|
|
||||||
// 中毒状态:不能
|
// 中毒状态:不能
|
||||||
if (core.hasFlag('poison')) return 0;
|
if (core.hasFlag('poison')) return -1;
|
||||||
|
|
||||||
var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y');
|
var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y');
|
||||||
if (fromX==destX&&fromY==destY) return 0;
|
if (fromX==destX&&fromY==destY) return 0;
|
||||||
|
|
||||||
// 可以无视起点事件
|
// 可以无视起点事件
|
||||||
// if (core.getBlock(fromX,fromY)!=null||core.status.checkBlock.damage[13*fromX+fromY]>0)
|
// if (core.getBlock(fromX,fromY)!=null||core.status.checkBlock.damage[13*fromX+fromY]>0)
|
||||||
// return 0;
|
// return -1;
|
||||||
|
|
||||||
// BFS
|
// BFS
|
||||||
var visited=[], queue=[];
|
var visited=[], queue=[];
|
||||||
@ -286,7 +286,7 @@ maps.prototype.canMoveDirectly = function (destX,destY) {
|
|||||||
queue.push(13*nx+ny);
|
queue.push(13*nx+ny);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype.drawBlock = function (block, animate, dx, dy) {
|
maps.prototype.drawBlock = function (block, animate, dx, dy) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user