feat: 勇士显伤

This commit is contained in:
hunhou001 2023-09-27 12:14:05 +08:00
parent c242018ee8
commit b3e3ae5f8e
3 changed files with 47 additions and 0 deletions

View File

@ -289,6 +289,11 @@ function handleScreenSetting<T extends number | boolean>(
} 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<SettingStorage>(
@ -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),

View File

@ -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 };

View File

@ -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;