Fix openDoor replay Bug

This commit is contained in:
oc 2019-02-25 01:40:21 +08:00
parent 49daef63fb
commit 8d88cc4d01
3 changed files with 14 additions and 9 deletions

View File

@ -176,6 +176,7 @@ core.openDoor(id, x, y, needKey, callback) [异步]
尝试开门操作。id为目标点的IDx和y为坐标needKey表示是否需要使用钥匙callback为开门完毕后的回调函数。
id可为null代表使用地图上的值。
例如core.openDoor('yellowDoor', 10, 3, false, function() {console.log("1")})
此函数返回true代表成功开门并将执行callback回调返回false代表无法开门且不会执行回调函数。
core.battle(id, x, y, force, callback) [异步]

View File

@ -623,7 +623,7 @@ core.prototype.nearHero = function (x, y) {
////// 开门 //////
core.prototype.openDoor = function (id, x, y, needKey, callback) {
core.events.openDoor(id, x, y, needKey, callback);
return core.events.openDoor(id, x, y, needKey, callback);
}
////// 战斗 //////

View File

@ -864,11 +864,15 @@ events.prototype.doAction = function() {
y = core.calValue(data.loc[1], prefix);
}
var floorId=data.floorId || core.status.floorId;
if (floorId==core.status.floorId)
core.openDoor(null, x, y, data.needKey, function() {
if (floorId==core.status.floorId) {
var _callback = function () {
core.lockControl();
core.events.doAction();
})
}
if (!core.openDoor(null, x, y, data.needKey, _callback)) {
_callback();
}
}
else {
core.removeBlock(x, y, floorId);
this.doAction();
@ -1423,8 +1427,7 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) {
// 是否存在门
if (!core.terrainExists(x, y, id) || !(id.endsWith("Door") || id.endsWith("Wall"))
|| !core.isset(core.material.icons.animates[id])) {
if (core.isset(callback)) callback();
return;
return false;
}
if (core.status.automaticRoute.moveStepBeforeStop.length==0) {
core.status.automaticRoute.moveStepBeforeStop=core.status.automaticRoute.autoStepRoutes.slice(core.status.automaticRoute.autoStep-1,core.status.automaticRoute.autoStepRoutes.length);
@ -1440,8 +1443,7 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) {
core.drawTip("你没有" + ((core.material.items[key]||{}).name||"钥匙"));
else core.drawTip("无法开启此门");
core.clearContinueAutomaticRoute();
if (core.isset(callback)) callback();
return;
return false;
}
core.autosave(true);
core.removeItem(key);
@ -1469,7 +1471,9 @@ events.prototype.openDoor = function (id, x, y, needKey, callback) {
}
core.clearMap('event', 32 * x, 32 * y, 32, 32);
core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
}, speed / core.status.replay.speed)
}, speed / core.status.replay.speed);
return true;
}
////// 战斗 //////