mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-15 03:04:30 +08:00
feat: 黄蓝门转换机制
This commit is contained in:
1 parent
6417d9218b
commit
763ff0f3e7
15 files changed
+332
-144
No files matched your search
@@ -7,6 +7,7 @@ import { specials } from './enemy/special';
|
||||
import { gameListener, hook, loading } from './game';
|
||||
import * as battle from './enemy/battle';
|
||||
import * as hero from './hero';
|
||||
import * as miscMechanism from './mechanism/misc';
|
||||
|
||||
// ----- 类注册
|
||||
Mota.register('class', 'DamageEnemy', damage.DamageEnemy);
|
||||
@@ -25,6 +26,9 @@ Mota.register('var', 'hook', hook);
|
||||
Mota.register('var', 'gameListener', gameListener);
|
||||
Mota.register('var', 'loading', loading);
|
||||
// ----- 模块注册
|
||||
Mota.register('module', 'Mechanism', {
|
||||
BluePalace: miscMechanism.BluePalace
|
||||
});
|
||||
|
||||
main.loading = loading;
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { has } from '@/plugin/game/utils';
|
||||
|
||||
export namespace BluePalace {
|
||||
type DoorConvertInfo = [id: AllIds, x: number, y: number];
|
||||
|
||||
function drawDoors(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
convert: DoorConvertInfo[],
|
||||
frame: number
|
||||
) {
|
||||
ctx.clearRect(0, 0, 480, 480);
|
||||
convert.forEach(v => {
|
||||
core.drawIcon(ctx, v[0], v[1] * 32, v[2] * 32, 32, 32, frame);
|
||||
});
|
||||
}
|
||||
|
||||
export function doorConvert(
|
||||
x?: number,
|
||||
y?: number,
|
||||
floorId: FloorIds = core.status.floorId
|
||||
) {
|
||||
core.autosave();
|
||||
core.extractBlocks(floorId);
|
||||
const blocks = core.status.maps[floorId].blocks;
|
||||
|
||||
const ctx = core.createCanvas(`@doorConvert`, 0, 0, 480, 480, 35);
|
||||
const time = core.values.animateSpeed / 4;
|
||||
|
||||
const toConvert: DoorConvertInfo[] = [];
|
||||
blocks.forEach(v => {
|
||||
if (v.id === 492) {
|
||||
core.setBlock(494, v.x, v.y, floorId);
|
||||
toConvert.push(['A492', v.x, v.y]);
|
||||
} else if (v.id === 494) {
|
||||
core.setBlock(492, v.x, v.y, floorId);
|
||||
toConvert.push(['A494', v.x, v.y]);
|
||||
}
|
||||
});
|
||||
|
||||
if (has(x) && has(y)) {
|
||||
core.removeBlock(x, y, floorId);
|
||||
}
|
||||
|
||||
if (core.isReplaying() || core.status.floorId !== floorId) {
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
|
||||
core.lockControl();
|
||||
core.playSound('door.mp3');
|
||||
|
||||
new Promise<void>(res => {
|
||||
drawDoors(ctx, toConvert, 0);
|
||||
setTimeout(res, time);
|
||||
})
|
||||
.then(() => {
|
||||
drawDoors(ctx, toConvert, 1);
|
||||
return new Promise<void>(res => {
|
||||
setTimeout(res, time);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
drawDoors(ctx, toConvert, 2);
|
||||
return new Promise<void>(res => {
|
||||
setTimeout(res, time);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
drawDoors(ctx, toConvert, 3);
|
||||
return new Promise<void>(res => {
|
||||
core.unlockControl();
|
||||
core.deleteCanvas('@doorConvert');
|
||||
core.doAction();
|
||||
setTimeout(res, time);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -24,6 +24,7 @@ import type * as hero from './hero';
|
||||
import type * as damage from './enemy/damage';
|
||||
import type { Logger } from '@/core/common/logger';
|
||||
import type { Danmaku } from '@/core/main/custom/danmaku';
|
||||
import type * as misc from './mechanism/misc';
|
||||
|
||||
interface ClassInterface {
|
||||
// 渲染进程与游戏进程通用
|
||||
@@ -85,7 +86,11 @@ interface VariableInterface {
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
interface ModuleInterface {}
|
||||
interface ModuleInterface {
|
||||
Mechanism: {
|
||||
BluePalace: typeof misc.BluePalace;
|
||||
};
|
||||
}
|
||||
|
||||
interface SystemInterfaceMap {
|
||||
class: ClassInterface;
|
||||
|
||||
Reference in new issue
Block a user