fix: 怪物手册前后移动5个 & 编辑器大地图绘制

This commit is contained in:
AncTe committed 2024-10-03 18:19:13 +08:00
1 parent f8a1ea503c
commit ec5381e2bb
4 files changed
+27 -98

No files matched your search

-73
View File
@@ -1,73 +0,0 @@
import { debounce } from 'lodash-es';
import { Transition, hyper } from 'mutate-animate';
const tran = new Transition();
tran.value.x = 0;
tran.value.y = 0;
let needSmooth = false;
export function init() {
const setting = Mota.require('var', 'mainSetting');
tran.ticker.add(() => {
if (core.isPlaying() && needSmooth && !core.isReplaying()) {
core.setViewport(tran.value.x, tran.value.y);
}
});
const func = debounce(() => {
needSmooth = false;
}, 700);
Mota.rewrite(
core.control,
'_drawHero_updateViewport',
'full',
(x, y, offset) => {
const ox = core.clamp(
(x - core._HALF_WIDTH_) * 32 + offset.x,
0,
Math.max(32 * core.bigmap.width - core._PX_, 0)
);
const oy = core.clamp(
(y - core._HALF_HEIGHT_) * 32 + offset.y,
0,
Math.max(32 * core.bigmap.height - core._PY_, 0)
);
tran.transition('x', ox).transition('y', oy);
const t = setting.getValue('screen.smoothView', false);
if (!t || core.isReplaying()) {
core.bigmap.offsetX = ox;
core.bigmap.offsetY = oy;
core.control.updateViewport();
return;
}
if (tran.easeTime > 0) {
needSmooth = true;
func();
} else {
core.setViewport(tran.value.x, tran.value.y);
}
}
);
const hso = hyper('sin', 'out');
let time2 = Date.now();
Mota.rewrite(core.control, '_moveAction_moving', 'front', () => {
const f = core.status.floorId === 'tower6';
const t = setting.getValue('screen.smoothView', false) && !f ? 200 : 0;
if (Date.now() - time2 > 20) tran.mode(hso).time(t).absolute();
});
Mota.rewrite(core.control, 'moveDirectly', 'front', () => {
const f = core.status.floorId === 'tower6';
const t = setting.getValue('screen.smoothView', false) && !f ? 600 : 0;
time2 = Date.now();
tran.mode(hso).time(t).absolute();
});
Mota.rewrite(core.events, '_changeFloor_beforeChange', 'front', () => {
tran.time(0).absolute();
});
}