Merge pull request #2 from hunhou001/dev-hunhou001

feat: 勇士显伤
This commit is contained in:
AncTe 2023-09-27 19:11:43 +08:00 committed by GitHub
commit 4e1f1b45c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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') { } else if (key === 'itemDetail') {
// 宝石血瓶显伤 // 宝石血瓶显伤
core.setLocalStorage('itemDetail', n); core.setLocalStorage('itemDetail', n);
} else if (key === 'heroDetail') {
// 勇士显伤
core.setLocalStorage('heroDetail', n);
core.drawHero();
// storage.setValue('heroDetail', n as boolean);
} else if (key === 'transition') { } else if (key === 'transition') {
// 界面动画 // 界面动画
core.setLocalStorage('transition', n); core.setLocalStorage('transition', n);
@ -352,6 +357,7 @@ mainSetting
.register('fullscreen', '全屏游戏', false) .register('fullscreen', '全屏游戏', false)
.register('halo', '光环显示', true) .register('halo', '光环显示', true)
.register('itemDetail', '宝石血瓶显伤', true) .register('itemDetail', '宝石血瓶显伤', true)
.register('heroDetail', '勇士显伤', false)
.register('transition', '界面动画', false) .register('transition', '界面动画', false)
.register('antiAlias', '抗锯齿', false) .register('antiAlias', '抗锯齿', false)
.register('fontSize', '字体大小', 16, [8, 28, 1]) .register('fontSize', '字体大小', 16, [8, 28, 1])
@ -400,6 +406,7 @@ interface SettingStorage {
betterLoad: boolean; betterLoad: boolean;
autoScale: boolean; autoScale: boolean;
paraLight: boolean; paraLight: boolean;
heroDetail: boolean;
} }
const storage = new GameStorage<SettingStorage>( const storage = new GameStorage<SettingStorage>(
@ -411,6 +418,7 @@ loading.once('coreInit', () => {
'screen.fullscreen': !!document.fullscreenElement, 'screen.fullscreen': !!document.fullscreenElement,
'screen.halo': !!storage.getValue('showHalo', true), 'screen.halo': !!storage.getValue('showHalo', true),
'screen.itemDetail': !!storage.getValue('itemDetail', true), 'screen.itemDetail': !!storage.getValue('itemDetail', true),
'screen.heroDetail': !!storage.getValue('heroDetail', false),
'screen.transition': !!storage.getValue('transition', false), 'screen.transition': !!storage.getValue('transition', false),
'screen.antiAlias': !!storage.getValue('antiAlias', false), 'screen.antiAlias': !!storage.getValue('antiAlias', false),
'screen.fontSize': storage.getValue('fontSize', 16), '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 setShadowNodes
} from './shadow'; } from './shadow';
import { pColor } from '../utils'; import { pColor } from '../utils';
import { drawHeroDetail } from '../game/fx/heroDetail';
export default function init() { export default function init() {
const origin4 = control.prototype.drawHero; const origin4 = control.prototype.drawHero;
control.prototype.drawHero = function () { control.prototype.drawHero = function () {
origin4.apply(core.control, arguments); origin4.apply(core.control, arguments);
drawHeroDetail(
core.status.heroCenter.px - 16,
core.status.heroCenter.py + 20
);
if (core.getFlag('__heroOpacity__') !== 0) { if (core.getFlag('__heroOpacity__') !== 0) {
getAllLights().forEach(v => { getAllLights().forEach(v => {
if (!v.followHero) return; if (!v.followHero) return;