mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-04-18 17:48:52 +08:00
refactor: src 除入口外全部移入 monorepo
This commit is contained in:
parent
cca10a429c
commit
0679bbb1a5
3
packages-user/client-modules/package.json
Normal file
3
packages-user/client-modules/package.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"name": "@user/client-modules"
|
||||||
|
}
|
@ -16,7 +16,7 @@ export interface CurrentEnemy {
|
|||||||
onMapEnemy: DamageEnemy[];
|
onMapEnemy: DamageEnemy[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
export function patchBattle() {
|
||||||
const patch = new Patch(PatchClass.Enemys);
|
const patch = new Patch(PatchClass.Enemys);
|
||||||
|
|
||||||
patch.add('canBattle', function (x, y, floorId) {
|
patch.add('canBattle', function (x, y, floorId) {
|
||||||
@ -252,7 +252,7 @@ function init() {
|
|||||||
hook.emit('afterBattle', enemy, x, y);
|
hook.emit('afterBattle', enemy, x, y);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
loading.once('coreInit', init);
|
loading.once('coreInit', patchBattle);
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Enemys {
|
interface Enemys {
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
import { patchBattle } from './battle';
|
||||||
|
|
||||||
|
export function patchAll() {
|
||||||
|
patchBattle();
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
import { getHeroStatusOf, getHeroStatusOn } from '../state/hero';
|
import { getHeroStatusOf, getHeroStatusOn } from '../state/hero';
|
||||||
import { Range } from '@user/data-utils';
|
import { Range, ensureArray, has, manhattan } from '@user/data-utils';
|
||||||
import { ensureArray, has, manhattan } from '@/plugin/game/utils';
|
|
||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
import { hook } from '@user/data-base';
|
import { hook } from '@user/data-base';
|
||||||
import { HeroSkill, NightSpecial } from '../mechanism/misc';
|
import { HeroSkill, NightSpecial } from '../mechanism/misc';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { backDir, has } from '@/plugin/game/utils';
|
import { backDir, has } from '@user/data-utils';
|
||||||
import { loading } from '@user/data-base';
|
import { loading } from '@user/data-base';
|
||||||
import type { LayerDoorAnimate } from '@motajs/render';
|
import type { LayerDoorAnimate } from '@motajs/render';
|
||||||
import { getSkillLevel } from '@/plugin/game/skillTree';
|
import { getSkillLevel } from './skillTree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一些零散机制的数据
|
* 一些零散机制的数据
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HeroSkill } from '@/game/mechanism/misc';
|
import { HeroSkill } from './misc';
|
||||||
|
|
||||||
let levels: number[] = [];
|
let levels: number[] = [];
|
||||||
|
|
@ -1 +1,2 @@
|
|||||||
export * from './range';
|
export * from './range';
|
||||||
|
export * from './utils';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@motajs/entry-client",
|
"name": "@user/entry-client",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@motajs/client": "workspace:*",
|
"@motajs/client": "workspace:*",
|
||||||
"@motajs/client-base": "workspace:*",
|
"@motajs/client-base": "workspace:*",
|
||||||
@ -16,6 +16,8 @@
|
|||||||
"@motajs/legacy-client": "workspace:*",
|
"@motajs/legacy-client": "workspace:*",
|
||||||
"@motajs/legacy-data": "workspace:*",
|
"@motajs/legacy-data": "workspace:*",
|
||||||
"@motajs/legacy-ui": "workspace:*",
|
"@motajs/legacy-ui": "workspace:*",
|
||||||
"@motajs/legacy-system": "workspace:*"
|
"@motajs/legacy-system": "workspace:*",
|
||||||
|
"@user/client-modules": "workspace:*",
|
||||||
|
"@user/legacy-plugin-client": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,8 @@ import * as RenderVue from '@motajs/render-vue';
|
|||||||
import * as System from '@motajs/system';
|
import * as System from '@motajs/system';
|
||||||
import * as SystemAction from '@motajs/system-action';
|
import * as SystemAction from '@motajs/system-action';
|
||||||
import * as SystemUI from '@motajs/system-ui';
|
import * as SystemUI from '@motajs/system-ui';
|
||||||
|
import * as ClientModules from '@user/client-modules';
|
||||||
|
import * as LegacyPluginClient from '@user/legacy-plugin-client';
|
||||||
|
|
||||||
export function create() {
|
export function create() {
|
||||||
Mota.register('@motajs/client', Client);
|
Mota.register('@motajs/client', Client);
|
||||||
@ -31,4 +33,6 @@ export function create() {
|
|||||||
Mota.register('@motajs/system', System);
|
Mota.register('@motajs/system', System);
|
||||||
Mota.register('@motajs/system-action', SystemAction);
|
Mota.register('@motajs/system-action', SystemAction);
|
||||||
Mota.register('@motajs/system-ui', SystemUI);
|
Mota.register('@motajs/system-ui', SystemUI);
|
||||||
|
Mota.register('@user/client-modules', ClientModules);
|
||||||
|
Mota.register('@user/legacy-plugin-client', LegacyPluginClient);
|
||||||
}
|
}
|
||||||
|
@ -1 +1,5 @@
|
|||||||
export * from './create';
|
import { create } from './create';
|
||||||
|
|
||||||
|
export function createGame() {
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@user/entry-data"
|
"name": "@user/entry-data",
|
||||||
|
"dependencies": {
|
||||||
|
"@user/data-base": "workspace:*",
|
||||||
|
"@user/data-fallback": "workspace:*",
|
||||||
|
"@user/data-state": "workspace:*",
|
||||||
|
"@user/data-utils": "workspace:*",
|
||||||
|
"@user/legacy-plugin-data": "workspace:*"
|
||||||
|
}
|
||||||
}
|
}
|
14
packages-user/entry-data/src/create.ts
Normal file
14
packages-user/entry-data/src/create.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { Mota } from './mota';
|
||||||
|
import * as DataBase from '@user/data-base';
|
||||||
|
import * as DataFallback from '@user/data-fallback';
|
||||||
|
import * as DataState from '@user/data-state';
|
||||||
|
import * as DataUtils from '@user/data-utils';
|
||||||
|
import * as LegacyPluginData from '@user/legacy-plugin-data';
|
||||||
|
|
||||||
|
export function create() {
|
||||||
|
Mota.register('@user/data-base', DataBase);
|
||||||
|
Mota.register('@user/data-fallback', DataFallback);
|
||||||
|
Mota.register('@user/data-state', DataState);
|
||||||
|
Mota.register('@user/data-utils', DataUtils);
|
||||||
|
Mota.register('@user/legacy-plugin-data', LegacyPluginData);
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
|
import { patchAll } from '@user/data-fallback';
|
||||||
import { createMota } from './mota';
|
import { createMota } from './mota';
|
||||||
|
import { create } from './create';
|
||||||
|
|
||||||
createMota();
|
createMota();
|
||||||
|
patchAll();
|
||||||
|
create();
|
||||||
|
|
||||||
export * from './mota';
|
export * from './mota';
|
||||||
|
@ -13,6 +13,13 @@ import type * as RenderVue from '@motajs/render-vue';
|
|||||||
import type * as System from '@motajs/system';
|
import type * as System from '@motajs/system';
|
||||||
import type * as SystemAction from '@motajs/system-action';
|
import type * as SystemAction from '@motajs/system-action';
|
||||||
import type * as SystemUI from '@motajs/system-ui';
|
import type * as SystemUI from '@motajs/system-ui';
|
||||||
|
import type * as ClientModules from '@user/client-modules';
|
||||||
|
import type * as DataBase from '@user/data-base';
|
||||||
|
import type * as DataFallback from '@user/data-fallback';
|
||||||
|
import type * as DataState from '@user/data-state';
|
||||||
|
import type * as DataUtils from '@user/data-utils';
|
||||||
|
import type * as LegacyPluginClient from '@user/legacy-plugin-client';
|
||||||
|
import type * as LegacyPluginData from '@user/legacy-plugin-data';
|
||||||
|
|
||||||
interface ModuleInterface {
|
interface ModuleInterface {
|
||||||
'@motajs/client': typeof Client;
|
'@motajs/client': typeof Client;
|
||||||
@ -30,6 +37,13 @@ interface ModuleInterface {
|
|||||||
'@motajs/system': typeof System;
|
'@motajs/system': typeof System;
|
||||||
'@motajs/system-action': typeof SystemAction;
|
'@motajs/system-action': typeof SystemAction;
|
||||||
'@motajs/system-ui': typeof SystemUI;
|
'@motajs/system-ui': typeof SystemUI;
|
||||||
|
'@user/client-modules': typeof ClientModules;
|
||||||
|
'@user/data-base': typeof DataBase;
|
||||||
|
'@user/data-fallback': typeof DataFallback;
|
||||||
|
'@user/data-state': typeof DataState;
|
||||||
|
'@user/data-utils': typeof DataUtils;
|
||||||
|
'@user/legacy-plugin-client': typeof LegacyPluginClient;
|
||||||
|
'@user/legacy-plugin-data': typeof LegacyPluginData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMota {
|
export interface IMota {
|
||||||
@ -137,7 +151,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Mota = new MotaSystem();
|
export const Mota: IMota = new MotaSystem();
|
||||||
|
|
||||||
export function createMota() {
|
export function createMota() {
|
||||||
window.Mota = Mota;
|
window.Mota = Mota;
|
||||||
|
6
packages-user/legacy-plugin-client/package.json
Normal file
6
packages-user/legacy-plugin-client/package.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "@user/legacy-plugin-client",
|
||||||
|
"dependencies": {
|
||||||
|
"@user/data-state": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import {
|
|||||||
RenderItemPosition,
|
RenderItemPosition,
|
||||||
Transform
|
Transform
|
||||||
} from '@motajs/render';
|
} from '@motajs/render';
|
||||||
import { IStateDamageable } from '@/game/state/interface';
|
import { IStateDamageable } from '@user/data-state';
|
||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
import { Ticker } from 'mutate-animate';
|
import { Ticker } from 'mutate-animate';
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { IStateDamageable } from '@/game/state/interface';
|
import { IStateDamageable } from '@user/data-state';
|
||||||
import { BarrageBoss, BossSprite, Hitbox } from './barrage';
|
import { BarrageBoss, BossSprite, Hitbox } from './barrage';
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
@ -1,5 +1,5 @@
|
|||||||
import { Transform, MotaOffscreenCanvas2D } from '@motajs/render';
|
import { Transform, MotaOffscreenCanvas2D } from '@motajs/render';
|
||||||
import { IStateDamageable } from '@/game/state/interface';
|
import { IStateDamageable } from '@user/data-state';
|
||||||
import { Hitbox, Projectile } from './barrage';
|
import { Hitbox, Projectile } from './barrage';
|
||||||
import type { PalaceBoss } from './palaceBoss';
|
import type { PalaceBoss } from './palaceBoss';
|
||||||
import { clamp } from '@motajs/legacy-ui';
|
import { clamp } from '@motajs/legacy-ui';
|
@ -21,7 +21,7 @@ import {
|
|||||||
ThunderBallProjectile,
|
ThunderBallProjectile,
|
||||||
ThunderProjectile
|
ThunderProjectile
|
||||||
} from './towerBossProjectile';
|
} from './towerBossProjectile';
|
||||||
import { IStateDamageable } from '@/game/state/interface';
|
import { IStateDamageable } from '@user/data-state';
|
||||||
import { Pop } from '../fx/pop';
|
import { Pop } from '../fx/pop';
|
||||||
import { WeatherController } from '@/module';
|
import { WeatherController } from '@/module';
|
||||||
|
|
@ -2,7 +2,7 @@ import { hyper, power, TimingFn } from 'mutate-animate';
|
|||||||
import { Hitbox, Projectile } from './barrage';
|
import { Hitbox, Projectile } from './barrage';
|
||||||
import { MotaOffscreenCanvas2D, Transform } from '@motajs/render';
|
import { MotaOffscreenCanvas2D, Transform } from '@motajs/render';
|
||||||
import type { TowerBoss } from './towerBoss';
|
import type { TowerBoss } from './towerBoss';
|
||||||
import { IStateDamageable } from '@/game/state/interface';
|
import { IStateDamageable } from '@user/data-state';
|
||||||
import { PointEffect, PointEffectType } from '../fx/pointShader';
|
import { PointEffect, PointEffectType } from '../fx/pointShader';
|
||||||
import { isNil } from 'lodash-es';
|
import { isNil } from 'lodash-es';
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
|||||||
disableViewport,
|
disableViewport,
|
||||||
enableViewport
|
enableViewport
|
||||||
} from '@motajs/render';
|
} from '@motajs/render';
|
||||||
import type { HeroMover, MoveStep } from '@/game/state/move';
|
import type { HeroMover, MoveStep } from '@user/data-state';
|
||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
|
|
||||||
export interface IChaseController {
|
export interface IChaseController {
|
@ -1,5 +1,5 @@
|
|||||||
import { Animation, linear, sleep } from 'mutate-animate';
|
import { Animation, linear, sleep } from 'mutate-animate';
|
||||||
import { has } from '@motajs/legacy-ui';
|
// import { has } from '@motajs/legacy-ui';
|
||||||
|
|
||||||
// todo: 移植到渲染树
|
// todo: 移植到渲染树
|
||||||
|
|
||||||
@ -28,37 +28,37 @@ const FRAG_TIMING = linear();
|
|||||||
|
|
||||||
export function init() {
|
export function init() {
|
||||||
return;
|
return;
|
||||||
Mota.rewrite(core.events, 'afterBattle', 'add', (_, enemy, x, y) => {
|
// Mota.rewrite(core.events, 'afterBattle', 'add', (_, enemy, x, y) => {
|
||||||
// 打怪特效
|
// // 打怪特效
|
||||||
const setting = Mota.require('var', 'mainSetting');
|
// const setting = Mota.require('var', 'mainSetting');
|
||||||
if (setting.getValue('fx.frag') && has(x) && has(y)) {
|
// if (setting.getValue('fx.frag') && has(x) && has(y)) {
|
||||||
const frame = core.status.globalAnimateStatus % 2;
|
// const frame = core.status.globalAnimateStatus % 2;
|
||||||
const canvas = document.createElement('canvas');
|
// const canvas = document.createElement('canvas');
|
||||||
canvas.width = 32;
|
// canvas.width = 32;
|
||||||
canvas.height = 32;
|
// canvas.height = 32;
|
||||||
core.drawIcon(canvas, enemy.id, 0, 0, 32, 32, frame);
|
// core.drawIcon(canvas, enemy.id, 0, 0, 32, 32, frame);
|
||||||
const manager = applyFragWith(canvas);
|
// const manager = applyFragWith(canvas);
|
||||||
const frag = manager.canvas;
|
// const frag = manager.canvas;
|
||||||
frag.style.imageRendering = 'pixelated';
|
// frag.style.imageRendering = 'pixelated';
|
||||||
frag.style.width = `${frag.width * core.domStyle.scale}px`;
|
// frag.style.width = `${frag.width * core.domStyle.scale}px`;
|
||||||
frag.style.height = `${frag.height * core.domStyle.scale}px`;
|
// frag.style.height = `${frag.height * core.domStyle.scale}px`;
|
||||||
const left =
|
// const left =
|
||||||
(x * 32 + 16 - frag.width / 2 - core.bigmap.offsetX) *
|
// (x * 32 + 16 - frag.width / 2 - core.bigmap.offsetX) *
|
||||||
core.domStyle.scale;
|
// core.domStyle.scale;
|
||||||
const top =
|
// const top =
|
||||||
(y * 32 + 16 - frag.height / 2 - core.bigmap.offsetY) *
|
// (y * 32 + 16 - frag.height / 2 - core.bigmap.offsetY) *
|
||||||
core.domStyle.scale;
|
// core.domStyle.scale;
|
||||||
frag.style.left = `${left}px`;
|
// frag.style.left = `${left}px`;
|
||||||
frag.style.top = `${top}px`;
|
// frag.style.top = `${top}px`;
|
||||||
frag.style.zIndex = '45';
|
// frag.style.zIndex = '45';
|
||||||
frag.style.position = 'absolute';
|
// frag.style.position = 'absolute';
|
||||||
frag.style.filter = 'sepia(20%)brightness(120%)';
|
// frag.style.filter = 'sepia(20%)brightness(120%)';
|
||||||
core.dom.gameDraw.appendChild(frag);
|
// core.dom.gameDraw.appendChild(frag);
|
||||||
manager.onEnd.then(() => {
|
// manager.onEnd.then(() => {
|
||||||
frag.remove();
|
// frag.remove();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyFragWith(
|
export function applyFragWith(
|
6
packages-user/legacy-plugin-client/src/fx/index.ts
Normal file
6
packages-user/legacy-plugin-client/src/fx/index.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export * from './gameCanvas';
|
||||||
|
export * from './halo';
|
||||||
|
export * from './itemDetail';
|
||||||
|
export * from './pointShader';
|
||||||
|
export * from './pop';
|
||||||
|
export * from './portal';
|
@ -7,7 +7,7 @@ import {
|
|||||||
LayerGroup,
|
LayerGroup,
|
||||||
Sprite
|
Sprite
|
||||||
} from '@motajs/render';
|
} from '@motajs/render';
|
||||||
import type { BluePalace } from '@/game/mechanism/misc';
|
import type { BluePalace } from '@user/data-state';
|
||||||
|
|
||||||
/** 最大粒子数 */
|
/** 最大粒子数 */
|
||||||
const MAX_PARTICLES = 10;
|
const MAX_PARTICLES = 10;
|
6
packages-user/legacy-plugin-client/src/index.ts
Normal file
6
packages-user/legacy-plugin-client/src/index.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export * from './boss';
|
||||||
|
export * from './chase';
|
||||||
|
export * from './fx';
|
||||||
|
|
||||||
|
export * from './fallback';
|
||||||
|
export * from './loopMap';
|
7
packages-user/legacy-plugin-data/package.json
Normal file
7
packages-user/legacy-plugin-data/package.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "@user/legacy-plugin-data",
|
||||||
|
"dependencies": {
|
||||||
|
"@user/data-state": "workspace:*",
|
||||||
|
"@user/data-base": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
///<reference path="../../../../src/types/core.d.ts" />
|
// @ts-nocheck
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
/* @__PURE__ */ (function () {
|
/* @__PURE__ */ (function () {
|
6
packages-user/legacy-plugin-data/src/enemy/index.ts
Normal file
6
packages-user/legacy-plugin-data/src/enemy/index.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { init as initCheckBlock } from './checkblock';
|
||||||
|
|
||||||
|
initCheckBlock();
|
||||||
|
|
||||||
|
export * from './checkblock';
|
||||||
|
export * from './remainEnemy';
|
@ -9,7 +9,7 @@ import type {
|
|||||||
FloorViewport
|
FloorViewport
|
||||||
} from '@motajs/render';
|
} from '@motajs/render';
|
||||||
import type { TimingFn } from 'mutate-animate';
|
import type { TimingFn } from 'mutate-animate';
|
||||||
import { BlockMover, heroMoveCollection, MoveStep } from '@/game/state/move';
|
import { BlockMover, heroMoveCollection, MoveStep } from '@user/data-state';
|
||||||
|
|
||||||
// 向后兼容用,会充当两个版本间过渡的作用
|
// 向后兼容用,会充当两个版本间过渡的作用
|
||||||
|
|
||||||
@ -23,13 +23,13 @@ interface Adapters {
|
|||||||
|
|
||||||
const adapters: Adapters = {};
|
const adapters: Adapters = {};
|
||||||
|
|
||||||
export function init() {
|
export function initFallback() {
|
||||||
const hook = Mota.require('var', 'hook');
|
const hook = Mota.require('var', 'hook');
|
||||||
const loading = Mota.require('var', 'loading');
|
const loading = Mota.require('var', 'loading');
|
||||||
let fallbackIds: number = 1e8;
|
let fallbackIds: number = 1e8;
|
||||||
|
|
||||||
if (!main.replayChecking && main.mode === 'play') {
|
if (!main.replayChecking && main.mode === 'play') {
|
||||||
const Adapter = Mota.require('module', 'Render').RenderAdapter;
|
const Adapter = Mota.require('@motajs/render').RenderAdapter;
|
||||||
const hero = Adapter.get<HeroRenderer>('hero-adapter');
|
const hero = Adapter.get<HeroRenderer>('hero-adapter');
|
||||||
const doorAnimate = Adapter.get<LayerDoorAnimate>('door-animate');
|
const doorAnimate = Adapter.get<LayerDoorAnimate>('door-animate');
|
||||||
const animate = Adapter.get<LayerGroupAnimate>('animate');
|
const animate = Adapter.get<LayerGroupAnimate>('animate');
|
||||||
@ -88,8 +88,8 @@ export function init() {
|
|||||||
|
|
||||||
Mota.r(() => {
|
Mota.r(() => {
|
||||||
// ----- 引入
|
// ----- 引入
|
||||||
const Camera = Mota.require('module', 'Render').Camera;
|
const { Camera, MotaRenderer: Renderer } =
|
||||||
const Renderer = Mota.require('module', 'Render').MotaRenderer;
|
Mota.require('@motajs/render');
|
||||||
const Animation = Mota.require('module', 'Animation');
|
const Animation = Mota.require('module', 'Animation');
|
||||||
|
|
||||||
// ----- 勇士移动相关
|
// ----- 勇士移动相关
|
@ -16,7 +16,7 @@ function createCanvas(name, zIndex) {
|
|||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function init() {
|
export function initFiveLayer() {
|
||||||
// 大地图适配
|
// 大地图适配
|
||||||
|
|
||||||
core.initStatus.bg2maps = {};
|
core.initStatus.bg2maps = {};
|
5
packages-user/legacy-plugin-data/src/fx/index.ts
Normal file
5
packages-user/legacy-plugin-data/src/fx/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { init as initItemDetail } from './itemDetail';
|
||||||
|
|
||||||
|
initItemDetail();
|
||||||
|
|
||||||
|
export * from './itemDetail';
|
@ -1,4 +1,4 @@
|
|||||||
import { EnemyCollection, ensureFloorDamage } from '@/game/enemy/damage';
|
import { EnemyCollection, ensureFloorDamage } from '@user/data-state';
|
||||||
import { formatDamage } from '../utils';
|
import { formatDamage } from '../utils';
|
||||||
|
|
||||||
export function init() {
|
export function init() {
|
65
packages-user/legacy-plugin-data/src/hook.ts
Normal file
65
packages-user/legacy-plugin-data/src/hook.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { hook } from '@user/data-base';
|
||||||
|
|
||||||
|
const potionItems: AllIdsOf<'items'>[] = [
|
||||||
|
'redPotion',
|
||||||
|
'bluePotion',
|
||||||
|
'yellowPotion',
|
||||||
|
'greenPotion',
|
||||||
|
'I482',
|
||||||
|
'I484',
|
||||||
|
'I487',
|
||||||
|
'I491'
|
||||||
|
];
|
||||||
|
|
||||||
|
export function createHook() {
|
||||||
|
hook.on('afterGetItem', (itemId, x, y, isGentleClick) => {
|
||||||
|
// 获得一个道具后触发的事件
|
||||||
|
// itemId:获得的道具ID;x和y是该道具所在的坐标
|
||||||
|
// isGentleClick:是否是轻按触发的
|
||||||
|
if (potionItems.includes(itemId)) core.playSound('回血');
|
||||||
|
else core.playSound('获得道具');
|
||||||
|
|
||||||
|
const todo: any[] = [];
|
||||||
|
// 检查该点的获得道具后事件。
|
||||||
|
if (core.status.floorId == null) return;
|
||||||
|
const event =
|
||||||
|
core.floors[core.status.floorId].afterGetItem[`${x},${y}`];
|
||||||
|
if (
|
||||||
|
event &&
|
||||||
|
(event instanceof Array ||
|
||||||
|
!isGentleClick ||
|
||||||
|
!event.disableOnGentleClick)
|
||||||
|
) {
|
||||||
|
core.unshift(todo, event as any[]);
|
||||||
|
}
|
||||||
|
if (core.hasFlag('spring')) {
|
||||||
|
if (!core.hasFlag('springCount')) core.setFlag('springCount', 0);
|
||||||
|
if (potionItems.includes(itemId)) {
|
||||||
|
core.addFlag('springCount', 1);
|
||||||
|
}
|
||||||
|
if (core.getFlag<number>('springCount', 0) === 50) {
|
||||||
|
core.setFlag('springCount', 0);
|
||||||
|
core.status.hero.hpmax += core.getNakedStatus('hpmax') * 0.1;
|
||||||
|
}
|
||||||
|
core.updateStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (todo.length > 0) core.insertAction(todo, x, y);
|
||||||
|
});
|
||||||
|
|
||||||
|
hook.on('afterOpenDoor', (doorId, x, y) => {
|
||||||
|
// 开一个门后触发的事件
|
||||||
|
|
||||||
|
const todo: any[] = [];
|
||||||
|
// 检查该点的获得开门后事件。
|
||||||
|
if (core.status.floorId == null) return;
|
||||||
|
const event =
|
||||||
|
core.floors[core.status.floorId].afterOpenDoor[`${x},${y}`];
|
||||||
|
if (event) core.unshift(todo, event as any[]);
|
||||||
|
|
||||||
|
if (todo.length > 0) core.insertAction(todo, x, y);
|
||||||
|
|
||||||
|
if (core.status.event.id == null) core.continueAutomaticRoute();
|
||||||
|
else core.clearContinueAutomaticRoute();
|
||||||
|
});
|
||||||
|
}
|
25
packages-user/legacy-plugin-data/src/index.ts
Normal file
25
packages-user/legacy-plugin-data/src/index.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { initFallback } from './fallback';
|
||||||
|
import { initFiveLayer } from './fiveLayer';
|
||||||
|
import { createHook } from './hook';
|
||||||
|
import { initReplay } from './replay';
|
||||||
|
import { initUI } from './ui';
|
||||||
|
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
import('./dev/hotReload');
|
||||||
|
}
|
||||||
|
|
||||||
|
initFallback();
|
||||||
|
initFiveLayer();
|
||||||
|
createHook();
|
||||||
|
initReplay();
|
||||||
|
initUI();
|
||||||
|
|
||||||
|
export * from './chase';
|
||||||
|
export * from './fallback';
|
||||||
|
export * from './fiveLayer';
|
||||||
|
export * from './removeMap';
|
||||||
|
export * from './replay';
|
||||||
|
export * from './shop';
|
||||||
|
export * from './skill';
|
||||||
|
export * from '../../data-state/src/mechanism/skillTree';
|
||||||
|
export * from './ui';
|
@ -1,5 +1,8 @@
|
|||||||
import { HeroSkill } from '@/game/mechanism/misc';
|
import { HeroSkill } from '@/game/mechanism/misc';
|
||||||
import { getSkillFromIndex, upgradeSkill } from './skillTree';
|
import {
|
||||||
|
getSkillFromIndex,
|
||||||
|
upgradeSkill
|
||||||
|
} from '../../data-state/src/mechanism/skillTree';
|
||||||
import { canOpenShop } from './shop';
|
import { canOpenShop } from './shop';
|
||||||
|
|
||||||
const replayableSettings = ['autoSkill'];
|
const replayableSettings = ['autoSkill'];
|
||||||
@ -20,7 +23,7 @@ export function clip(...replace: string[]) {
|
|||||||
core.status.route.push(...replace);
|
core.status.route.push(...replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function init() {
|
export function initReplay() {
|
||||||
function tipAndWait(content: string, time: number) {
|
function tipAndWait(content: string, time: number) {
|
||||||
const speed = core.status.replay.speed;
|
const speed = core.status.replay.speed;
|
||||||
if (main.replayChecking || speed === 24) return Promise.resolve();
|
if (main.replayChecking || speed === 24) return Promise.resolve();
|
@ -1,6 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
|
|
||||||
export function init() {
|
export function initUI() {
|
||||||
if (main.mode === 'editor') return;
|
if (main.mode === 'editor') return;
|
||||||
const { mainUi, fixedUi, mainSetting } = Mota.requireAll('var');
|
const { mainUi, fixedUi, mainSetting } = Mota.requireAll('var');
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'ant-design-vue/dist/antd.dark.css';
|
||||||
|
|
||||||
export * as UI from './ui';
|
export * as UI from './ui';
|
||||||
export * as Components from './components';
|
export * as Components from './components';
|
||||||
export * from './preset';
|
export * from './preset';
|
||||||
|
131
pnpm-lock.yaml
131
pnpm-lock.yaml
@ -190,6 +190,47 @@ importers:
|
|||||||
specifier: ^8.18.0
|
specifier: ^8.18.0
|
||||||
version: 8.18.0
|
version: 8.18.0
|
||||||
|
|
||||||
|
packages-user/client-modules: {}
|
||||||
|
|
||||||
|
packages-user/data-base:
|
||||||
|
dependencies:
|
||||||
|
'@motajs/types':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../packages/types
|
||||||
|
|
||||||
|
packages-user/data-fallback:
|
||||||
|
dependencies:
|
||||||
|
'@motajs/legacy-common':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../packages/legacy-common
|
||||||
|
'@user/data-base':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-base
|
||||||
|
'@user/data-state':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-state
|
||||||
|
|
||||||
|
packages-user/data-state:
|
||||||
|
dependencies:
|
||||||
|
'@motajs/common':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../packages/common
|
||||||
|
'@motajs/types':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../packages/types
|
||||||
|
'@user/data-base':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-base
|
||||||
|
'@user/data-utils':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-utils
|
||||||
|
|
||||||
|
packages-user/data-utils:
|
||||||
|
dependencies:
|
||||||
|
'@user/data-base':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-base
|
||||||
|
|
||||||
packages-user/entry-client:
|
packages-user/entry-client:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@motajs/client':
|
'@motajs/client':
|
||||||
@ -240,8 +281,45 @@ importers:
|
|||||||
'@motajs/system-ui':
|
'@motajs/system-ui':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../packages/system-ui
|
version: link:../../packages/system-ui
|
||||||
|
'@user/client-modules':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../client-modules
|
||||||
|
'@user/legacy-plugin-client':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../legacy-plugin-client
|
||||||
|
|
||||||
packages-user/entry-data: {}
|
packages-user/entry-data:
|
||||||
|
dependencies:
|
||||||
|
'@user/data-base':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-base
|
||||||
|
'@user/data-fallback':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-fallback
|
||||||
|
'@user/data-state':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-state
|
||||||
|
'@user/data-utils':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-utils
|
||||||
|
'@user/legacy-plugin-data':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../legacy-plugin-data
|
||||||
|
|
||||||
|
packages-user/legacy-plugin-client:
|
||||||
|
dependencies:
|
||||||
|
'@user/data-state':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-state
|
||||||
|
|
||||||
|
packages-user/legacy-plugin-data:
|
||||||
|
dependencies:
|
||||||
|
'@user/data-base':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-base
|
||||||
|
'@user/data-state':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../data-state
|
||||||
|
|
||||||
packages/client:
|
packages/client:
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -382,56 +460,13 @@ importers:
|
|||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../render
|
version: link:../render
|
||||||
|
|
||||||
|
packages/types: {}
|
||||||
|
|
||||||
src:
|
src:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@motajs/client':
|
'@user/entry-client':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../packages/client
|
version: link:../packages-user/entry-client
|
||||||
'@motajs/client-base':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/client-base
|
|
||||||
'@motajs/common':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/common
|
|
||||||
'@motajs/legacy-client':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/legacy-client
|
|
||||||
'@motajs/legacy-common':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/legacy-common
|
|
||||||
'@motajs/legacy-data':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/legacy-data
|
|
||||||
'@motajs/legacy-system':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/legacy-system
|
|
||||||
'@motajs/legacy-ui':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/legacy-ui
|
|
||||||
'@motajs/render':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/render
|
|
||||||
'@motajs/render-core':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/render-core
|
|
||||||
'@motajs/render-elements':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/render-elements
|
|
||||||
'@motajs/render-style':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/render-style
|
|
||||||
'@motajs/render-vue':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/render-vue
|
|
||||||
'@motajs/system':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/system
|
|
||||||
'@motajs/system-action':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/system-action
|
|
||||||
'@motajs/system-ui':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../packages/system-ui
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import './game/index';
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import './styles.less';
|
import './styles.less';
|
||||||
import 'ant-design-vue/dist/antd.dark.css';
|
import { createGame } from '@user/entry-client';
|
||||||
|
|
||||||
createApp(App).mount('#root');
|
createApp(App).mount('#root');
|
||||||
|
|
||||||
|
// 创建游戏实例
|
||||||
|
createGame();
|
||||||
|
|
||||||
main.init('play');
|
main.init('play');
|
||||||
main.listen();
|
main.listen();
|
||||||
|
@ -1,21 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@motajs/user",
|
"name": "@user/main",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@motajs/client": "workspace:*",
|
"@user/entry-client": "workspace:*"
|
||||||
"@motajs/client-base": "workspace:*",
|
|
||||||
"@motajs/common": "workspace:*",
|
|
||||||
"@motajs/render": "workspace:*",
|
|
||||||
"@motajs/render-core": "workspace:*",
|
|
||||||
"@motajs/render-elements": "workspace:*",
|
|
||||||
"@motajs/render-style": "workspace:*",
|
|
||||||
"@motajs/render-vue": "workspace:*",
|
|
||||||
"@motajs/system": "workspace:*",
|
|
||||||
"@motajs/system-ui": "workspace:*",
|
|
||||||
"@motajs/system-action": "workspace:*",
|
|
||||||
"@motajs/legacy-common": "workspace:*",
|
|
||||||
"@motajs/legacy-client": "workspace:*",
|
|
||||||
"@motajs/legacy-data": "workspace:*",
|
|
||||||
"@motajs/legacy-ui": "workspace:*",
|
|
||||||
"@motajs/legacy-system": "workspace:*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,63 +0,0 @@
|
|||||||
import { hook } from '@/game/game';
|
|
||||||
|
|
||||||
export {};
|
|
||||||
|
|
||||||
const potionItems: AllIdsOf<'items'>[] = [
|
|
||||||
'redPotion',
|
|
||||||
'bluePotion',
|
|
||||||
'yellowPotion',
|
|
||||||
'greenPotion',
|
|
||||||
'I482',
|
|
||||||
'I484',
|
|
||||||
'I487',
|
|
||||||
'I491'
|
|
||||||
];
|
|
||||||
|
|
||||||
hook.on('afterGetItem', (itemId, x, y, isGentleClick) => {
|
|
||||||
// 获得一个道具后触发的事件
|
|
||||||
// itemId:获得的道具ID;x和y是该道具所在的坐标
|
|
||||||
// isGentleClick:是否是轻按触发的
|
|
||||||
if (potionItems.includes(itemId)) core.playSound('回血');
|
|
||||||
else core.playSound('获得道具');
|
|
||||||
|
|
||||||
const todo: any[] = [];
|
|
||||||
// 检查该点的获得道具后事件。
|
|
||||||
if (core.status.floorId == null) return;
|
|
||||||
const event = core.floors[core.status.floorId].afterGetItem[`${x},${y}`];
|
|
||||||
if (
|
|
||||||
event &&
|
|
||||||
(event instanceof Array ||
|
|
||||||
!isGentleClick ||
|
|
||||||
!event.disableOnGentleClick)
|
|
||||||
) {
|
|
||||||
core.unshift(todo, event as any[]);
|
|
||||||
}
|
|
||||||
if (core.hasFlag('spring')) {
|
|
||||||
if (!core.hasFlag('springCount')) core.setFlag('springCount', 0);
|
|
||||||
if (potionItems.includes(itemId)) {
|
|
||||||
core.addFlag('springCount', 1);
|
|
||||||
}
|
|
||||||
if (core.getFlag<number>('springCount', 0) === 50) {
|
|
||||||
core.setFlag('springCount', 0);
|
|
||||||
core.status.hero.hpmax += core.getNakedStatus('hpmax') * 0.1;
|
|
||||||
}
|
|
||||||
core.updateStatusBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (todo.length > 0) core.insertAction(todo, x, y);
|
|
||||||
});
|
|
||||||
|
|
||||||
hook.on('afterOpenDoor', (doorId, x, y) => {
|
|
||||||
// 开一个门后触发的事件
|
|
||||||
|
|
||||||
const todo: any[] = [];
|
|
||||||
// 检查该点的获得开门后事件。
|
|
||||||
if (core.status.floorId == null) return;
|
|
||||||
const event = core.floors[core.status.floorId].afterOpenDoor[`${x},${y}`];
|
|
||||||
if (event) core.unshift(todo, event as any[]);
|
|
||||||
|
|
||||||
if (todo.length > 0) core.insertAction(todo, x, y);
|
|
||||||
|
|
||||||
if (core.status.event.id == null) core.continueAutomaticRoute();
|
|
||||||
else core.clearContinueAutomaticRoute();
|
|
||||||
});
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user