fix: 录像验证

This commit is contained in:
unanmed 2024-03-11 22:02:55 +08:00
parent 3f808a848c
commit d4467b4d11
7 changed files with 81 additions and 43 deletions

View File

@ -10,3 +10,4 @@ public/editor.html
keyCodes.ts keyCodes.ts
*.md *.md
setting.ts setting.ts
dist/project/data.js

View File

@ -3394,58 +3394,74 @@ control.prototype.screenFlash = function (
control.prototype.playBgm = function (bgm, startTime) { control.prototype.playBgm = function (bgm, startTime) {
bgm = core.getMappedName(bgm); bgm = core.getMappedName(bgm);
if (main.mode !== 'play') return; if (main.mode !== 'play') return;
Mota.r(() => {
Mota.require('var', 'bgm').changeTo(bgm, startTime); Mota.require('var', 'bgm').changeTo(bgm, startTime);
});
}; };
////// 暂停背景音乐的播放 ////// ////// 暂停背景音乐的播放 //////
control.prototype.pauseBgm = function () { control.prototype.pauseBgm = function () {
if (main.mode !== 'play') return; if (main.mode !== 'play') return;
Mota.r(() => {
Mota.require('var', 'bgm').pause(); Mota.require('var', 'bgm').pause();
});
}; };
////// 恢复背景音乐的播放 ////// ////// 恢复背景音乐的播放 //////
control.prototype.resumeBgm = function (resumeTime) { control.prototype.resumeBgm = function (resumeTime) {
if (main.mode !== 'play') return; if (main.mode !== 'play') return;
Mota.r(() => {
Mota.require('var', 'bgm').resume(); Mota.require('var', 'bgm').resume();
});
}; };
////// 更改背景音乐的播放 ////// ////// 更改背景音乐的播放 //////
control.prototype.triggerBgm = function () { control.prototype.triggerBgm = function () {
if (main.mode !== 'play') return; if (main.mode !== 'play') return;
Mota.r(() => {
const bgm = Mota.require('var', 'bgm'); const bgm = Mota.require('var', 'bgm');
bgm.disable = !bgm.disable; bgm.disable = !bgm.disable;
if (!bgm.disable) this.resumeBgm(); if (!bgm.disable) this.resumeBgm();
else this.pauseBgm(); else this.pauseBgm();
});
}; };
// todo: deprecate playSound, stopSound, getPlayingSounds // todo: deprecate playSound, stopSound, getPlayingSounds
////// 播放音频 ////// ////// 播放音频 //////
control.prototype.playSound = function (sound, pitch, callback) { control.prototype.playSound = function (sound, pitch, callback) {
Mota.r(() => {
sound = core.getMappedName(sound); sound = core.getMappedName(sound);
Mota.require('var', 'sound').play(sound, callback); Mota.require('var', 'sound').play(sound, callback);
});
}; };
////// 停止所有音频 ////// ////// 停止所有音频 //////
control.prototype.stopSound = function (id) { control.prototype.stopSound = function (id) {
Mota.r(() => {
if (typeof id === 'number') Mota.require('var', 'sound').stop(id); if (typeof id === 'number') Mota.require('var', 'sound').stop(id);
else Mota.require('var', 'sound').stopAll(); else Mota.require('var', 'sound').stopAll();
});
}; };
////// 获得当前正在播放的所有指定音效的id列表 ////// ////// 获得当前正在播放的所有指定音效的id列表 //////
control.prototype.getPlayingSounds = function (name) { control.prototype.getPlayingSounds = function (name) {
Mota.r(() => {
name = core.getMappedName(name); name = core.getMappedName(name);
return Mota.require('var', 'sound').getPlaying(name); return Mota.require('var', 'sound').getPlaying(name);
});
}; };
////// 检查bgm状态 ////// ////// 检查bgm状态 //////
control.prototype.checkBgm = function () { control.prototype.checkBgm = function () {
Mota.r(() => {
const bgm = Mota.require('var', 'bgm'); const bgm = Mota.require('var', 'bgm');
if (bgm.disable) { if (bgm.disable) {
bgm.pause(); bgm.pause();
} else if (!bgm.playing) { } else if (!bgm.playing) {
bgm.changeTo(bgm.now ?? main.startBgm); bgm.changeTo(bgm.now ?? main.startBgm);
} }
});
}; };
///// 设置屏幕放缩 ////// ///// 设置屏幕放缩 //////

View File

@ -306,6 +306,7 @@ core.prototype.initSync = function (coreData, callback) {
this._forwardFuncs(); this._forwardFuncs();
for (var key in coreData) core[key] = coreData[key]; for (var key in coreData) core[key] = coreData[key];
this._loadGameProcessSync(); this._loadGameProcessSync();
this._loadPluginSync();
this._init_flags(); this._init_flags();
this._init_platform(); this._init_platform();
this._init_others(); this._init_others();
@ -319,6 +320,18 @@ core.prototype._loadPluginAsync = async function () {
if (!main.useCompress) { if (!main.useCompress) {
await main.loadScript(`project/plugins.js?v=${main.version}`); await main.loadScript(`project/plugins.js?v=${main.version}`);
} }
this._initPlugins();
};
core.prototype._loadPluginSync = function () {
if (main.useCompress) main.loadMod('project', 'project', () => 0);
else {
main.pureData.forEach(v => main.loadMod('project', v, () => 0));
}
this._initPlugins();
};
core.prototype._initPlugins = function () {
for (const [key, value] of Object.entries( for (const [key, value] of Object.entries(
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1
)) { )) {
@ -331,10 +344,6 @@ core.prototype._loadPluginAsync = async function () {
} }
}; };
core.prototype._loadPluginSync = function () {
main.loadMod('project', 'plugins', () => 0);
};
core.prototype._loadGameProcess = async function () { core.prototype._loadGameProcess = async function () {
// 加载游戏进程代码 // 加载游戏进程代码
if (main.pluginUseCompress && main.replayChecking) { if (main.pluginUseCompress && main.replayChecking) {

View File

@ -486,7 +486,9 @@ loader.prototype._loadMusic_sync = function () {
core.loader.loadOneSound(t); core.loader.loadOneSound(t);
}); });
// 直接开始播放 // 直接开始播放
Mota.r(() => {
core.playBgm(main.startBgm); core.playBgm(main.startBgm);
});
}; };
loader.prototype._loadMusic_async = function (onprogress, onfinished) { loader.prototype._loadMusic_async = function (onprogress, onfinished) {
@ -525,12 +527,14 @@ loader.prototype.loadOneMusic = function (name) {
music.loop = 'loop'; music.loop = 'loop';
core.material.bgms[name] = music; core.material.bgms[name] = music;
} else { } else {
Mota.r(() => {
if (!main.renderLoaded) { if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => { Mota.require('var', 'hook').once('renderLoaded', () => {
Mota.require('var', 'bgm').add(`bgms.${name}`, music); Mota.require('var', 'bgm').add(`bgms.${name}`, music);
}); });
} }
Mota.require('var', 'bgm').add(`bgms.${name}`, music); Mota.require('var', 'bgm').add(`bgms.${name}`, music);
});
} }
}; };
@ -543,6 +547,7 @@ loader.prototype.loadOneSound = function (name) {
if (main.mode === 'editor') { if (main.mode === 'editor') {
core.loader._loadOneSound_decodeData(name, data); core.loader._loadOneSound_decodeData(name, data);
} else { } else {
Mota.r(() => {
if (!main.renderLoaded) { if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => { Mota.require('var', 'hook').once('renderLoaded', () => {
const sound = Mota.require('var', 'sound'); const sound = Mota.require('var', 'sound');
@ -552,6 +557,7 @@ loader.prototype.loadOneSound = function (name) {
const sound = Mota.require('var', 'sound'); const sound = Mota.require('var', 'sound');
sound.add(`sounds.${name}`, data); sound.add(`sounds.${name}`, data);
} }
});
} }
}, },
function (e) { function (e) {

View File

@ -298,10 +298,15 @@ main.prototype.loadSync = function (mode, callback) {
}); });
core.initSync(coreData, callback); core.initSync(coreData, callback);
main.loading.emit('coreLoaded');
main.loading.emit('coreInit');
core.initStatus.maps = core.maps._initMaps();
core.resize(); core.resize();
main.core = core; main.core = core;
core.completeAchievement = () => 0; core.completeAchievement = () => 0;
core.plugin = { drawLight: 0 };
}; };
main.prototype.loadAsync = async function (mode, callback) { main.prototype.loadAsync = async function (mode, callback) {

View File

@ -114,7 +114,7 @@ class GameListener extends EventEmitter<ListenerEvent> {
constructor() { constructor() {
super(); super();
if (main.replayChecking) return;
if (!!window.core) { if (!!window.core) {
this.init(); this.init();
} else { } else {

View File

@ -31,10 +31,11 @@ export function init() {
floor.enemy.calMapDamage(); floor.enemy.calMapDamage();
core.status.damage.data = []; core.status.damage.data = [];
Mota.r(() => {
floor.enemy.render(true); floor.enemy.render(true);
getItemDetail(floorId, onMap); // 宝石血瓶详细信息 getItemDetail(floorId, onMap); // 宝石血瓶详细信息
this.drawDamage(ctx, floorId); this.drawDamage(ctx, floorId);
});
}; };
} }