fix: 高倍速动画

This commit is contained in:
unanmed 2024-11-20 16:38:47 +08:00
parent 001c91c312
commit c6cf6287de
4 changed files with 34 additions and 16 deletions

View File

@ -1324,7 +1324,10 @@ control.prototype.startReplay = function (list) {
core.setOpacity('replay', 0.6);
this._replay_drawProgress();
core.updateStatusBar(false, true);
core.drawTip('开始播放');
// Mota.Plugin.require('utils_r').tip(
// 'warn',
// '由于不可抗力,录像播放过程中将没有勇士移动动画'
// );
Mota.require('var', 'hook').emit('replayStatus', false);
Mota.require('class', 'CustomToolbar').setDefaultTool(true);
this.replay();

View File

@ -40,6 +40,8 @@ export class HeroRenderer
/** 勇士移动速度 */
speed: number = 100;
/** 勇士移动的真正速度,经过录像修正 */
realSpeed: number = 100;
/** 当前的移动方向 */
moveDir: Dir2 = 'down';
@ -83,6 +85,7 @@ export class HeroRenderer
*/
setMoveSpeed(speed: number) {
this.speed = speed;
this.fixMoveSpeed();
}
/**
@ -200,13 +203,14 @@ export class HeroRenderer
if (!this.renderable) return;
if (this.moving) {
const progress = (time - this.lastStepTime) / this.speed;
const progress = (time - this.lastStepTime) / this.realSpeed;
const { x: dx, y: dy } = this.stepDelta;
const { x, y } = core.status.hero.loc;
if (progress >= 1) {
this.renderable.x = x + dx;
this.renderable.y = y + dy;
this.fixMoveSpeed();
this.emit('stepEnd');
} else {
const rx = dx * progress + x;
@ -229,6 +233,15 @@ export class HeroRenderer
this.turn(this.stepDir);
}
private fixMoveSpeed() {
if (!core.isReplaying()) {
this.realSpeed = this.speed;
} else {
const replay = core.status.replay.speed;
this.realSpeed = replay === 24 ? 1 : this.speed / replay;
}
}
/**
*
*/

View File

@ -486,10 +486,10 @@ export class HeroMover extends ObjectMoverBase {
const adapter = HeroMover.adapter;
const viewport = HeroMover.viewport;
if (!adapter || !viewport) return;
if (!core.isReplaying()) {
adapter.sync('startAnimate');
await adapter.all('readyMove');
}
// if (!core.isReplaying()) {
adapter.sync('startAnimate');
await adapter.all('readyMove');
// }
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
if (!this.ignoreTerrain) {
const { x, y } = core.status.hero.loc;
@ -511,10 +511,10 @@ export class HeroMover extends ObjectMoverBase {
const adapter = HeroMover.adapter;
const viewport = HeroMover.viewport;
if (!adapter || !viewport) return;
if (!core.isReplaying()) {
await adapter.all('endMove');
adapter.sync('endAnimate');
}
// if (!core.isReplaying()) {
await adapter.all('endMove');
adapter.sync('endAnimate');
// }
viewport.sync('endMove');
core.clearContinueAutomaticRoute();
core.stopAutomaticRoute();
@ -685,12 +685,12 @@ export class HeroMover extends ObjectMoverBase {
const speed = replay === 24 ? 1 : this.moveSpeed / replay;
viewport.all('moveTo', x, y, speed * 1.6);
adapter.sync('setAnimateDir', showDir);
if (core.isReplaying()) {
await sleep(speed);
await adapter.all('setHeroLoc', x, y);
} else {
await adapter.all('move', moveDir);
}
// if (core.isReplaying()) {
// await sleep(speed);
// await adapter.all('setHeroLoc', x, y);
// } else {
await adapter.all('move', moveDir);
// }
}
/**

View File

@ -7,6 +7,7 @@ import * as gameCanvas from './fx/gameCanvas';
import * as animateController from './animateController';
import * as achievement from './ui/achievement';
import * as boss from './boss';
import * as utils from './utils';
import './loopMap';
Mota.Plugin.register('fly_r', fly);
@ -23,3 +24,4 @@ Mota.Plugin.register(
Mota.Plugin.register('chase_r', chase);
Mota.Plugin.register('achievement_r', achievement);
Mota.Plugin.register('boss_r', boss);
Mota.Plugin.register('utils_r', utils);