From 3913229e52205b165d382a8c7fe78f1cddd04900 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 4 Mar 2024 19:00:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9D=82=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/project/functions.js | 34 ++++++++++++------------ public/project/plugins.js | 46 +++++++++++++++++++++++++++++++++ src/plugin/fx/gameCanvas.ts | 4 +-- src/plugin/shadow/gameShadow.ts | 8 +++--- 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/public/project/functions.js b/public/project/functions.js index 449a00f..e51c2c3 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -428,17 +428,18 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { core.events.checkLvUp(); const getHeroStatusOn = Mota.require('fn', 'getHeroStatusOn'); + const { has } = Mota.Plugin.require('utils_g'); // 检查HP上限 if (core.flags.statusBarItems.indexOf('enableHPMax') >= 0) { - core.setStatus( - 'hp', - Math.min(getHeroStatusOn('hpmax'), core.getStatus('hp')) - ); + const hpmax = getHeroStatusOn('hpmax'); + if (core.status.hero.hp > hpmax) { + core.status.hero.hp = hpmax; + } } // 设置生命上限、生命值、攻防护盾金币和经验值 - var statusList = [ + const statusList = [ 'hpmax', 'hp', 'mana', @@ -448,29 +449,26 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { 'money', 'exp' ]; - statusList.forEach(function (item) { + statusList.forEach(item => { // 向下取整 core.status.hero[item] = Math.floor(core.status.hero[item]); }); // 设置魔力值; status:manamax 只有在非负时才生效。 - if ( - core.status.hero.manamax != null && - core.getRealStatus('manamax') >= 0 - ) { - core.status.hero.mana = Math.min( - core.status.hero.mana, - core.getRealStatus('manamax') - ); + if (has(core.status.hero.manamax)) { + const manamax = getHeroStatusOn('manamax'); + if (manamax >= 0 && getHeroStatusOn('mana') > manamax) { + core.status.hero.mana = manamax; + } } // 难度 - if (core.statusBar.hard.innerText != core.status.hard) { + if (core.statusBar.hard.innerText !== core.status.hard) { core.statusBar.hard.innerText = core.status.hard; } - var hardColor = core.getFlag('__hardColor__'); - if (hardColor == null) core.statusBar.hard.innerText = ''; - if (core.statusBar.hard.getAttribute('_style') != hardColor) { + const hardColor = core.getFlag('__hardColor__'); + if (!has(hardColor)) core.statusBar.hard.innerText = ''; + if (core.statusBar.hard.getAttribute('_style') !== hardColor) { core.statusBar.hard.style.color = hardColor; core.statusBar.hard.setAttribute('_style', hardColor); } diff --git a/public/project/plugins.js b/public/project/plugins.js index 280b8ca..567507d 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -1312,5 +1312,51 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.insertAction(actions); } }); + }, + misc: function () { + // 把一些杂项放在这了 + + const { loading } = Mota.requireAll('var'); + + Mota.r(() => { + // 楼层滤镜配置 + loading.once('coreInit', () => { + const { filterMap } = Mota.Plugin.require('gameCanvas_r'); + // 楼层滤镜是一系列数组,数组第一项是一个数组,表示所有使用这个滤镜的楼层,第二项是滤镜内容 + filterMap.push( + [ + ['sample0', 'sample1', 'sample2'], // 楼层列表 + 'brightness(120%)' // 滤镜内容 + ], + [['MT0'], 'contrast(120%)'] + ); + }); + + // 点光源配置,参考插件库点光源插件的配置方式 + loading.once('coreInit', () => { + const { shadowInfo, backgroundInfo, blurInfo, immersionInfo } = + Mota.Plugin.require('gameShadow_r'); + const { pColor } = Mota.require('module', 'RenderUtils'); + + // 光源信息 + shadowInfo.MT0 = [ + { + id: 'mt0_1', + x: 144, + y: 144, + decay: 20, + r: 150, + color: pColor('#e953'), + noShelter: true + } + ]; + // 背景色 + backgroundInfo.MT0 = pColor('#0006'); + // 虚化程度 + blurInfo.MT0 = 3; + // 浸入墙壁程度 + immersionInfo.MT0 = 4; + }); + }); } }; diff --git a/src/plugin/fx/gameCanvas.ts b/src/plugin/fx/gameCanvas.ts index 8f8f8eb..9ff7d8c 100644 --- a/src/plugin/fx/gameCanvas.ts +++ b/src/plugin/fx/gameCanvas.ts @@ -12,9 +12,7 @@ export function setGameCanvasFilter(filter: string) { }); } -const filterMap: [FloorIds[], string][] = [ - [['MT50'], 'brightness(80%)contrast(120%)'] // 童心佬的滤镜( -]; +export const filterMap: [FloorIds[], string][] = []; export function getCanvasFilterByFloorId( floorId: FloorIds = core.status.floorId diff --git a/src/plugin/shadow/gameShadow.ts b/src/plugin/shadow/gameShadow.ts index 4c20101..3ed0bbc 100644 --- a/src/plugin/shadow/gameShadow.ts +++ b/src/plugin/shadow/gameShadow.ts @@ -46,7 +46,7 @@ export function init() { }); } -const shadowInfo: Partial<Record<FloorIds, Light[]>> = { +export const shadowInfo: Partial<Record<FloorIds, Light[]>> = { MT50: [ { id: 'mt50_1', @@ -86,11 +86,11 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = { } ] }; -const backgroundInfo: Partial<Record<FloorIds, Color>> = { +export const backgroundInfo: Partial<Record<FloorIds, Color>> = { MT50: pColor('#0006') }; -const blurInfo: Partial<Record<FloorIds, number>> = {}; -const immersionInfo: Partial<Record<FloorIds, number>> = {}; +export const blurInfo: Partial<Record<FloorIds, number>> = {}; +export const immersionInfo: Partial<Record<FloorIds, number>> = {}; const shadowCache: Partial<Record<FloorIds, Polygon[]>> = {}; let calMapShadow = true;