开关门支持图块贴图

This commit is contained in:
ckcz123 2021-08-12 17:55:51 +08:00
parent 2ffa315acb
commit 94939e72a9
4 changed files with 42 additions and 55 deletions

View File

@ -217,7 +217,7 @@ editor_blockly = function () {
return true;
if ((one.type == 'while' || one.type == 'dowhile') && this.checkAsync(one.data))
return true;
if (one.type == 'if' && (this.checkAsync(one.yes) || this.checkAsync(one.no)))
if (one.type == 'confirm' && (this.checkAsync(one.yes) || this.checkAsync(one.no)))
return true;
if (one.type == 'choices') {
var list = one.choices;
@ -235,7 +235,8 @@ editor_blockly = function () {
}
}
}
if (one.async && one.type != 'animate' && one.type != 'function' && one.type != 'playSound') hasAsync = true;
if (one.type == 'previewUI' && this.checkAsync(one.action)) return true;
if (one.async && one.type != 'animate' && one.type != 'function') hasAsync = true;
if (one.type == 'waitAsync') hasAsync = false;
}
return hasAsync;

View File

@ -494,9 +494,9 @@ events.prototype._sys_openDoor = function (data, callback) {
////// 开门 //////
events.prototype.openDoor = function (x, y, needKey, callback) {
var id = core.getBlockId(x, y);
var block = core.getBlock(x, y);
core.saveAndStopAutomaticRoute();
if (!this._openDoor_check(id, x, y, needKey)) {
if (!this._openDoor_check(block, x, y, needKey)) {
var locked = core.status.lockControl;
core.waitHeroToStop(function () {
if (!locked) core.unlockControl();
@ -513,16 +513,19 @@ events.prototype.openDoor = function (x, y, needKey, callback) {
if (callback) callback();
}, 1); // +1是为了录像检测系统
} else {
this._openDoor_animate(id, x, y, callback);
this._openDoor_animate(block, x, y, callback);
}
}
events.prototype._openDoor_check = function (id, x, y, needKey) {
events.prototype._openDoor_check = function (block, x, y, needKey) {
var clearAndReturn = function () {
core.clearContinueAutomaticRoute();
return false;
}
if (block == null || block.event == null) return clearAndReturn();
var id = block.event.id;
// 是否存在门或暗墙
if (core.material.icons.animates[id] == null && core.material.icons.npc48[id] == null) {
return clearAndReturn();
@ -530,10 +533,8 @@ events.prototype._openDoor_check = function (id, x, y, needKey) {
if (id == 'steelDoor' && core.flags.steelDoorWithoutKey)
needKey = false;
var doorInfo = core.getBlockById(id).event;
if (doorInfo == null || doorInfo.doorInfo == null)
return clearAndReturn();
doorInfo = doorInfo.doorInfo;
var doorInfo = block.event.doorInfo;
if (doorInfo == null) return clearAndReturn();
// Check all keys
var keyInfo = doorInfo.keys || {};
if (needKey) {
@ -564,42 +565,33 @@ events.prototype._openDoor_check = function (id, x, y, needKey) {
return true;
}
events.prototype._openDoor_animate = function (id, x, y, callback) {
var blockInfo = core.getBlockInfo(id);
var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height;
events.prototype._openDoor_animate = function (block, x, y, callback) {
var blockInfo = core.getBlockInfo(block);
blockInfo.opacity = block.opacity;
blockInfo.filter = block.filter;
var speed = (core.getBlockById(id).event.doorInfo.time || 160) / 4;
var speed = (block.event.doorInfo.time || 160) / 4;
var locked = core.status.lockControl;
core.lockControl();
core.status.replay.animate = true;
core.removeBlock(x, y);
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)
core.drawImage('event2', image, 0, posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
var state = 0;
var animate = window.setInterval(function () {
core.clearMap('event', offsetX, offsetY, 32, 32);
if (height > 32)
core.clearMap('event2', offsetX, offsetY + 32 - height, 32, height - 32)
state++;
if (state == 4) {
blockInfo.posX = 0;
core.maps._drawBlockInfo(blockInfo, x, y);
var animate = window.setInterval(function() {
blockInfo.posX++;
if (blockInfo.posX == 4) {
core.maps._removeBlockFromMap(core.status.floorId, block);
clearInterval(animate);
delete core.animateFrame.asyncId[animate];
if (!locked) core.unlockControl();
core.status.replay.animate = false;
core.events.afterOpenDoor(id, x, y);
core.events.afterOpenDoor(block.event.id, x, y);
if (callback) callback();
return;
}
core.drawImage('event', image, 32 * state, posY * height + height - 32, 32, 32, offsetX, offsetY, 32, 32);
if (height > 32)
core.drawImage('event2', image, 32 * state, posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
core.maps._drawBlockInfo(blockInfo, x, y);
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true;
}
@ -3167,37 +3159,30 @@ events.prototype.closeDoor = function (x, y, id, callback) {
if (callback) callback();
return;
}
var doorInfo = (core.getBlockById(id).event || {}).doorInfo;
if (doorInfo == null) {
var block = core.getBlockById(id);
var doorInfo = (block.event || {}).doorInfo;
if (!doorInfo) {
if (callback) callback();
return;
}
// 关门动画
core.playSound(doorInfo.closeSound);
var blockInfo = core.getBlockInfo(id);
var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height;
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 blockInfo = core.getBlockInfo(block);
var speed = (doorInfo.time || 160) / 4;
blockInfo.posX = 3;
core.maps._drawBlockInfo(blockInfo, x, y);
var animate = window.setInterval(function () {
state++;
if (state == 4) {
blockInfo.posX--;
if (blockInfo.posX < 0) {
clearInterval(animate);
delete core.animateFrame.asyncId[animate];
core.setBlock(id, x, y);
core.showBlock(x, y);
if (callback) callback();
return;
}
core.clearMap('event', offsetX, offsetY, 32, 32);
core.drawImage('event', image, 32 * (4-state), posY * height + height - 32, 32, 32, offsetX, offsetY, 32, 32);
if (height > 32)
core.drawImage('event2', image, 32 * (4-state), posY * height, 32, height - 32, offsetX, offsetY + 32 - height, 32, height - 32);
core.maps._drawBlockInfo(blockInfo, x, y);
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
core.animateFrame.asyncId[animate] = true;
}

View File

@ -1939,7 +1939,7 @@ maps.prototype.getBlockInfo = function (block) {
block = this.getBlockByNumber(block);
}
var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name,
image = null, posX = 0, posY = 0, animate = block.event.animate,
image = null, posX = 0, posY = 0, animate = block.event.animate, doorInfo = block.event.doorInfo,
height = block.event.height || 32, faceIds = {}, face = 'down', bigImage = null;
if (id == 'none') return null;
@ -1975,10 +1975,11 @@ maps.prototype.getBlockInfo = function (block) {
} else if (core.material.items[id]) {
name = core.material.items[id].name;
}
if (bigImage != null) animate = 4;
// 非门效果则强制变成四帧动画
if (!doorInfo && bigImage != null) animate = 4;
}
return {number: number, id: id, cls: cls, name: name, image: image, posX: posX,
return {number: number, id: id, cls: cls, name: name, image: image, posX: posX, doorInfo: doorInfo,
posY: posY, height: height, faceIds: faceIds, animate: animate, face: face, bigImage: bigImage};
}

View File

@ -852,7 +852,7 @@ ui.prototype._getPosition = function (content) {
}
}
if(pos=='hero' || pos=='this'){
pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down');
pos = py==null?'center':(py>core.__HALF_SIZE__? 'up':'down');
}
return "";
});