From 0039c0d65bf63aeb51e5a50160494ae532d55801 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 19 Oct 2024 21:31:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B7=A8=E5=BE=AA=E7=8E=AF=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E6=89=93=E6=80=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/state/move.ts | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/game/state/move.ts b/src/game/state/move.ts index dd65c76..bc409de 100644 --- a/src/game/state/move.ts +++ b/src/game/state/move.ts @@ -428,7 +428,9 @@ const enum HeroMoveCode { /** 进入传送门 */ Portal, /** 循环式地图 */ - Loop + Loop, + /** 循环式地图撞击 */ + LoopHit } export class HeroMover extends ObjectMoverBase { @@ -546,23 +548,27 @@ export class HeroMover extends ObjectMoverBase { if (!this.ignoreTerrain) { const { noPass, canMove } = this.checkCanMove(x, y, showDir); - // 不能移动 - if (noPass || !canMove) { - if (!canMove) return HeroMoveCode.CannotMove; - else return HeroMoveCode.Hit; + if (!canMove) { + return HeroMoveCode.CannotMove; } - + // 循环式地图 const floorId = core.status.floorId; if (MiscData.loopMaps.has(core.status.floorId)) { const floor = core.status.maps[floorId]; const width = floor.width; if (x === 0 && dir === 'left') { + if (noPass) { + return HeroMoveCode.LoopHit; + } await Promise.all([ this.renderHeroLoop(), this.moveAnimate(nx, ny, showDir, dir) ]); return HeroMoveCode.Loop; } else if (x === width - 1 && dir === 'right') { + if (noPass) { + return HeroMoveCode.LoopHit; + } await Promise.all([ this.renderHeroLoop(), this.moveAnimate(nx, ny, showDir, dir) @@ -570,6 +576,10 @@ export class HeroMover extends ObjectMoverBase { return HeroMoveCode.Loop; } } + // 不能移动 + if (noPass) { + return HeroMoveCode.Hit; + } } // 可以移动,显示移动动画 @@ -588,11 +598,19 @@ export class HeroMover extends ObjectMoverBase { const showDir = toDir(this.moveDir); // 前方不能移动 - if (code === HeroMoveCode.CannotMove || code === HeroMoveCode.Hit) { + if ( + code === HeroMoveCode.CannotMove || + code === HeroMoveCode.Hit || + code === HeroMoveCode.LoopHit + ) { controller.stop(); this.onCannotMove(showDir); if (code === HeroMoveCode.Hit) { core.trigger(nx, ny); + } else if (code === HeroMoveCode.LoopHit) { + const floor = core.status.thisMap; + if (x === 0) core.trigger(floor.width - 1, y); + else core.trigger(0, y); } return; }