Move Directly

This commit is contained in:
oc 2018-01-31 20:29:33 +08:00
parent aa3d86aaff
commit 777e296179

View File

@ -1241,15 +1241,17 @@ core.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
if (core.status.automaticRoute.automaticRouting) { if (core.status.automaticRoute.automaticRouting) {
var lastX = core.status.automaticRoute.destX, lastY=core.status.automaticRoute.destY; var lastX = core.status.automaticRoute.destX, lastY=core.status.automaticRoute.destY;
core.stopAutomaticRoute(); core.stopAutomaticRoute();
if (lastX==destX && lastY==destY && core.canMoveDirectly(destX, destY)) { if (lastX==destX && lastY==destY) {
core.lockControl(); core.lockControl();
setTimeout(function () { setTimeout(function () {
core.unLockControl(); core.unLockControl();
core.clearMap('hero', 0, 0, 416, 416); if (core.canMoveDirectly(destX, destY)) {
core.setHeroLoc('x', destX); core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('y', destY); core.setHeroLoc('x', destX);
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); core.setHeroLoc('y', destY);
core.status.route.push("go:"+destX+":"+destY); core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.status.route.push("move:"+destX+":"+destY);
}
}, 100); }, 100);
} }
return; return;
@ -3735,6 +3737,19 @@ core.prototype.replay = function () {
} }
} }
} }
else if (action.indexOf('move:')==0) {
var pos=action.substring(5).split(":");
var x=parseInt(pos[0]), y=parseInt(pos[1]);
if (core.canMoveDirectly(x,y)) {
core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('x', x);
core.setHeroLoc('y', y);
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.status.route.push("move:"+x+":"+y);
core.replay();
return;
}
}
core.stopReplay(); core.stopReplay();
core.insertAction("录像文件出错"); core.insertAction("录像文件出错");
@ -4109,6 +4124,9 @@ core.prototype.encodeRoute = function (route) {
ans+="P"+t.substring(6); ans+="P"+t.substring(6);
else if (t=='no') else if (t=='no')
ans+='N'; ans+='N';
else if (t.indexOf('move:')==0) {
ans+="M"+t.substring(5);
}
} }
}); });
if (cnt>0) { if (cnt>0) {
@ -4153,6 +4171,7 @@ core.prototype.decodeRoute = function (route) {
case "G": ans.push("getNext"); break; case "G": ans.push("getNext"); break;
case "P": ans.push("input:"+number); break; case "P": ans.push("input:"+number); break;
case "N": ans.push("no"); break; case "N": ans.push("no"); break;
case "M": ++index; ans.push("move:"+number+":"+getNumber()); break;
} }
} }
return ans; return ans;