mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 23:29:27 +08:00
fix: 瞬移
This commit is contained in:
parent
529968a7a1
commit
e5291e335a
@ -977,6 +977,7 @@ control.prototype.moveDirectly = function (destX, destY, ignoreSteps) {
|
||||
|
||||
////// 尝试瞬间移动 //////
|
||||
control.prototype.tryMoveDirectly = function (destX, destY) {
|
||||
// console.trace();
|
||||
if (this.nearHero(destX, destY)) return false;
|
||||
var canMoveArray = core.maps.generateMovableArray();
|
||||
var dirs = [
|
||||
|
@ -87,24 +87,6 @@ export function init() {
|
||||
core.fillBoldText(ctx, one.text, px, py, one.color as string);
|
||||
});
|
||||
};
|
||||
|
||||
control.prototype.moveHero = function (
|
||||
direction: Dir,
|
||||
callback: () => void
|
||||
) {
|
||||
// 如果正在移动,直接return
|
||||
if (core.status.heroMoving != 0) return;
|
||||
if (core.isset(direction)) core.setHeroLoc('direction', direction);
|
||||
|
||||
const nx = core.nextX();
|
||||
const ny = core.nextY();
|
||||
if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) {
|
||||
core.autosave();
|
||||
}
|
||||
|
||||
if (callback) return this.moveAction(callback);
|
||||
this._moveHero_moving();
|
||||
};
|
||||
}
|
||||
|
||||
function checkMockery(loc: string, force: boolean = false) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { RenderAdapter } from '@/core/render/adapter';
|
||||
import type { HeroRenderer } from '@/core/render/preset/hero';
|
||||
import { hook } from '@/game/game';
|
||||
|
||||
interface Adapters {
|
||||
'hero-adapter'?: RenderAdapter<HeroRenderer>;
|
||||
@ -77,7 +78,7 @@ export function init() {
|
||||
await adapter.all('readyMove');
|
||||
moving = true;
|
||||
stopChian = false;
|
||||
return startHeroMoveChain();
|
||||
startHeroMoveChain();
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,6 +246,38 @@ export function init() {
|
||||
callback?.();
|
||||
});
|
||||
};
|
||||
|
||||
control.prototype.moveHero = async function (
|
||||
direction: Dir,
|
||||
callback: () => void
|
||||
) {
|
||||
// 如果正在移动,直接return
|
||||
if (core.status.heroMoving != 0) return;
|
||||
if (core.isset(direction)) core.setHeroLoc('direction', direction);
|
||||
|
||||
const nx = core.nextX();
|
||||
const ny = core.nextY();
|
||||
if (core.status.thisMap.enemy.mapDamage[`${nx},${ny}`]?.mockery) {
|
||||
core.autosave();
|
||||
}
|
||||
|
||||
console.trace();
|
||||
|
||||
moveDir = direction;
|
||||
stepDir = direction;
|
||||
await readyMove();
|
||||
stopChian = true;
|
||||
|
||||
callback?.();
|
||||
|
||||
// if (callback) return this.moveAction(callback);
|
||||
// this._moveHero_moving();
|
||||
};
|
||||
|
||||
hook.on('reset', () => {
|
||||
moveDir = core.status.hero.loc.direction;
|
||||
stepDir = moveDir;
|
||||
});
|
||||
});
|
||||
|
||||
return { readyMove, endMove, move };
|
||||
|
Loading…
Reference in New Issue
Block a user