refactor: hero

This commit is contained in:
unanmed 2024-02-03 18:01:15 +08:00
parent 0c9e0543ee
commit db6983b4bd
11 changed files with 14 additions and 80 deletions

View File

@ -2551,7 +2551,6 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (
blocks,
options
) {
// todo: storage获取方式优化
const setting = Mota.require('var', 'mainSetting');
options.ctx.imageSmoothingEnabled = !setting.getValue(
'screen.antiAliasing',

View File

@ -1,5 +1,3 @@
// todo: 更改utils.ts的形式使common文件夹可以同时在渲染进程和游戏进程使用
function has<T>(value: T): value is NonNullable<T> {
return value !== null && value !== undefined;
}

View File

@ -3,8 +3,6 @@ import { Button, InputNumber, Radio } from 'ant-design-vue';
import { mainUi } from './ui';
import { gameKey } from './hotkey';
// todo: 数字类型改为一个输入框,一个加按钮一个减按钮;新增单选框
interface Components {
Default: SettingComponent;
Boolean: SettingComponent;
@ -14,6 +12,8 @@ interface Components {
RadioSetting: (items: string[]) => SettingComponent;
}
export type { Components as SettingDisplayComponents };
export function createSettingComponents() {
const com: Components = {
Default: DefaultSetting,

View File

@ -355,25 +355,11 @@ function handleScreenSetting<T extends number | boolean>(
if (key === 'fullscreen') {
// 全屏
triggerFullscreen(n as boolean);
} else if (key === 'halo') {
// 光环
// core.setLocalStorage('showHalo', n);
} else if (key === 'frag') {
// 打怪特效
// core.setLocalStorage('frag', n);
} else if (key === 'itemDetail') {
// 宝石血瓶显伤
// core.setLocalStorage('itemDetail', n);
} else if (key === 'heroDetail') {
// 勇士显伤
// core.setLocalStorage('heroDetail', n);
core.drawHero();
} else if (key === 'transition') {
// 界面动画
// core.setLocalStorage('transition', n);
} else if (key === 'antiAlias') {
// 抗锯齿
// core.setLocalStorage('antiAlias', n);
for (const canvas of core.dom.gameCanvas) {
if (core.domStyle.hdCanvas.includes(canvas.id)) continue;
if (n) {
@ -384,12 +370,7 @@ function handleScreenSetting<T extends number | boolean>(
}
} else if (key === 'fontSize') {
// 字体大小
// core.setLocalStorage('fontSize', n);
root.style.fontSize = `${n}px`;
} else if (key === 'smoothView') {
// core.setLocalStorage('smoothView', n);
} else if (key === 'criticalGem') {
// core.setLocalStorage('criticalGem', n);
}
}
@ -401,9 +382,6 @@ function handleActionSetting<T extends number | boolean>(
if (key === 'autoSkill') {
// 自动切换技能
flags.autoSkill = n;
} else if (key === 'fixed') {
// 定点查看
// core.setLocalStorage('fixed', n);
}
}
@ -411,15 +389,7 @@ function handleUtilsSetting<T extends number | boolean>(
key: string,
n: T,
o: T
) {
if (key === 'betterLoad') {
// 加载优化
// core.setLocalStorage('betterLoad', n);
} else if (key === 'autoScale') {
// 自动放缩
// core.setLocalStorage('autoScale', n);
}
}
) {}
// ----- 游戏的所有设置项
// todo: 虚拟键盘缩放,小地图楼传缩放

View File

@ -38,39 +38,3 @@ Mota.Plugin.register('frag_r', frag, frag.init);
Mota.Plugin.register('use_r', use);
Mota.Plugin.register('gameCanvas_r', gameCanvas);
Mota.Plugin.register('smooth_r', smooth, smooth.init);
// // todo: 将插件更改为注册形式,分为渲染进程和游戏进程两部分,同时分配优先级
// export function resolvePlugin() {
// const toForward: [keyof Mota['plugin'], any][] = [
// ['pop', pop()],
// ['use', use()],
// ['animate', animate()],
// ['utils', utils()],
// ['status', status()],
// ['fly', fly()],
// ['chase', chase()],
// ['webglUtils', webglUtils()],
// ['shadow', shadow()],
// ['gameShadow', gameShadow()],
// ['achievement', achievement()],
// ['completion', completion()],
// ['path', path()],
// ['gameCanvas', gameCanvas()],
// ['noise', noise()],
// ['smooth', smooth()],
// ['frag', frag()]
// ];
// for (const [key, obj] of toForward) {
// mota.plugin[key] = obj;
// }
// // 完成度相关
// Object.values(floors).forEach((v, i) => {
// const from = core.floorIds.indexOf(v[0]);
// const to = core.floorIds.indexOf(v[1]);
// const all = core.floorIds.slice(from, to + 1);
// floors[i + 1] = all;
// });
// }

View File

@ -6,6 +6,7 @@ import { Range } from '@/plugin/game/range';
import { specials } from './enemy/special';
import { gameListener, hook, loading } from './game';
import * as battle from './enemy/battle';
import * as hero from './hero';
// ----- 类注册
Mota.register('class', 'DamageEnemy', DamageEnemy);
@ -15,6 +16,8 @@ Mota.register('class', 'IndexedEventEmitter', IndexedEventEmitter);
Mota.register('class', 'Range', Range);
// ----- 函数注册
Mota.register('fn', 'getEnemy', battle.getEnemy);
Mota.register('fn', 'getHeroStatusOn', hero.getHeroStatusOn);
Mota.register('fn', 'getHeroStatusOf', hero.getHeroStatusOf);
// ----- 变量注册
Mota.register('var', 'enemySpecials', specials);
Mota.register('var', 'hook', hook);

View File

@ -29,7 +29,8 @@ import type { specials } from './enemy/special';
import type { Range } from '@/plugin/game/range';
import type { KeyCode } from '@/plugin/keyCodes';
import type { Ref } from 'vue';
import * as battle from './enemy/battle';
import type * as battle from './enemy/battle';
import type * as hero from './hero';
interface ClassInterface {
// 渲染进程与游戏进程通用
@ -61,8 +62,9 @@ interface ClassInterface {
}
type _IBattle = typeof battle;
type _IHero = typeof hero;
interface FunctionInterface extends _IBattle {
interface FunctionInterface extends _IBattle, _IHero {
// 定义于渲染进程录像中会进行polyfill但是不执行任何内容
readyAllResource(): void;
// 定义于游戏进程,渲染进程依然可用

View File

@ -6,7 +6,6 @@ import * as replay from './replay';
import * as ui from './ui';
import * as rewrite from './fx/rewrite';
import * as halo from './fx/halo';
import * as hero from '../../game/hero';
import * as loopMap from './loopMap';
import * as removeMap from './removeMap';
import * as shop from './shop';
@ -37,7 +36,6 @@ Mota.Plugin.register('study_g', study);
Mota.Plugin.register('remainEnemy_g', remainEnemy);
Mota.Plugin.register('checkBlock_g', checkBlock, checkBlock.init);
// todo: 这几个不应该放到插件
Mota.Plugin.register('hero_g', hero);
Mota.Plugin.register('ui_g', ui, ui.init);
// export {

View File

@ -43,7 +43,7 @@ export function markEnemy(id: EnemyIds) {
id,
enemy,
mode: 0b011111,
lastAtk: Mota.Plugin.require('hero_g').getHeroStatusOn('atk', 'empty'),
lastAtk: Mota.requireAll('fn').getHeroStatusOn('atk', 'empty'),
lastDamage: enemy.calDamage().damage,
status: 0b0,
update: ref(true)
@ -65,7 +65,7 @@ export function unmarkEnemy(id: EnemyIds) {
}
export function checkMarkedEnemy() {
const { getHeroStatusOn } = Mota.Plugin.require('hero_g');
const { getHeroStatusOn } = Mota.requireAll('fn');
marked.forEach(v => {
const { id, enemy, mode, lastAtk, lastDamage, markDamage } = v;
const atk = getHeroStatusOn('atk', 'empty');

View File

@ -59,7 +59,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) {
'hpmax',
'money'
] as (keyof SelectType<HeroStatus, number>)[];
const { getHeroStatusOn } = Mota.Plugin.require('hero_g');
const { getHeroStatusOn } = Mota.requireAll('fn');
return (
<div id="hero-status">

View File

@ -181,7 +181,7 @@ watch(status, update);
*/
function update() {
toShow.forEach(v => {
hero[v] = Mota.Plugin.require('hero_g').getHeroStatusOn(v);
hero[v] = Mota.requireAll('fn').getHeroStatusOn(v);
});
keys[0] = core.itemCount('yellowKey');
keys[1] = core.itemCount('blueKey');