开关门支持图块贴图

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; return true;
if ((one.type == 'while' || one.type == 'dowhile') && this.checkAsync(one.data)) if ((one.type == 'while' || one.type == 'dowhile') && this.checkAsync(one.data))
return true; 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; return true;
if (one.type == 'choices') { if (one.type == 'choices') {
var list = one.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; if (one.type == 'waitAsync') hasAsync = false;
} }
return hasAsync; return hasAsync;

View File

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

View File

@ -1939,7 +1939,7 @@ maps.prototype.getBlockInfo = function (block) {
block = this.getBlockByNumber(block); block = this.getBlockByNumber(block);
} }
var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name, 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; height = block.event.height || 32, faceIds = {}, face = 'down', bigImage = null;
if (id == 'none') return null; if (id == 'none') return null;
@ -1975,10 +1975,11 @@ maps.prototype.getBlockInfo = function (block) {
} else if (core.material.items[id]) { } else if (core.material.items[id]) {
name = core.material.items[id].name; 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}; 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'){ 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 ""; return "";
}); });