diff --git a/public/libs/control.js b/public/libs/control.js index 0e6a9ca..6183be1 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -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(); diff --git a/src/core/render/preset/hero.ts b/src/core/render/preset/hero.ts index 60d2e12..94f2a95 100644 --- a/src/core/render/preset/hero.ts +++ b/src/core/render/preset/hero.ts @@ -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; + } + } + /** * 准备开始移动 */ diff --git a/src/game/state/move.ts b/src/game/state/move.ts index 279dec2..447f0e1 100644 --- a/src/game/state/move.ts +++ b/src/game/state/move.ts @@ -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); + // } } /** diff --git a/src/plugin/index.ts b/src/plugin/index.ts index 610bfe7..d5185bc 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -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);