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为目标点的IDx和y为坐标needKey表示是否需要使用钥匙callback为开门完毕后的回调函数。
id可为null代表使用地图上的值。 id可为null代表使用地图上的值。
例如core.openDoor('yellowDoor', 10, 3, false, function() {console.log("1")}) 例如core.openDoor('yellowDoor', 10, 3, false, function() {console.log("1")})
此函数返回true代表成功开门并将执行callback回调返回false代表无法开门且不会执行回调函数。
core.battle(id, x, y, force, callback) [异步] 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.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); y = core.calValue(data.loc[1], prefix);
} }
var floorId=data.floorId || core.status.floorId; var floorId=data.floorId || core.status.floorId;
if (floorId==core.status.floorId) if (floorId==core.status.floorId) {
core.openDoor(null, x, y, data.needKey, function() { var _callback = function () {
core.lockControl(); core.lockControl();
core.events.doAction(); core.events.doAction();
}) }
if (!core.openDoor(null, x, y, data.needKey, _callback)) {
_callback();
}
}
else { else {
core.removeBlock(x, y, floorId); core.removeBlock(x, y, floorId);
this.doAction(); 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")) if (!core.terrainExists(x, y, id) || !(id.endsWith("Door") || id.endsWith("Wall"))
|| !core.isset(core.material.icons.animates[id])) { || !core.isset(core.material.icons.animates[id])) {
if (core.isset(callback)) callback(); return false;
return;
} }
if (core.status.automaticRoute.moveStepBeforeStop.length==0) { 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); 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||"钥匙")); core.drawTip("你没有" + ((core.material.items[key]||{}).name||"钥匙"));
else core.drawTip("无法开启此门"); else core.drawTip("无法开启此门");
core.clearContinueAutomaticRoute(); core.clearContinueAutomaticRoute();
if (core.isset(callback)) callback(); return false;
return;
} }
core.autosave(true); core.autosave(true);
core.removeItem(key); 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.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); 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;
} }
////// 战斗 ////// ////// 战斗 //////