fix: 黄蓝门转换动画

This commit is contained in:
unanmed 2024-08-28 13:44:29 +08:00
parent 85af7259ec
commit 288c76c194

View File

@ -1,5 +1,6 @@
import { backDir, has } from '@/plugin/game/utils'; import { backDir, has } from '@/plugin/game/utils';
import { loading } from '../game'; import { loading } from '../game';
import type { LayerDoorAnimate } from '@/core/render/preset/floor';
export namespace BluePalace { export namespace BluePalace {
type DoorConvertInfo = [id: AllIds, x: number, y: number]; type DoorConvertInfo = [id: AllIds, x: number, y: number];
@ -26,9 +27,6 @@ export namespace BluePalace {
core.extractBlocks(floorId); core.extractBlocks(floorId);
const blocks = core.status.maps[floorId].blocks; const blocks = core.status.maps[floorId].blocks;
const ctx = core.createCanvas(`@doorConvert`, 0, 0, 480, 480, 35);
const time = core.values.animateSpeed / 3;
const toConvert: DoorConvertInfo[] = []; const toConvert: DoorConvertInfo[] = [];
blocks.forEach(v => { blocks.forEach(v => {
if (v.id === 492) { if (v.id === 492) {
@ -52,31 +50,24 @@ export namespace BluePalace {
core.lockControl(); core.lockControl();
core.playSound('door.mp3'); core.playSound('door.mp3');
new Promise<void>(res => { const Adapter = Mota.require('module', 'Render').RenderAdapter;
drawDoors(ctx, toConvert, 0); const adapter = Adapter.get<LayerDoorAnimate>('door-animate');
setTimeout(res, time); const texture = Mota.require('module', 'Render').texture;
}) if (adapter) {
.then(() => { Promise.all(
drawDoors(ctx, toConvert, 1); toConvert.map(v => {
return new Promise<void>(res => { const block = core.initBlock(
setTimeout(res, time); v[1],
}); v[2],
}) texture.idNumberMap[v[0]]
.then(() => { );
drawDoors(ctx, toConvert, 2); return adapter.all('openDoor', block);
return new Promise<void>(res => { })
setTimeout(res, time); ).then(() => {
}); core.unlockControl();
}) core.doAction();
.then(() => {
drawDoors(ctx, toConvert, 3);
return new Promise<void>(res => {
core.unlockControl();
core.deleteCanvas('@doorConvert');
core.doAction();
setTimeout(res, time);
});
}); });
}
} }
// ---------- 传送门部分 // ---------- 传送门部分