This commit is contained in:
qdzwxe 2025-09-08 21:31:33 +08:00
commit c0762c62cf
36 changed files with 142 additions and 113 deletions

View File

@ -15,9 +15,9 @@
## 开发环境 ## 开发环境
- `node.js ^18.0.0 || ^20.0.0 || >=22.0.0` - `node.js ^20.0.0 || >=22.0.0`
- `pnpm >= 10.0.0` - `pnpm >= 10.0.0`
- 任意支持 `ES2024` 特性的浏览器 - 任意支持 `ESNext` 特性的浏览器
**建议使用 `vscode`,搭配 `prettier` `eslint` 插件** **建议使用 `vscode`,搭配 `prettier` `eslint` 插件**
@ -30,7 +30,7 @@
## 构建说明 ## 构建说明
- `pnpm build:packages`: 构建所有 `packages` 文件夹下的内容,使用库模式。 - `pnpm build:packages`: 构建所有 `packages` 文件夹下的内容,使用库模式。
- `pnpm build:game`: 构建为可以直接部署构建包。 - `pnpm build:game`: 构建为可以直接部署构建包。
- `pnpm build:lib`: 构建所有 `packages` `packages-user` 文件夹下的内容,使用库模式。 - `pnpm build:lib`: 构建所有 `packages` `packages-user` 文件夹下的内容,使用库模式。
## 开发原则 ## 开发原则

View File

