mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-10-31 23:20:18 +08:00
噪声、新楼层
This commit is contained in:
1 parent
16d8e35a81
commit
fd8fb6a068
18 files changed
+449
-95
No files matched your search
@@ -0,0 +1,29 @@
|
||||
export default function init() {
|
||||
return {
|
||||
setGameCanvasFilter,
|
||||
getCanvasFilterByFloorId,
|
||||
setCanvasFilterByFloorId
|
||||
};
|
||||
}
|
||||
|
||||
export function setGameCanvasFilter(filter: string) {
|
||||
['bg', 'bg2', 'event', 'event2', 'fg', 'fg2', 'hero'].forEach(v => {
|
||||
core.canvas[v].canvas.style.filter = filter;
|
||||
});
|
||||
}
|
||||
|
||||
const filterMap: [FloorIds[], string][] = [
|
||||
[['MT50'], 'brightness(80%)contrast(120%)'] // 童心佬的滤镜(
|
||||
];
|
||||
|
||||
export function getCanvasFilterByFloorId(
|
||||
floorId: FloorIds = core.status.floorId
|
||||
) {
|
||||
return filterMap.find(v => v[0].includes(floorId))?.[1] ?? '';
|
||||
}
|
||||
|
||||
export function setCanvasFilterByFloorId(
|
||||
floorId: FloorIds = core.status.floorId
|
||||
) {
|
||||
setGameCanvasFilter(getCanvasFilterByFloorId(floorId));
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
export default function init() {
|
||||
return { createGaussNoise };
|
||||
}
|
||||
|
||||
interface GaussNoiseConfig {
|
||||
/** 分辨率,最小为1,最大为画布长宽的最大值,默认为画布长宽最大值的一半,过大可能会卡顿 */
|
||||
resolution?: number;
|
||||
/** 画布宽度 */
|
||||
width?: number;
|
||||
/** 画布高度 */
|
||||
height?: number;
|
||||
/** 噪声灰度的均值,范围 0 ~ 255 */
|
||||
expectation: number;
|
||||
/** 噪声灰度方差 */
|
||||
deviation: number;
|
||||
/** 目标画布,如果不指定会创建一个新的 */
|
||||
canvas?: HTMLCanvasElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个高斯噪声
|
||||
* @param config 噪声选项
|
||||
* @returns 噪声画布
|
||||
*/
|
||||
export function createGaussNoise(config: GaussNoiseConfig): HTMLCanvasElement {
|
||||
const canvas = config.canvas ?? document.createElement('canvas');
|
||||
canvas.width = config.width ?? core._PX_;
|
||||
canvas.height = config.height ?? core._PY_;
|
||||
canvas.style.imageRendering = 'pixelated';
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
|
||||
const max = Math.max(canvas.width, canvas.height);
|
||||
const resolution = Math.min(max, config.resolution ?? max / 2);
|
||||
|
||||
const step =
|
||||
max === canvas.width
|
||||
? canvas.width / resolution
|
||||
: canvas.height / resolution;
|
||||
|
||||
for (let x = 0; x < canvas.width; x += step) {
|
||||
for (let y = 0; y < canvas.height; y += step) {
|
||||
const random =
|
||||
Math.sqrt(Math.log(Math.random()) * -2) *
|
||||
Math.sin(2 * Math.PI * Math.random());
|
||||
const gray = 255 - random * config.deviation - config.expectation;
|
||||
|
||||
ctx.fillStyle = `rgba(${gray},${gray},${gray},${gray / 255})`;
|
||||
ctx.fillRect(x, y, step, step);
|
||||
}
|
||||
}
|
||||
|
||||
return canvas;
|
||||
}
|
||||
@@ -60,6 +60,9 @@ export class EnemyCollection implements RangeCollection<DamageEnemy> {
|
||||
this.floorId = floorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析本地图的怪物信息
|
||||
*/
|
||||
extract() {
|
||||
core.extractBlocks(this.floorId);
|
||||
core.status.maps[this.floorId].blocks.forEach(v => {
|
||||
|
||||
@@ -27,8 +27,9 @@ export {};
|
||||
async function reloadFloor(data) {
|
||||
// 如果被砍层了直接忽略
|
||||
if (
|
||||
core.status.maps[data].deleted ||
|
||||
core.status.maps[data].forceDelete
|
||||
core.status.maps &&
|
||||
(core.status.maps[data].deleted ||
|
||||
core.status.maps[data].forceDelete)
|
||||
)
|
||||
return;
|
||||
// 首先重新加载main.floors对应的楼层
|
||||
|
||||
@@ -34,7 +34,9 @@ export const jumpIgnoreFloor = [
|
||||
'MT45',
|
||||
'MT46',
|
||||
'MT47',
|
||||
'MT48'
|
||||
'MT48',
|
||||
'MT49',
|
||||
'MT50'
|
||||
];
|
||||
// 跳跃
|
||||
export function jumpSkill() {
|
||||
|
||||
@@ -31,8 +31,49 @@ export default function init() {
|
||||
return { updateShadow, clearShadowCache, setCalShadow };
|
||||
}
|
||||
|
||||
const shadowInfo: Partial<Record<FloorIds, Light[]>> = {};
|
||||
const backgroundInfo: Partial<Record<FloorIds, Color>> = {};
|
||||
const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
|
||||
MT50: [
|
||||
{
|
||||
id: 'mt50_1',
|
||||
x: 144,
|
||||
y: 144,
|
||||
decay: 20,
|
||||
r: 150,
|
||||
color: '#ee995333',
|
||||
noShelter: true
|
||||
},
|
||||
{
|
||||
id: 'mt50_2',
|
||||
x: 336,
|
||||
y: 144,
|
||||
decay: 20,
|
||||
r: 150,
|
||||
color: '#ee995333',
|
||||
noShelter: true
|
||||
},
|
||||
{
|
||||
id: 'mt50_2',
|
||||
x: 336,
|
||||
y: 336,
|
||||
decay: 20,
|
||||
r: 150,
|
||||
color: '#ee995333',
|
||||
noShelter: true
|
||||
},
|
||||
{
|
||||
id: 'mt50_2',
|
||||
x: 144,
|
||||
y: 336,
|
||||
decay: 20,
|
||||
r: 150,
|
||||
color: '#ee995333',
|
||||
noShelter: true
|
||||
}
|
||||
]
|
||||
};
|
||||
const backgroundInfo: Partial<Record<FloorIds, Color>> = {
|
||||
MT50: '#0006'
|
||||
};
|
||||
const blurInfo: Partial<Record<FloorIds, number>> = {};
|
||||
const immersionInfo: Partial<Record<FloorIds, number>> = {};
|
||||
const shadowCache: Partial<Record<FloorIds, Polygon[]>> = {};
|
||||
|
||||
Reference in new issue
Block a user