mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 23:29:27 +08:00
fix: 跨循环地图打怪
This commit is contained in:
parent
a05981e675
commit
0039c0d65b
@ -428,7 +428,9 @@ const enum HeroMoveCode {
|
|||||||
/** 进入传送门 */
|
/** 进入传送门 */
|
||||||
Portal,
|
Portal,
|
||||||
/** 循环式地图 */
|
/** 循环式地图 */
|
||||||
Loop
|
Loop,
|
||||||
|
/** 循环式地图撞击 */
|
||||||
|
LoopHit
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HeroMover extends ObjectMoverBase {
|
export class HeroMover extends ObjectMoverBase {
|
||||||
@ -546,23 +548,27 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
if (!this.ignoreTerrain) {
|
if (!this.ignoreTerrain) {
|
||||||
const { noPass, canMove } = this.checkCanMove(x, y, showDir);
|
const { noPass, canMove } = this.checkCanMove(x, y, showDir);
|
||||||
|
|
||||||
// 不能移动
|
if (!canMove) {
|
||||||
if (noPass || !canMove) {
|
return HeroMoveCode.CannotMove;
|
||||||
if (!canMove) return HeroMoveCode.CannotMove;
|
|
||||||
else return HeroMoveCode.Hit;
|
|
||||||
}
|
}
|
||||||
|
// 循环式地图
|
||||||
const floorId = core.status.floorId;
|
const floorId = core.status.floorId;
|
||||||
if (MiscData.loopMaps.has(core.status.floorId)) {
|
if (MiscData.loopMaps.has(core.status.floorId)) {
|
||||||
const floor = core.status.maps[floorId];
|
const floor = core.status.maps[floorId];
|
||||||
const width = floor.width;
|
const width = floor.width;
|
||||||
if (x === 0 && dir === 'left') {
|
if (x === 0 && dir === 'left') {
|
||||||
|
if (noPass) {
|
||||||
|
return HeroMoveCode.LoopHit;
|
||||||
|
}
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.renderHeroLoop(),
|
this.renderHeroLoop(),
|
||||||
this.moveAnimate(nx, ny, showDir, dir)
|
this.moveAnimate(nx, ny, showDir, dir)
|
||||||
]);
|
]);
|
||||||
return HeroMoveCode.Loop;
|
return HeroMoveCode.Loop;
|
||||||
} else if (x === width - 1 && dir === 'right') {
|
} else if (x === width - 1 && dir === 'right') {
|
||||||
|
if (noPass) {
|
||||||
|
return HeroMoveCode.LoopHit;
|
||||||
|
}
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.renderHeroLoop(),
|
this.renderHeroLoop(),
|
||||||
this.moveAnimate(nx, ny, showDir, dir)
|
this.moveAnimate(nx, ny, showDir, dir)
|
||||||
@ -570,6 +576,10 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
return HeroMoveCode.Loop;
|
return HeroMoveCode.Loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 不能移动
|
||||||
|
if (noPass) {
|
||||||
|
return HeroMoveCode.Hit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 可以移动,显示移动动画
|
// 可以移动,显示移动动画
|
||||||
@ -588,11 +598,19 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
const showDir = toDir(this.moveDir);
|
const showDir = toDir(this.moveDir);
|
||||||
|
|
||||||
// 前方不能移动
|
// 前方不能移动
|
||||||
if (code === HeroMoveCode.CannotMove || code === HeroMoveCode.Hit) {
|
if (
|
||||||
|
code === HeroMoveCode.CannotMove ||
|
||||||
|
code === HeroMoveCode.Hit ||
|
||||||
|
code === HeroMoveCode.LoopHit
|
||||||
|
) {
|
||||||
controller.stop();
|
controller.stop();
|
||||||
this.onCannotMove(showDir);
|
this.onCannotMove(showDir);
|
||||||
if (code === HeroMoveCode.Hit) {
|
if (code === HeroMoveCode.Hit) {
|
||||||
core.trigger(nx, ny);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user