mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-16 20:24:31 +08:00
feat: 黄蓝门转换机制
This commit is contained in:
1 parent
6417d9218b
commit
763ff0f3e7
15 files changed
+332
-144
No files matched your search
@@ -11,11 +11,12 @@ import { setCanvasFilterByFloorId } from '@/plugin/fx/gameCanvas';
|
||||
* 最大光源数量,必须设置,且光源数不能超过这个值,这个值决定了会预留多少的缓冲区,因此最好尽可能小,同时游戏过程中不可修改
|
||||
* 这个值越大,对显卡尤其是显存的要求会越大,不过考虑到各种设备的性能差异,不建议超过10
|
||||
*/
|
||||
const MAX_LIGHT_NUM = 10;
|
||||
const MAX_LIGHT_NUM = 5;
|
||||
/** 阴影层的Z值 */
|
||||
const Z_INDEX = 55;
|
||||
// 我也不知道这个数怎么来的,试出来是这个,别动就行
|
||||
const FOVY = Math.PI / 1.86;
|
||||
const ignore: Set<AllNumbers> = new Set([660]);
|
||||
|
||||
interface LightConfig {
|
||||
decay: number;
|
||||
@@ -76,7 +77,7 @@ Mota.require('var', 'loading').once('coreInit', () => {
|
||||
103,
|
||||
{ decay: 50, r: 300, color: [0.9333, 0.6, 0.333, 0.3] },
|
||||
{ background: [0, 0, 0, 0.26] },
|
||||
{ decay: 50, r: 200, color: [0, 0, 0, 0] }
|
||||
{ decay: 50, r: 250, color: [0, 0, 0, 0] }
|
||||
);
|
||||
addLightFromBlock(
|
||||
['MT50'],
|
||||
@@ -97,7 +98,7 @@ Mota.require('var', 'loading').once('coreInit', () => {
|
||||
y: core.status.heroCenter.py
|
||||
});
|
||||
});
|
||||
shadow.requestRefresh();
|
||||
if (shadow.followHero.size > 0) shadow.requestRefresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1207,7 +1208,8 @@ export function calMapWalls(floor: FloorIds, nocache: boolean = false) {
|
||||
if (
|
||||
!used.has(x + y * width) &&
|
||||
requiredCls.includes(block.event.cls) &&
|
||||
block.event.noPass
|
||||
block.event.noPass &&
|
||||
!ignore.has(block.id)
|
||||
) {
|
||||
const queue: Block[] = [block];
|
||||
const arr: [number, number][] = [];
|
||||
@@ -1233,7 +1235,8 @@ export function calMapWalls(floor: FloorIds, nocache: boolean = false) {
|
||||
if (
|
||||
requiredCls.includes(blk.event.cls) &&
|
||||
blk.event.noPass &&
|
||||
!used.has(blk.x + blk.y * width)
|
||||
!used.has(blk.x + blk.y * width) &&
|
||||
!ignore.has(blk.id)
|
||||
) {
|
||||
used.add(blk.x + blk.y * width);
|
||||
queue.push(blk);
|
||||
|
||||
@@ -236,6 +236,11 @@ gameKey
|
||||
name: '评论区',
|
||||
defaults: KeyCode.KeyP
|
||||
})
|
||||
.register({
|
||||
id: 'debug',
|
||||
name: '调试模式',
|
||||
defaults: KeyCode.F8
|
||||
})
|
||||
// --------------------
|
||||
.group('general', '通用按键')
|
||||
.register({
|
||||
@@ -557,6 +562,9 @@ gameKey
|
||||
if (flags.shield) flags.shield = false;
|
||||
else flags.shield = true;
|
||||
core.updateStatusBar();
|
||||
})
|
||||
.realize('debug', () => {
|
||||
core.debug();
|
||||
});
|
||||
|
||||
// ----- Storage
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -132,7 +132,8 @@ function checkMockery(loc: string, force: boolean = false) {
|
||||
'npcs',
|
||||
'npc48',
|
||||
'terrains'
|
||||
].includes(block.event.cls)
|
||||
].includes(block.event.cls) &&
|
||||
block.event.noPass
|
||||
) {
|
||||
action.push(
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user