fix: animateBlock

This commit is contained in:
unanmed 2024-11-22 21:52:25 +08:00
parent a2150990c3
commit 58e6b4be83
5 changed files with 35 additions and 19 deletions

View File

@ -4139,16 +4139,24 @@ maps.prototype.animateBlock = function (loc, type, time, callback) {
typeof type != 'number' typeof type != 'number'
) { ) {
if (callback) callback(); if (callback) callback();
}
// --- 检测所有是0的点
var list = this._animateBlock_getList(loc, type);
if (list.length == 0) {
if (callback) callback();
return; return;
} }
this._animateBlock_drawList(list, 0); loc.forEach(function (t) {
time /= Math.max(core.status.replay.speed, 1); if (type === 'show') core.showBlock(t[0], t[1]);
this._animateBlock_doAnimate(loc, list, type, time, callback); else if (type === 'hide') core.hideBlock(t[0], t[1]);
else if (type === 'remove') core.removeBlock(t[0], t[1]);
else core.showBlock(t[0], t[1]);
});
callback?.();
// --- 检测所有是0的点
// var list = this._animateBlock_getList(loc, type);
// if (list.length == 0) {
// if (callback) callback();
// return;
// }
// this._animateBlock_drawList(list, 0);
// time /= Math.max(core.status.replay.speed, 1);
// this._animateBlock_doAnimate(loc, list, type, time, callback);
}; };
maps.prototype._animateBlock_doAnimate = function ( maps.prototype._animateBlock_doAnimate = function (

View File

@ -157,7 +157,7 @@ main.floors.MT21=
"\t[低级智人]\b[up,hero]或许智慧结晶会告诉我答案吧。", "\t[低级智人]\b[up,hero]或许智慧结晶会告诉我答案吧。",
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.require('var', 'fixedUi').open('chapter', { chapter: '第二章 智慧' });\nMota.Plugin.require('removeMap_g').removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}" "function": "function(){\nif (!core.isReplaying()) Mota.require('var', 'fixedUi').open('chapter', { chapter: '第二章 智慧' });\nMota.Plugin.require('removeMap_g').removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}"
}, },
{ {
"type": "setValue", "type": "setValue",

View File

@ -113,7 +113,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
"140": {"cls":"npcs","id":"blackTrader","faceIds":{"down":"blueTrader","left":"redMSNpc","right":"blackTrader","up":"N532"}}, "140": {"cls":"npcs","id":"blackTrader","faceIds":{"down":"blueTrader","left":"redMSNpc","right":"blackTrader","up":"N532"}},
"141": {"cls":"autotile","id":"autotile4","script":1}, "141": {"cls":"autotile","id":"autotile4","script":1},
"142": {"cls":"autotile","id":"autotile5"}, "142": {"cls":"autotile","id":"autotile5"},
"143": {"cls":"autotile","id":"autotile6","autotileConnection":["A492"]}, "143": {"cls":"autotile","id":"autotile6","autotileConnection":["A492","A494","A497"]},
"144": {"cls":"autotile","id":"autotile7"}, "144": {"cls":"autotile","id":"autotile7"},
"145": {"cls":"autotile","id":"autotile8"}, "145": {"cls":"autotile","id":"autotile8"},
"146": {"cls":"autotile","id":"autotile9","canPass":true}, "146": {"cls":"autotile","id":"autotile9","canPass":true},

View File

@ -339,7 +339,8 @@ export class LayerDoorAnimate implements ILayerRenderExtends {
animate: 0, animate: 0,
frame, frame,
bigImage: false, bigImage: false,
render: renderable.render render: renderable.render,
alpha: 1
}; };
return { renderable: data, count: frame, perTime }; return { renderable: data, count: frame, perTime };
} }

View File

@ -513,6 +513,7 @@ export interface LayerMovingRenderable extends RenderableData {
zIndex: number; zIndex: number;
x: number; x: number;
y: number; y: number;
alpha: number;
} }
export class Layer extends Container { export class Layer extends Container {
@ -842,7 +843,8 @@ export class Layer extends Container {
...renderable, ...renderable,
x: nx, x: nx,
y: ny, y: ny,
zIndex: ny zIndex: ny,
alpha: 1
}); });
} }
} }
@ -858,8 +860,10 @@ export class Layer extends Container {
* autotiles属性的引用 * autotiles属性的引用
*/ */
calAutotiles(x: number, y: number, width: number, height: number) { calAutotiles(x: number, y: number, width: number, height: number) {
const ex = x + width; const sx = x - 1;
const ey = y + height; const sy = y - 1;
const ex = x + width + 1;
const ey = y + height + 1;
const data = this.renderData; const data = this.renderData;
const tile = texture.autotile; const tile = texture.autotile;
const map = maps_90f36752_8815_4be8_b32b_d7fad1d0542e; const map = maps_90f36752_8815_4be8_b32b_d7fad1d0542e;
@ -922,9 +926,10 @@ export class Layer extends Container {
} }
}; };
for (let nx = x; nx < ex; nx++) { for (let nx = sx; nx < ex; nx++) {
for (let ny = y; ny < ey; ny++) { if (nx >= w || nx < 0) continue;
if (nx > w || ny > h) continue; for (let ny = sy; ny < ey; ny++) {
if (ny >= h || ny < 0) continue;
const index = nx + ny * w; const index = nx + ny * w;
const num = data[index]; const num = data[index];
// 特判空气墙与空图块 // 特判空气墙与空图块
@ -1208,7 +1213,7 @@ export class Layer extends Container {
const r = (max1 * max2) ** 2; const r = (max1 * max2) ** 2;
this.movingRenderable.forEach(v => { this.movingRenderable.forEach(v => {
const { x, y, image, render, animate } = v; const { x, y, image, render, animate, alpha } = v;
const ff = frame % v.frame; const ff = frame % v.frame;
const i = animate === -1 ? ff : animate; const i = animate === -1 ? ff : animate;
const [sx, sy, w, h] = render[i]; const [sx, sy, w, h] = render[i];
@ -1226,6 +1231,7 @@ export class Layer extends Container {
return; return;
} }
ctx.globalAlpha = alpha;
ctx.drawImage(image, sx, sy, w, h, px, py, w, h); ctx.drawImage(image, sx, sy, w, h, px, py, w, h);
}); });
} }
@ -1413,7 +1419,8 @@ export class Layer extends Container {
frame: renderable.frame, frame: renderable.frame,
bigImage: renderable.bigImage, bigImage: renderable.bigImage,
animate: -1, animate: -1,
render: renderable.render render: renderable.render,
alpha: 1
}; };
return moving; return moving;
} }