mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
fix: 撞墙上时平滑视角卡住
This commit is contained in:
parent
4dd046cee3
commit
f09704f7da
@ -163,8 +163,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
const setTargetX = (x: number, time: number) => {
|
const setTargetX = (x: number, time: number) => {
|
||||||
if (x === xTarget) return;
|
if (x === xTarget) return;
|
||||||
xTarget = x;
|
xTarget = x;
|
||||||
xStart = this.ox;
|
|
||||||
xStartTime = time;
|
xStartTime = time;
|
||||||
|
xStart = this.ox;
|
||||||
};
|
};
|
||||||
const setTargetY = (y: number, time: number) => {
|
const setTargetY = (y: number, time: number) => {
|
||||||
if (y === yTarget) return;
|
if (y === yTarget) return;
|
||||||
@ -186,8 +186,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
if (!ending) {
|
if (!ending) {
|
||||||
const dir = this.hero.stepDir;
|
const dir = this.hero.stepDir;
|
||||||
const { x, y } = core.utils.scan2[dir];
|
const { x, y } = core.utils.scan2[dir];
|
||||||
if (x !== 0) setTargetX(-x * this.maxOffset, now);
|
setTargetX(-x * this.maxOffset, now);
|
||||||
if (y !== 0) setTargetY(-y * this.maxOffset, now);
|
setTargetY(-y * this.maxOffset, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.hero.renderable) return;
|
if (!this.hero.renderable) return;
|
||||||
@ -202,7 +202,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.ox !== xTarget) {
|
if (this.ox !== xTarget) {
|
||||||
const progress = (now - xStartTime) / transitionTime;
|
const time = transitionTime * Math.abs(xStart - xTarget);
|
||||||
|
const progress = (now - xStartTime) / time;
|
||||||
if (progress > 1) {
|
if (progress > 1) {
|
||||||
this.ox = xTarget;
|
this.ox = xTarget;
|
||||||
} else {
|
} else {
|
||||||
@ -211,7 +212,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.oy !== yTarget) {
|
if (this.oy !== yTarget) {
|
||||||
const progress = (now - yStartTime) / transitionTime;
|
const time = transitionTime * Math.abs(yStart - yTarget);
|
||||||
|
const progress = (now - yStartTime) / time;
|
||||||
if (progress > 1) {
|
if (progress > 1) {
|
||||||
this.oy = yTarget;
|
this.oy = yTarget;
|
||||||
} else {
|
} else {
|
||||||
|
@ -484,7 +484,12 @@ export class HeroMover extends ObjectMoverBase {
|
|||||||
const viewport = HeroMover.viewport;
|
const viewport = HeroMover.viewport;
|
||||||
if (!adapter || !viewport) return;
|
if (!adapter || !viewport) return;
|
||||||
await adapter.all('readyMove');
|
await adapter.all('readyMove');
|
||||||
viewport.sync('startMove');
|
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
|
||||||
|
const { x, y } = core.status.hero.loc;
|
||||||
|
const data = this.checkCanMove(x, y, toDir(this.faceDir));
|
||||||
|
if (data.canMove && !data.noPass) {
|
||||||
|
viewport.sync('startMove');
|
||||||
|
}
|
||||||
adapter.sync('startAnimate');
|
adapter.sync('startAnimate');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user