@ -48,10 +48,10 @@ function constructor(
创建一个新的离屏画布。 创建一个新的离屏画布。
**参数** **参数**
- `alpha`: 是否启用透明度通道(默认为 `true`)。 - `alpha`: 是否启用透明度通道(默认为 `true`)。
- `canvas`: 可指定现有画布,未提供时自动创建新画布。 - `canvas`: 可指定现有画布,未提供时自动创建新画布。
**注意** **注意**
- 在自定义渲染元素中,建议使用 `RenderItem.requireCanvas` 而非直接调用此构造函数。 - 在自定义渲染元素中,建议使用 `RenderItem.requireCanvas` 而非直接调用此构造函数。之后如果不使用,再使用 `RenderItem.deleteCanvas` 删除。
--- ---
@ -67,11 +67,11 @@ function size(width: number, height: number): void;
设置画布的尺寸。 设置画布的尺寸。
**参数** **参数**
- `width`: 逻辑宽度(最小为 1 - `width`: 逻辑宽度(最小为 1
- `height`: 逻辑高度(最小为 1 - `height`: 逻辑高度(最小为 1
**行为** **行为**
- 自动计算缩放比例(考虑 `highResolution``autoScale`)。 - 自动计算缩放比例(考虑 `highResolution``autoScale`)。
- 调整画布物理尺寸和样式尺寸。 - 调整画布物理尺寸和样式尺寸。
**示例** **示例**
@ -92,7 +92,7 @@ function withGameScale(auto: boolean): void;
设置画布是否跟随 `core.domStyle.scale` 自动缩放。 设置画布是否跟随 `core.domStyle.scale` 自动缩放。
**参数** **参数**
- `auto`: 是否启用自动缩放。 - `auto`: 是否启用自动缩放。
**示例** **示例**
@ -112,7 +112,7 @@ function setHD(hd: boolean): void;
设置是否为高清画布(基于设备像素比例)。 设置是否为高清画布(基于设备像素比例)。
**参数** **参数**
- `hd`: 是否启用高清模式。 - `hd`: 是否启用高清模式。
**示例** **示例**
@ -132,7 +132,7 @@ function setAntiAliasing(anti: boolean): void;
设置抗锯齿功能。 设置抗锯齿功能。
**参数** **参数**
- `anti`: 是否启用抗锯齿。 - `anti`: 是否启用抗锯齿。
**示例** **示例**
@ -152,7 +152,7 @@ function clear(): void;
清空画布内容。 清空画布内容。
**注意** **注意**
- 冻结状态下调用此方法会触发警告。 - 冻结状态下调用此方法会触发警告。
**示例** **示例**
@ -242,7 +242,7 @@ function clone(canvas: MotaOffscreenCanvas2D): MotaOffscreenCanvas2D;
复制一个画布对象,结果画布将被冻结。 复制一个画布对象,结果画布将被冻结。
**返回值** **返回值**
- 复制的画布对象(不可修改属性,但可绘制)。 - 复制的画布对象(不可修改属性,但可绘制)。
**示例** **示例**
@ -262,7 +262,7 @@ function refreshAll(force: boolean = false): void;
刷新所有已注册画布的尺寸(仅在窗口大小变化时自动调用)。 刷新所有已注册画布的尺寸(仅在窗口大小变化时自动调用)。
**参数** **参数**
- `force`: 是否强制刷新所有画布(默认仅刷新启用 `autoScale` 的画布)。 - `force`: 是否强制刷新所有画布(默认仅刷新启用 `autoScale` 的画布)。
--- ---

View File

@ -4,8 +4,8 @@ import { patchAll } from './fallback';
import { createGameRenderer, createRender } from './render'; import { createGameRenderer, createRender } from './render';
export function create() { export function create() {
createAudio();
patchAll(); patchAll();
createAudio();
createRender(); createRender();
loading.once('coreInit', () => { loading.once('coreInit', () => {
createGameRenderer(); createGameRenderer();

View File

@ -51,7 +51,7 @@ export const FloorSelector = defineComponent<
const scrollRef = ref<ScrollExpose>(); const scrollRef = ref<ScrollExpose>();
const floors = computed(() => props.floors.toReversed()); const floors = computed(() => props.floors.toReversed());
const floorId = computed(() => floors.value[now.value]); const floorId = computed(() => props.floors[now.value]);
const floorName = computed(() => core.floors[floorId.value].title); const floorName = computed(() => core.floors[floorId.value].title);
watch( watch(

View File

@ -277,10 +277,10 @@ export const PauseIcon = defineIcon(1, (loc, pad) => {
export const DoubleArrow = defineIcon(1, (loc, pad) => { export const DoubleArrow = defineIcon(1, (loc, pad) => {
const path = new Path2D(); const path = new Path2D();
const path2 = new Path2D(); const path2 = new Path2D();
const [, , width, height, cx, cy] = loc; const [, , , height, cx, cy] = loc;
const [left, right, top, bottom] = pad(5); const [left, right, top, bottom] = pad(5);
path.moveTo(left, top + height / 12); path.moveTo(left, top + height / 12);
path.lineTo(cx + width / 8, cy); path.lineTo(cx, cy);
path.lineTo(left, bottom - height / 12); path.lineTo(left, bottom - height / 12);
path.closePath(); path.closePath();
path2.moveTo(cx, top + height / 12); path2.moveTo(cx, top + height / 12);

View File

@ -1,9 +1,10 @@
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { logger } from '@motajs/common'; import { logger } from '@motajs/common';
import { MotaOffscreenCanvas2D } from '@motajs/render-core'; import { MotaOffscreenCanvas2D, RenderItem } from '@motajs/render-core';
interface BlockCacherEvent { interface BlockCacherEvent {
split: []; split: [];
beforeClear: [index: number];
} }
interface BlockData { interface BlockData {
@ -307,9 +308,12 @@ export interface ICanvasCacheItem extends IBlockCacheable {
export class CanvasCacheItem implements ICanvasCacheItem { export class CanvasCacheItem implements ICanvasCacheItem {
constructor( constructor(
public canvas: MotaOffscreenCanvas2D, public readonly canvas: MotaOffscreenCanvas2D,
public symbol: number public readonly symbol: number,
public readonly element: RenderItem
) {} ) {}
destroy(): void {} destroy(): void {
this.element.deleteCanvas(this.canvas);
}
} }

View File

@ -539,7 +539,7 @@ export class Damage extends RenderItem<EDamageEvent> {
}); });
ctx.drawImage(temp.canvas, px, py, size, size); ctx.drawImage(temp.canvas, px, py, size, size);
block.cache.set(v, new CanvasCacheItem(temp, temp.symbol)); block.cache.set(v, new CanvasCacheItem(temp, temp.symbol, this));
}); });
ctx.restore(); ctx.restore();
// console.timeEnd('damage'); // console.timeEnd('damage');

View File

@ -774,6 +774,7 @@ export class Layer extends Container<ELayerEvent> {
const num = this.background; const num = this.background;
const data = texture.getRenderable(num); const data = texture.getRenderable(num);
this.backImage.forEach(v => this.deleteCanvas(v));
this.backImage = []; this.backImage = [];
if (!data) return; if (!data) return;
@ -800,6 +801,7 @@ export class Layer extends Container<ELayerEvent> {
this.backImage.push(canvas); this.backImage.push(canvas);
} }
this.deleteCanvas(temp);
for (const ex of this.extend.values()) { for (const ex of this.extend.values()) {
ex.onBackgroundGenerated?.(this, this.backImage); ex.onBackgroundGenerated?.(this, this.backImage);
@ -1239,7 +1241,10 @@ export class Layer extends Container<ELayerEvent> {
blockSize * cell, blockSize * cell,
blockSize * cell blockSize * cell
); );
this.block.cache.set(index, new CanvasCacheItem(temp, temp.symbol)); this.block.cache.set(
index,
new CanvasCacheItem(temp, temp.symbol, this)
);
}); });
} }
@ -1545,7 +1550,7 @@ export function createLayer() {
hook.on('setBlock', (x, y, floor, block) => { hook.on('setBlock', (x, y, floor, block) => {
const isNow = floor === core.status.floorId; const isNow = floor === core.status.floorId;
LayerGroupFloorBinder.activedBinder.forEach(v => { LayerGroupFloorBinder.activeBinder.forEach(v => {
if (floor === v.floor || (isNow && v.bindThisFloor)) { if (floor === v.floor || (isNow && v.bindThisFloor)) {
v.setBlock('event', block, x, y); v.setBlock('event', block, x, y);
} }
@ -1561,7 +1566,7 @@ export function createLayer() {
hook.on('changingFloor', floor => { hook.on('changingFloor', floor => {
// 潜在隐患如果putRenderData改成异步那么会变成两帧后才能真正刷新并渲染 // 潜在隐患如果putRenderData改成异步那么会变成两帧后才能真正刷新并渲染
// 考虑到楼层转换一般不会同时执行很多次,因此这里改为立刻更新 // 考虑到楼层转换一般不会同时执行很多次,因此这里改为立刻更新
LayerGroupFloorBinder.activedBinder.forEach(v => { LayerGroupFloorBinder.activeBinder.forEach(v => {
if (v.bindThisFloor) v.updateBindData(); if (v.bindThisFloor) v.updateBindData();
v.emit('floorChange', floor); v.emit('floorChange', floor);
}); });
@ -1571,7 +1576,7 @@ export function createLayer() {
}); });
hook.on('setBgFgBlock', (name, number, x, y, floor) => { hook.on('setBgFgBlock', (name, number, x, y, floor) => {
const isNow = floor === core.status.floorId; const isNow = floor === core.status.floorId;
LayerGroupFloorBinder.activedBinder.forEach(v => { LayerGroupFloorBinder.activeBinder.forEach(v => {
if (floor === v.floor || (isNow && v.bindThisFloor)) { if (floor === v.floor || (isNow && v.bindThisFloor)) {
v.setBlock(name, number, x, y); v.setBlock(name, number, x, y);
} }
@ -1612,7 +1617,7 @@ export class LayerGroupFloorBinder
private needUpdate: boolean = false; private needUpdate: boolean = false;
static activedBinder: Set<LayerGroupFloorBinder> = new Set(); static activeBinder: Set<LayerGroupFloorBinder> = new Set();
/** /**
* *
@ -1698,7 +1703,7 @@ export class LayerGroupFloorBinder
for (const layer of group.layers.values()) { for (const layer of group.layers.values()) {
this.checkLayerExtends(layer); this.checkLayerExtends(layer);
} }
LayerGroupFloorBinder.activedBinder.add(this); LayerGroupFloorBinder.activeBinder.add(this);
} }
onLayerAdd(_group: LayerGroup, layer: Layer): void { onLayerAdd(_group: LayerGroup, layer: Layer): void {
@ -1706,7 +1711,7 @@ export class LayerGroupFloorBinder
} }
onDestroy(group: LayerGroup) { onDestroy(group: LayerGroup) {
LayerGroupFloorBinder.activedBinder.delete(this); LayerGroupFloorBinder.activeBinder.delete(this);
group.layers.forEach(v => { group.layers.forEach(v => {
v.removeExtends('floor-binder'); v.removeExtends('floor-binder');
}); });

View File

@ -211,6 +211,7 @@ export class Winskin extends RenderItem<EWinskinEvent> {
Winskin.patternMap.set(this.imageName, winskinPattern); Winskin.patternMap.set(this.imageName, winskinPattern);
} }
this.patternCache = winskinPattern; this.patternCache = winskinPattern;
this.deleteCanvas(pattern);
return winskinPattern; return winskinPattern;
} }

View File

@ -48,6 +48,8 @@ export function createRender() {
export * from './components'; export * from './components';
export * from './elements'; export * from './elements';
export * from './fx';
export * from './legacy';
export * from './ui'; export * from './ui';
export * from './utils'; export * from './utils';
export * from './renderer'; export * from './renderer';

View File

@ -5,3 +5,5 @@ export function createLegacy() {
createGameCanvas(); createGameCanvas();
createShadow(); createShadow();
} }
export * from './shadow';

View File

@ -25,6 +25,7 @@ import { saveSave, saveLoad } from './save';
import { mainUIController } from './controller'; import { mainUIController } from './controller';
import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared'; import { MAIN_WIDTH, MAIN_HEIGHT } from '../shared';
import { openSettings } from './settings'; import { openSettings } from './settings';
import { openViewMap } from './viewmap';
interface ToolbarProps extends DefaultProps { interface ToolbarProps extends DefaultProps {
loc?: ElementLocator; loc?: ElementLocator;
@ -110,9 +111,7 @@ export const PlayingToolbar = defineComponent<
const redo = () => core.doSL('autoSave', 'reload'); const redo = () => core.doSL('autoSave', 'reload');
const numpad = () => emit('numpad'); const numpad = () => emit('numpad');
const view = () => { const view = () => {
if (core.isPlaying() && !core.isMoving() && !core.status.lockControl) { openViewMap(mainUIController, [0, 0, MAIN_WIDTH, MAIN_HEIGHT]);
core.ui._drawViewMaps();
}
}; };
const danmaku = () => requestAnimationFrame(openDanmakuPoster); const danmaku = () => requestAnimationFrame(openDanmakuPoster);
const replay = () => core.ui._drawReplay(); const replay = () => core.ui._drawReplay();
@ -183,7 +182,9 @@ export const ReplayingToolbar = defineComponent<ReplayingProps>(props => {
const speedDown = () => core.speedDownReplay(); const speedDown = () => core.speedDownReplay();
const speedUp = () => core.speedUpReplay(); const speedUp = () => core.speedUpReplay();
const book = () => core.openBook(true); const book = () => core.openBook(true);
const save = () => core.save(true); const save = () => {
saveSave(mainUIController, [0, 0, MAIN_WIDTH, MAIN_HEIGHT]);
};
const view = () => { const view = () => {
if (core.isPlaying() && !core.isMoving() && !core.status.lockControl) { if (core.isPlaying() && !core.isMoving() && !core.status.lockControl) {
core.ui._drawViewMaps(); core.ui._drawViewMaps();

View File

@ -242,8 +242,9 @@ export function canUpgrade(skill: number) {
if (consume > core.status.hero.mdef) return false; if (consume > core.status.hero.mdef) return false;
const level = getSkillLevel(skill); const level = getSkillLevel(skill);
const s = getSkillFromIndex(skill); const s = getSkillFromIndex(skill);
if (level === s?.max) return false; if (!s) return false;
const front = s?.front ?? []; if (level >= s.max) return false;
const front = s.front;
for (const [skill, level] of front) { for (const [skill, level] of front) {
if (getSkillLevel(skill) < level) return false; if (getSkillLevel(skill) < level) return false;
} }

View File

@ -73,6 +73,7 @@ export class SplittableBall extends Projectile<PalaceBoss> {
private splitted: boolean = false; private splitted: boolean = false;
static init(colors: Record<string, string[]>) { static init(colors: Record<string, string[]>) {
this.ball.forEach(v => mainRenderer.deleteCanvas(v));
this.ball.clear(); this.ball.clear();
for (const [key, color] of Object.entries(colors)) { for (const [key, color] of Object.entries(colors)) {
const canvas = mainRenderer.requireCanvas(); const canvas = mainRenderer.requireCanvas();

View File

@ -56,9 +56,11 @@ export {};
core.status.maps[data].enemy?.calRealAttribute(); core.status.maps[data].enemy?.calRealAttribute();
core.updateStatusBar(true, true); core.updateStatusBar(true, true);
} }
Mota.require('@motajs/legacy-ui').Shadow.update(true); Mota.require('@user/client-modules').Shadow.update(true);
const Binder = Mota.require('@motajs/render').LayerGroupFloorBinder; const Binder = Mota.require(
Binder.activedBinder.forEach(v => { '@user/client-modules'
).LayerGroupFloorBinder;
Binder.activeBinder.forEach(v => {
if (v.getFloor() === core.status.floorId) { if (v.getFloor() === core.status.floorId) {
v.updateBindData(); v.updateBindData();
} }

View File

@ -1,6 +1,6 @@
import { has, ofDir } from '@user/data-utils'; import { has, ofDir } from '@user/data-utils';
export function init() { export function createCheckBlock() {
// 伤害弹出 // 伤害弹出
// 复写阻激夹域检测 // 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery: boolean = false) { control.prototype.checkBlock = function (forceMockery: boolean = false) {
@ -52,7 +52,7 @@ function checkMockery(loc: string, force: boolean = false) {
action.push({ type: 'forbidSave', forbid: true }); action.push({ type: 'forbidSave', forbid: true });
action.push({ type: 'changePos', direction: dir }); action.push({ type: 'changePos', direction: dir });
const blocks = core.getMapBlocksObj(); const blocks = core.getMapBlocksObj();
while (1) { while (true) {
x += dx; x += dx;
y += dy; y += dy;
const block = blocks[`${x},${y}`]; const block = blocks[`${x},${y}`];

View File

@ -1,6 +1,8 @@
import { init as initCheckBlock } from './checkblock'; import { createCheckBlock } from './checkblock';
initCheckBlock(); export function createEnemy() {
createCheckBlock();
}
export * from './checkblock'; export * from './checkblock';
export * from './remainEnemy'; export * from './remainEnemy';

View File

@ -4,10 +4,12 @@ import { initFiveLayer } from './fiveLayer';
import { createHook } from './hook'; import { createHook } from './hook';
import { initReplay } from './replay'; import { initReplay } from './replay';
import { initUI } from './ui'; import { initUI } from './ui';
import { createEnemy } from './enemy';
export function createLegacy() { export function createLegacy() {
initFallback(); initFallback();
loading.once('coreInit', () => { loading.once('coreInit', () => {
createEnemy();
initFiveLayer(); initFiveLayer();
createHook(); createHook();
initReplay(); initReplay();
@ -15,6 +17,7 @@ export function createLegacy() {
}); });
} }
export * from './enemy';
export * from './chase'; export * from './chase';
export * from './fallback'; export * from './fallback';
export * from './fiveLayer'; export * from './fiveLayer';

View File

@ -62,10 +62,15 @@ export function initReplay() {
core.registerReplayAction('upgradeSkill', name => { core.registerReplayAction('upgradeSkill', name => {
if (!name.startsWith('skill:')) return false; if (!name.startsWith('skill:')) return false;
const skill = parseInt(name.slice(6)); const skill = parseInt(name.slice(6));
upgradeSkill(skill); const success = upgradeSkill(skill);
const s = getSkillFromIndex(skill); const s = getSkillFromIndex(skill);
const skillName = s?.title; const skillName = s?.title;
core.status.route.push(name); core.status.route.push(name);
if (!success) {
const { tip } = Mota.require('@motajs/legacy-ui');
tip('error', `升级技能:${skillName}失败`);
return false;
}
tipAndWait(`升级技能:${skillName}`, 1000).then(() => { tipAndWait(`升级技能:${skillName}`, 1000).then(() => {
core.replay(); core.replay();
}); });

View File

@ -2,9 +2,7 @@
"normal": [ "normal": [
{ {
"name": "虚惊一场", "name": "虚惊一场",
"text": [ "text": ["打完山洞门口的兽人后只剩一滴血"],
"打完山洞门口的兽人后只剩一滴血"
],
"point": 30 "point": 30
}, },
{ {
@ -18,44 +16,34 @@
"challenge": [ "challenge": [
{ {
"name": "逃出生天", "name": "逃出生天",
"text": [ "text": ["通过山路追逐战的困难难度"],
"通过山路追逐战的困难难度"
],
"point": 20 "point": 20
}, },
{ {
"name": "冰与火之舞", "name": "冰与火之舞",
"text": [ "text": ["完成第二章音游特殊战的困难难度"],
"完成第二章音游特殊战的困难难度"
],
"point": 50 "point": 50
} }
], ],
"explore": [ "explore": [
{ {
"name": "勇气巅峰", "name": "勇气巅峰",
"text": [ "text": ["第一章完成度达到100%"],
"第一章完成度达到100%" "progress": "${Mota.require('completion_r').getChapterCompletion(1)} / 100",
],
"progress": "${Mota.Plugin.require('completion_r').getChapterCompletion(1)} / 100",
"percent": true, "percent": true,
"point": 50 "point": 50
}, },
{ {
"name": "你是怎么办到的?!", "name": "你是怎么办到的?!",
"text": [ "text": ["与山路上的若干个神秘木牌对话"],
"与山路上的若干个神秘木牌对话"
],
"progress": "${core.getLocalStorage('mountSign', 0)} / 5", "progress": "${core.getLocalStorage('mountSign', 0)} / 5",
"hide": "该探索成就需要你自己探索如何达成", "hide": "该探索成就需要你自己探索如何达成",
"point": 25 "point": 25
}, },
{ {
"name": "智慧之心", "name": "智慧之心",
"text": [ "text": ["第二章完成度达到100%"],
"第二章完成度达到100%" "progress": "${Mota.require('completion_r').getChapterCompletion(2)} / 100",
],
"progress": "${Mota.Plugin.require('completion_r').getChapterCompletion(2)} / 100",
"percent": true, "percent": true,
"point": 50 "point": 50
}, },
@ -69,20 +57,16 @@
}, },
{ {
"name": "学坏了", "name": "学坏了",
"text": [ "text": ["学习电摇嘲讽技能"],
"学习电摇嘲讽技能"
],
"hide": "该探索成就需要你自己探索如何达成", "hide": "该探索成就需要你自己探索如何达成",
"point": 20 "point": 20
}, },
{ {
"name": "满腹经纶", "name": "满腹经纶",
"text": [ "text": ["把第二章中所有能学习的技能都学一遍"],
"把第二章中所有能学习的技能都学一遍"
],
"hide": "该探索成就需要你自己探索如何达成", "hide": "该探索成就需要你自己探索如何达成",
"progress": "", "progress": "",
"point": 50 "point": 50
} }
] ]
} }

View File

@ -24,7 +24,8 @@ export class MotaOffscreenCanvas2D extends EventEmitter<OffscreenCanvasEvent> {
/** /**
* \ * \
* ****使使使 `RenderItem.requireCanvas` * ****使使使 `RenderItem.requireCanvas`
* 使使 `RenderItem.deleteCanvas`
* @param alpha * @param alpha
* @param canvas * @param canvas
*/ */

View File

@ -348,10 +348,10 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
/** 这个渲染元素使用到的所有画布 */ /** 这个渲染元素使用到的所有画布 */
protected readonly canvases: Set<MotaOffscreenCanvas2D> = new Set(); protected readonly canvases: Set<MotaOffscreenCanvas2D> = new Set();
/** 这个渲染元素每个画布的配置信息 */ /** 这个渲染元素每个画布的配置信息 */
private readonly canvasMap: Map< private readonly canvasMap: WeakMap<
MotaOffscreenCanvas2D, MotaOffscreenCanvas2D,
RenderItemCanvasData RenderItemCanvasData
> = new Map(); > = new WeakMap();
//#endregion //#endregion
//#region 交互事件 //#region 交互事件
@ -1305,6 +1305,14 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
this.emit('destroy'); this.emit('destroy');
this.removeAllListeners(); this.removeAllListeners();
this.canvases.clear(); this.canvases.clear();
this.cache.clear();
this.propagationStoped.clear();
this.cachedEvent.clear();
this.mouseId.clear();
this.touchId.clear();
this.children.clear();
this._root = void 0;
this._parent = void 0;
} }
} }

View File

@ -241,10 +241,12 @@ actions.prototype._sys_onkeyUp_replay = function (e) {
else if (e.keyCode == 65) else if (e.keyCode == 65)
// A // A
core.rewindReplay(); core.rewindReplay();
else if (e.keyCode == 83) else if (e.keyCode == 83) {
// S // S
core.control._replay_SL(); const { saveSave, mainUIController, MAIN_WIDTH, MAIN_HEIGHT } =
else if (e.keyCode == 88) Mota.require('@user/client-modules');
saveSave(mainUIController, [0, 0, MAIN_WIDTH, MAIN_HEIGHT]);
} else if (e.keyCode == 88)
// X // X
core.control._replay_book(); core.control._replay_book();
else if (e.keyCode == 33 || e.keyCode == 34) else if (e.keyCode == 33 || e.keyCode == 34)

View File

@ -1275,10 +1275,6 @@ control.prototype.startReplay = function (list) {
core.setOpacity('replay', 0.6); core.setOpacity('replay', 0.6);
this._replay_drawProgress(); this._replay_drawProgress();
core.updateStatusBar(false, true); core.updateStatusBar(false, true);
// Mota.Plugin.require('utils_r').tip(
// 'warn',
// '由于不可抗力,录像播放过程中将没有勇士移动动画'
// );
Mota.require('@user/data-base').hook.emit('replayStatus', false); Mota.require('@user/data-base').hook.emit('replayStatus', false);
this.replay(); this.replay();
}; };

View File

@ -39,7 +39,7 @@ main.floors.MT12=
"手机端可以点击右下角的难度来切换下方工具栏至数字键", "手机端可以点击右下角的难度来切换下方工具栏至数字键",
{ {
"type": "function", "type": "function",
"function": "function(){\nconst HeroSkill = Mota.require('@user/data-state').Mechanism.HeroSkill;\nHeroSkill.learnSkill(HeroSkill.Jump);\n}" "function": "function(){\nconst HeroSkill = Mota.require('@user/data-state').HeroSkill;\nHeroSkill.learnSkill(HeroSkill.Jump);\n}"
}, },
{ {
"type": "hide", "type": "hide",

View File

@ -70,7 +70,7 @@ main.floors.MT16=
}, },
{ {
"type": "function", "type": "function",
"function": "function(){\ncore.status.maps.MT14.canFlyFrom = false;\nMota.Plugin.require('chase_g').chaseInit1();\n}" "function": "function(){\ncore.status.maps.MT14.canFlyFrom = false;\nMota.require('chase_g').chaseInit1();\n}"
}, },
{ {
"type": "show", "type": "show",
@ -89,7 +89,7 @@ main.floors.MT16=
"no": [ "no": [
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('replay_g').readyClip();\n}" "function": "function(){\nMota.require('@user/legacy-plugin-data').readyClip();\n}"
}, },
{ {
"type": "choices", "type": "choices",
@ -400,7 +400,7 @@ main.floors.MT16=
}, },
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('chase_r').start(false);\n}" "function": "function(){\nMota.require('legacy-plugin-client').start(false);\n}"
}, },
{ {
"type": "autoSave" "type": "autoSave"

View File

@ -56,7 +56,7 @@ main.floors.MT17=
"12,6": [ "12,6": [
{ {
"type": "function", "type": "function",
"function": "function(){\nif (core.status.hero.hp - flags.hphphp >= 150000) {\n\tMota.Plugin.require('achievement_r').completeAchievement('normal', 1);\n}\ndelete flags.hphphp;\n}" "function": "function(){\nif (core.status.hero.hp - flags.hphphp >= 150000) {\n\t//Mota.require('achievement_r').completeAchievement('normal', 1);\n}\ndelete flags.hphphp;\n}"
} }
] ]
}, },

View File

@ -157,7 +157,7 @@ main.floors.MT21=
"\t[低级智人]\b[up,hero]或许智慧结晶会告诉我答案吧。", "\t[低级智人]\b[up,hero]或许智慧结晶会告诉我答案吧。",
{ {
"type": "function", "type": "function",
"function": "function(){\nif (!core.isReplaying()) Mota.require('@motajs/legacy-ui').fixedUi.open('chapter', { chapter: '第二章 智慧' });\nMota.Plugin.require('removeMap_g').removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}" "function": "function(){\nif (!core.isReplaying()) Mota.require('@motajs/legacy-ui').fixedUi.open('chapter', { chapter: '第二章 智慧' });\nMota.require('removeMap_g').removeMaps('tower1', 'tower7', true);\ndelete flags.tower1;\ndelete flags.wordsTimeOut;\ndelete flags.boom;\ndelete flags.booming;\n}"
}, },
{ {
"type": "setValue", "type": "setValue",

View File

@ -16,7 +16,7 @@ main.floors.MT32=
"firstArrive": [ "firstArrive": [
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('removeMap_g').removeMaps('MT17', 'MT21', true)\n}" "function": "function(){\nMota.require('removeMap_g').removeMaps('MT17', 'MT21', true)\n}"
} }
], ],
"eachArrive": [], "eachArrive": [],

View File

@ -101,7 +101,7 @@ main.floors.MT35=
}, },
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('removeMap_g').removeMaps('MT22', 'MT31', true);\n}" "function": "function(){\nMota.require('removeMap_g').removeMaps('MT22', 'MT31', true);\n}"
}, },
{ {
"type": "changeFloor", "type": "changeFloor",

View File

@ -70,7 +70,7 @@ main.floors.MT41=
"那我就送你回到标题界面吧!", "那我就送你回到标题界面吧!",
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('achievement_r').completeAchievement('explore', 0);\n}" "function": "function(){\n//Mota.require('achievement_r').completeAchievement('explore', 0);\n}"
}, },
{ {
"type": "restart" "type": "restart"

View File

@ -124,7 +124,7 @@ main.floors.MT6=
"4,12": [ "4,12": [
{ {
"type": "function", "type": "function",
"function": "function(){\nif (core.status.hero.hp === 1) {\n\tMota.Plugin.require('achievement_r').completeAchievement('normal', 0);\n}\n}" "function": "function(){\nif (core.status.hero.hp === 1) {\n\t//Mota.require('achievement_r').completeAchievement('normal', 0);\n}\n}"
} }
] ]
}, },

View File

@ -123,7 +123,7 @@ main.floors.tower7=
"下面,就让我们开始吧!", "下面,就让我们开始吧!",
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('replay_g').readyClip();\n}" "function": "function(){\nMota.require('@user/legacy-plugin-data').readyClip();\n}"
} }
] ]
}, },
@ -168,7 +168,7 @@ main.floors.tower7=
}, },
{ {
"type": "function", "type": "function",
"function": "function(){\nMota.Plugin.require('boss_r').startTowerBoss();\n}" "function": "function(){\nMota.require('boss_r').startTowerBoss();\n}"
} }
], ],
"eachArrive": [], "eachArrive": [],

View File

@ -218,7 +218,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
} }
} }
// if (!flags.debug && !main.replayChecking) // if (!flags.debug && !main.replayChecking)
// Mota.Plugin.require('completion_r').checkVisitedFloor(); // Mota.require('completion_r').checkVisitedFloor();
Mota.require('@user/data-base').hook.emit( Mota.require('@user/data-base').hook.emit(
'afterChangeFloor', 'afterChangeFloor',
floorId floorId

View File

@ -40,8 +40,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "小绿宝石", "name": "小绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(20 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(20 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(20 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(20 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -626,8 +626,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "中绿宝石", "name": "中绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(40 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(40 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(40 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(40 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -729,8 +729,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "大绿宝石", "name": "大绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(80 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(80 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(80 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(80 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -896,8 +896,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "超大绿宝石", "name": "超大绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(160 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(160 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(160 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(160 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -1019,8 +1019,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "璀璨绿宝石", "name": "璀璨绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(320 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(320 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(320 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(320 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -1050,8 +1050,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "传奇绿宝石", "name": "传奇绿宝石",
"text": ",防御+${core.values.blueGem}", "text": ",防御+${core.values.blueGem}",
"itemEffect": "core.status.hero.mdef += Math.round(640 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(640 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(640 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(640 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.def += core.values.blueGem", "useItemEffect": "core.status.hero.def += core.values.blueGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
@ -1071,8 +1071,8 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items", "cls": "items",
"name": "史诗绿宝石", "name": "史诗绿宝石",
"text": ",护盾+${core.values.greenGem}", "text": ",护盾+${core.values.greenGem}",
"itemEffect": "core.status.hero.mdef += Math.round(1280 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))", "itemEffect": "core.status.hero.mdef += Math.round(1280 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))",
"itemEffectTip": ",智慧+${Math.round(1280 * core.status.thisMap.ratio / (core.getFlag(\"hard\") + 1) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}", "itemEffectTip": ",智慧+${Math.round(1280 * core.status.thisMap.ratio / (core.getFlag('hard')) * (Mota.require('@user/data-state').getSkillLevel(12) / 20 + 1))}",
"useItemEffect": "core.status.hero.mdef += core.values.greenGem", "useItemEffect": "core.status.hero.mdef += core.values.greenGem",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },

View File

@ -1,7 +1,7 @@
import { build, loadConfigFromFile, mergeConfig, UserConfig } from 'vite'; import { build, loadConfigFromFile, mergeConfig, UserConfig } from 'vite';
import legacy from '@vitejs/plugin-legacy'; import legacy from '@vitejs/plugin-legacy';
import { resolve } from 'path'; import { resolve } from 'path';
import { copy, emptyDir, ensureDir } from 'fs-extra'; import { copy, emptyDir, ensureDir, pathExists } from 'fs-extra';
import { OutputAsset, OutputChunk, RollupOutput } from 'rollup'; import { OutputAsset, OutputChunk, RollupOutput } from 'rollup';
import Fontmin from 'fontmin'; import Fontmin from 'fontmin';
import { readdir, readFile, rmdir, stat, writeFile } from 'fs/promises'; import { readdir, readFile, rmdir, stat, writeFile } from 'fs/promises';
@ -597,6 +597,15 @@ async function buildGame() {
resolve(process.cwd(), 'script/template/启动服务.exe'), resolve(process.cwd(), 'script/template/启动服务.exe'),
resolve(distDir, '启动服务.exe') resolve(distDir, '启动服务.exe')
); );
const bgPath = 'project/images/bg.jpg';
if (await pathExists(resolve(tempDir, 'client', bgPath))) {
await copy(
resolve(tempDir, 'client', bgPath),
resolve(distDir, bgPath)
);
}
} catch (e) { } catch (e) {
logProgress(6, ProgressStatus.Fail); logProgress(6, ProgressStatus.Fail);
process.stderr.write(String(e)); process.stderr.write(String(e));