Fix openDoor in v2

This commit is contained in:
ckcz123 2020-08-13 18:53:08 +08:00
parent 60b102f79f
commit ecf6f8a48d

View File

@ -521,14 +521,19 @@ events.prototype._openDoor_animate = function (id, x, y, callback) {
core.lockControl(); core.lockControl();
core.status.replay.animate = true; core.status.replay.animate = true;
core.removeBlock(x, y); core.removeBlock(x, y);
core.drawImage('event', image, 0, posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); var offsetX = 32 * x, offsetY = 32 * y;
if (core.bigmap.v2) {
offsetX -= core.bigmap.offsetX;
offsetY -= core.bigmap.offsetY;
}
core.drawImage('event', image, 0, posY * height + height - 32, 32, 32, offsetX, offsetY, 32, 32);
if (height > 32) if (height > 32)
core.drawImage('event2', image, 0, posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); core.drawImage('event2', image, 0, posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
var state = 0; var state = 0;
var animate = window.setInterval(function () { var animate = window.setInterval(function () {
core.clearMap('event', 32 * x, 32 * y, 32, 32); core.clearMap('event', offsetX, offsetY, 32, 32);
if (height > 32) if (height > 32)
core.clearMap('event2', x * 32, y * 32 + 32 - height, 32, height - 32) core.clearMap('event2', offsetX, offsetY + 32 - height, 32, height - 32)
state++; state++;
if (state == 4) { if (state == 4) {
clearInterval(animate); clearInterval(animate);
@ -539,9 +544,9 @@ events.prototype._openDoor_animate = function (id, x, y, callback) {
if (callback) callback(); if (callback) callback();
return; return;
} }
core.drawImage('event', image, 32 * state, posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); core.drawImage('event', image, 32 * state, posY * height + height - 32, 32, 32, offsetX, offsetY, 32, 32);
if (height > 32) if (height > 32)
core.drawImage('event2', image, 32 * state, posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); core.drawImage('event2', image, 32 * state, posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true; core.animateFrame.asyncId[animate] = true;
} }
@ -2725,6 +2730,12 @@ events.prototype.closeDoor = function (x, y, id, callback) {
var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height; var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height;
var speed = (doorInfo.time || 160) / 4, state = 0; var speed = (doorInfo.time || 160) / 4, state = 0;
var offsetX = 32 * x, offsetY = 32 * y;
if (core.bigmap.v2) {
offsetX -= core.bigmap.offsetX;
offsetY -= core.bigmap.offsetY;
}
var animate = window.setInterval(function () { var animate = window.setInterval(function () {
state++; state++;
if (state == 4) { if (state == 4) {
@ -2734,10 +2745,10 @@ events.prototype.closeDoor = function (x, y, id, callback) {
if (callback) callback(); if (callback) callback();
return; return;
} }
core.clearMap('event', 32 * x, 32 * y, 32, 32); core.clearMap('event', offsetX, offsetY, 32, 32);
core.drawImage('event', image, 32 * (4-state), posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); core.drawImage('event', image, 32 * (4-state), posY * height + height - 32, 32, 32, offsetX, offsetY, 32, 32);
if (height > 32) if (height > 32)
core.drawImage('event2', image, 32 * (4-state), posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); core.drawImage('event2', image, 32 * (4-state), posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true; core.animateFrame.asyncId[animate] = true;
} }