From b3e3ae5f8e889b03ffa5cbf8f2276c8125bbfc8c Mon Sep 17 00:00:00 2001 From: hunhou001 <55705194+hunhou001@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:14:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8B=87=E5=A3=AB=E6=98=BE=E4=BC=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/main/setting.ts | 8 ++++++++ src/plugin/game/fx/heroDetail.ts | 33 ++++++++++++++++++++++++++++++++ src/plugin/shadow/gameShadow.ts | 6 ++++++ 3 files changed, 47 insertions(+) create mode 100644 src/plugin/game/fx/heroDetail.ts diff --git a/src/core/main/setting.ts b/src/core/main/setting.ts index 6efcd05..2eefc5b 100644 --- a/src/core/main/setting.ts +++ b/src/core/main/setting.ts @@ -289,6 +289,11 @@ function handleScreenSetting( } else if (key === 'itemDetail') { // 宝石血瓶显伤 core.setLocalStorage('itemDetail', n); + } else if (key === 'heroDetail') { + // 勇士显伤 + core.setLocalStorage('heroDetail', n); + core.drawHero(); + // storage.setValue('heroDetail', n as boolean); } else if (key === 'transition') { // 界面动画 core.setLocalStorage('transition', n); @@ -352,6 +357,7 @@ mainSetting .register('fullscreen', '全屏游戏', false) .register('halo', '光环显示', true) .register('itemDetail', '宝石血瓶显伤', true) + .register('heroDetail', '勇士显伤', false) .register('transition', '界面动画', false) .register('antiAlias', '抗锯齿', false) .register('fontSize', '字体大小', 16, [8, 28, 1]) @@ -400,6 +406,7 @@ interface SettingStorage { betterLoad: boolean; autoScale: boolean; paraLight: boolean; + heroDetail: boolean; } const storage = new GameStorage( @@ -411,6 +418,7 @@ loading.once('coreInit', () => { 'screen.fullscreen': !!document.fullscreenElement, 'screen.halo': !!storage.getValue('showHalo', true), 'screen.itemDetail': !!storage.getValue('itemDetail', true), + 'screen.heroDetail': !!storage.getValue('heroDetail', false), 'screen.transition': !!storage.getValue('transition', false), 'screen.antiAlias': !!storage.getValue('antiAlias', false), 'screen.fontSize': storage.getValue('fontSize', 16), diff --git a/src/plugin/game/fx/heroDetail.ts b/src/plugin/game/fx/heroDetail.ts new file mode 100644 index 0000000..b1cfa97 --- /dev/null +++ b/src/plugin/game/fx/heroDetail.ts @@ -0,0 +1,33 @@ +function drawHeroDetail(px: number, py: number) { + if (!core.getLocalStorage('heroDetail', false)) return; + const { hp, atk, def } = core.status.hero; + const toDraw = { + atk: { + value: atk, + color: '#FF7A7A' + }, + def: { + value: def, + color: '#00E6F1' + }, + hp: { + value: hp, + color: '#F9FFFF0' + } + }; + + let i = 0; + for (const [key, value] of Object.entries(toDraw)) { + const ctx = core.canvas['hero'].canvas; + core.fillBoldText( + ctx, + value.value.toString(), + px, + py - 10 * i, + value.color as string + ); + i++; + } +} + +export { drawHeroDetail }; diff --git a/src/plugin/shadow/gameShadow.ts b/src/plugin/shadow/gameShadow.ts index b9acf9a..1638736 100644 --- a/src/plugin/shadow/gameShadow.ts +++ b/src/plugin/shadow/gameShadow.ts @@ -13,11 +13,17 @@ import { setShadowNodes } from './shadow'; import { pColor } from '../utils'; +import { drawHeroDetail } from '../game/fx/heroDetail'; export default function init() { const origin4 = control.prototype.drawHero; control.prototype.drawHero = function () { origin4.apply(core.control, arguments); + drawHeroDetail( + core.status.heroCenter.px - 16, + core.status.heroCenter.py + 20 + ); + if (core.getFlag('__heroOpacity__') !== 0) { getAllLights().forEach(v => { if (!v.followHero) return;