mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-03-01 01:57:05 +08:00
refactor: hero
This commit is contained in:
parent
0c9e0543ee
commit
db6983b4bd
@ -2551,7 +2551,6 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (
|
|||||||
blocks,
|
blocks,
|
||||||
options
|
options
|
||||||
) {
|
) {
|
||||||
// todo: storage获取方式优化
|
|
||||||
const setting = Mota.require('var', 'mainSetting');
|
const setting = Mota.require('var', 'mainSetting');
|
||||||
options.ctx.imageSmoothingEnabled = !setting.getValue(
|
options.ctx.imageSmoothingEnabled = !setting.getValue(
|
||||||
'screen.antiAliasing',
|
'screen.antiAliasing',
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// todo: 更改utils.ts的形式,使common文件夹可以同时在渲染进程和游戏进程使用
|
|
||||||
|
|
||||||
function has<T>(value: T): value is NonNullable<T> {
|
function has<T>(value: T): value is NonNullable<T> {
|
||||||
return value !== null && value !== undefined;
|
return value !== null && value !== undefined;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ import { Button, InputNumber, Radio } from 'ant-design-vue';
|
|||||||
import { mainUi } from './ui';
|
import { mainUi } from './ui';
|
||||||
import { gameKey } from './hotkey';
|
import { gameKey } from './hotkey';
|
||||||
|
|
||||||
// todo: 数字类型改为一个输入框,一个加按钮一个减按钮;新增单选框
|
|
||||||
|
|
||||||
interface Components {
|
interface Components {
|
||||||
Default: SettingComponent;
|
Default: SettingComponent;
|
||||||
Boolean: SettingComponent;
|
Boolean: SettingComponent;
|
||||||
@ -14,6 +12,8 @@ interface Components {
|
|||||||
RadioSetting: (items: string[]) => SettingComponent;
|
RadioSetting: (items: string[]) => SettingComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type { Components as SettingDisplayComponents };
|
||||||
|
|
||||||
export function createSettingComponents() {
|
export function createSettingComponents() {
|
||||||
const com: Components = {
|
const com: Components = {
|
||||||
Default: DefaultSetting,
|
Default: DefaultSetting,
|
||||||
|
@ -355,25 +355,11 @@ function handleScreenSetting<T extends number | boolean>(
|
|||||||
if (key === 'fullscreen') {
|
if (key === 'fullscreen') {
|
||||||
// 全屏
|
// 全屏
|
||||||
triggerFullscreen(n as boolean);
|
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') {
|
} else if (key === 'heroDetail') {
|
||||||
// 勇士显伤
|
// 勇士显伤
|
||||||
// core.setLocalStorage('heroDetail', n);
|
|
||||||
core.drawHero();
|
core.drawHero();
|
||||||
} else if (key === 'transition') {
|
|
||||||
// 界面动画
|
|
||||||
// core.setLocalStorage('transition', n);
|
|
||||||
} else if (key === 'antiAlias') {
|
} else if (key === 'antiAlias') {
|
||||||
// 抗锯齿
|
// 抗锯齿
|
||||||
// core.setLocalStorage('antiAlias', n);
|
|
||||||
for (const canvas of core.dom.gameCanvas) {
|
for (const canvas of core.dom.gameCanvas) {
|
||||||
if (core.domStyle.hdCanvas.includes(canvas.id)) continue;
|
if (core.domStyle.hdCanvas.includes(canvas.id)) continue;
|
||||||
if (n) {
|
if (n) {
|
||||||
@ -384,12 +370,7 @@ function handleScreenSetting<T extends number | boolean>(
|
|||||||
}
|
}
|
||||||
} else if (key === 'fontSize') {
|
} else if (key === 'fontSize') {
|
||||||
// 字体大小
|
// 字体大小
|
||||||
// core.setLocalStorage('fontSize', n);
|
|
||||||
root.style.fontSize = `${n}px`;
|
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') {
|
if (key === 'autoSkill') {
|
||||||
// 自动切换技能
|
// 自动切换技能
|
||||||
flags.autoSkill = n;
|
flags.autoSkill = n;
|
||||||
} else if (key === 'fixed') {
|
|
||||||
// 定点查看
|
|
||||||
// core.setLocalStorage('fixed', n);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,15 +389,7 @@ function handleUtilsSetting<T extends number | boolean>(
|
|||||||
key: string,
|
key: string,
|
||||||
n: T,
|
n: T,
|
||||||
o: T
|
o: T
|
||||||
) {
|
) {}
|
||||||
if (key === 'betterLoad') {
|
|
||||||
// 加载优化
|
|
||||||
// core.setLocalStorage('betterLoad', n);
|
|
||||||
} else if (key === 'autoScale') {
|
|
||||||
// 自动放缩
|
|
||||||
// core.setLocalStorage('autoScale', n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----- 游戏的所有设置项
|
// ----- 游戏的所有设置项
|
||||||
// todo: 虚拟键盘缩放,小地图楼传缩放
|
// todo: 虚拟键盘缩放,小地图楼传缩放
|
||||||
|
@ -38,39 +38,3 @@ Mota.Plugin.register('frag_r', frag, frag.init);
|
|||||||
Mota.Plugin.register('use_r', use);
|
Mota.Plugin.register('use_r', use);
|
||||||
Mota.Plugin.register('gameCanvas_r', gameCanvas);
|
Mota.Plugin.register('gameCanvas_r', gameCanvas);
|
||||||
Mota.Plugin.register('smooth_r', smooth, smooth.init);
|
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;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
@ -6,6 +6,7 @@ import { Range } from '@/plugin/game/range';
|
|||||||
import { specials } from './enemy/special';
|
import { specials } from './enemy/special';
|
||||||
import { gameListener, hook, loading } from './game';
|
import { gameListener, hook, loading } from './game';
|
||||||
import * as battle from './enemy/battle';
|
import * as battle from './enemy/battle';
|
||||||
|
import * as hero from './hero';
|
||||||
|
|
||||||
// ----- 类注册
|
// ----- 类注册
|
||||||
Mota.register('class', 'DamageEnemy', DamageEnemy);
|
Mota.register('class', 'DamageEnemy', DamageEnemy);
|
||||||
@ -15,6 +16,8 @@ Mota.register('class', 'IndexedEventEmitter', IndexedEventEmitter);
|
|||||||
Mota.register('class', 'Range', Range);
|
Mota.register('class', 'Range', Range);
|
||||||
// ----- 函数注册
|
// ----- 函数注册
|
||||||
Mota.register('fn', 'getEnemy', battle.getEnemy);
|
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', 'enemySpecials', specials);
|
||||||
Mota.register('var', 'hook', hook);
|
Mota.register('var', 'hook', hook);
|
||||||
|
@ -29,7 +29,8 @@ import type { specials } from './enemy/special';
|
|||||||
import type { Range } from '@/plugin/game/range';
|
import type { Range } from '@/plugin/game/range';
|
||||||
import type { KeyCode } from '@/plugin/keyCodes';
|
import type { KeyCode } from '@/plugin/keyCodes';
|
||||||
import type { Ref } from 'vue';
|
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 {
|
interface ClassInterface {
|
||||||
// 渲染进程与游戏进程通用
|
// 渲染进程与游戏进程通用
|
||||||
@ -61,8 +62,9 @@ interface ClassInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type _IBattle = typeof battle;
|
type _IBattle = typeof battle;
|
||||||
|
type _IHero = typeof hero;
|
||||||
|
|
||||||
interface FunctionInterface extends _IBattle {
|
interface FunctionInterface extends _IBattle, _IHero {
|
||||||
// 定义于渲染进程,录像中会进行polyfill,但是不执行任何内容
|
// 定义于渲染进程,录像中会进行polyfill,但是不执行任何内容
|
||||||
readyAllResource(): void;
|
readyAllResource(): void;
|
||||||
// 定义于游戏进程,渲染进程依然可用
|
// 定义于游戏进程,渲染进程依然可用
|
||||||
|
@ -6,7 +6,6 @@ import * as replay from './replay';
|
|||||||
import * as ui from './ui';
|
import * as ui from './ui';
|
||||||
import * as rewrite from './fx/rewrite';
|
import * as rewrite from './fx/rewrite';
|
||||||
import * as halo from './fx/halo';
|
import * as halo from './fx/halo';
|
||||||
import * as hero from '../../game/hero';
|
|
||||||
import * as loopMap from './loopMap';
|
import * as loopMap from './loopMap';
|
||||||
import * as removeMap from './removeMap';
|
import * as removeMap from './removeMap';
|
||||||
import * as shop from './shop';
|
import * as shop from './shop';
|
||||||
@ -37,7 +36,6 @@ Mota.Plugin.register('study_g', study);
|
|||||||
Mota.Plugin.register('remainEnemy_g', remainEnemy);
|
Mota.Plugin.register('remainEnemy_g', remainEnemy);
|
||||||
Mota.Plugin.register('checkBlock_g', checkBlock, checkBlock.init);
|
Mota.Plugin.register('checkBlock_g', checkBlock, checkBlock.init);
|
||||||
// todo: 这几个不应该放到插件
|
// todo: 这几个不应该放到插件
|
||||||
Mota.Plugin.register('hero_g', hero);
|
|
||||||
Mota.Plugin.register('ui_g', ui, ui.init);
|
Mota.Plugin.register('ui_g', ui, ui.init);
|
||||||
|
|
||||||
// export {
|
// export {
|
||||||
|
@ -43,7 +43,7 @@ export function markEnemy(id: EnemyIds) {
|
|||||||
id,
|
id,
|
||||||
enemy,
|
enemy,
|
||||||
mode: 0b011111,
|
mode: 0b011111,
|
||||||
lastAtk: Mota.Plugin.require('hero_g').getHeroStatusOn('atk', 'empty'),
|
lastAtk: Mota.requireAll('fn').getHeroStatusOn('atk', 'empty'),
|
||||||
lastDamage: enemy.calDamage().damage,
|
lastDamage: enemy.calDamage().damage,
|
||||||
status: 0b0,
|
status: 0b0,
|
||||||
update: ref(true)
|
update: ref(true)
|
||||||
@ -65,7 +65,7 @@ export function unmarkEnemy(id: EnemyIds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function checkMarkedEnemy() {
|
export function checkMarkedEnemy() {
|
||||||
const { getHeroStatusOn } = Mota.Plugin.require('hero_g');
|
const { getHeroStatusOn } = Mota.requireAll('fn');
|
||||||
marked.forEach(v => {
|
marked.forEach(v => {
|
||||||
const { id, enemy, mode, lastAtk, lastDamage, markDamage } = v;
|
const { id, enemy, mode, lastAtk, lastDamage, markDamage } = v;
|
||||||
const atk = getHeroStatusOn('atk', 'empty');
|
const atk = getHeroStatusOn('atk', 'empty');
|
||||||
|
@ -59,7 +59,7 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) {
|
|||||||
'hpmax',
|
'hpmax',
|
||||||
'money'
|
'money'
|
||||||
] as (keyof SelectType<HeroStatus, number>)[];
|
] as (keyof SelectType<HeroStatus, number>)[];
|
||||||
const { getHeroStatusOn } = Mota.Plugin.require('hero_g');
|
const { getHeroStatusOn } = Mota.requireAll('fn');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="hero-status">
|
<div id="hero-status">
|
||||||
|
@ -181,7 +181,7 @@ watch(status, update);
|
|||||||
*/
|
*/
|
||||||
function update() {
|
function update() {
|
||||||
toShow.forEach(v => {
|
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[0] = core.itemCount('yellowKey');
|
||||||
keys[1] = core.itemCount('blueKey');
|
keys[1] = core.itemCount('blueKey');
|
||||||
|
Loading…
Reference in New Issue
Block a user