This commit is contained in:
Hanusiak Piotr 2022-02-07 14:23:34 +01:00
parent d480150728
commit c29ce6e9a9
3 changed files with 17 additions and 8 deletions

View file

@ -163,12 +163,20 @@ export abstract class Character extends Container implements OutlineableInterfac
* Returns position based on where player is currently facing * Returns position based on where player is currently facing
* @param shift How far from player should the point of interest be. * @param shift How far from player should the point of interest be.
*/ */
public getDirectionalActivationPosition(shift: number): { x: number, y: number } { public getDirectionalActivationPosition(shift: number): { x: number; y: number } {
switch (this.lastDirection) { switch (this.lastDirection) {
case PlayerAnimationDirections.Down: { return { x: this.x, y: this.y + shift }; } case PlayerAnimationDirections.Down: {
case PlayerAnimationDirections.Left: { return { x: this.x - shift, y: this.y }; } return { x: this.x, y: this.y + shift };
case PlayerAnimationDirections.Right: { return { x: this.x + shift, y: this.y }; } }
case PlayerAnimationDirections.Up: { return { x: this.x, y: this.y - shift }; } case PlayerAnimationDirections.Left: {
return { x: this.x - shift, y: this.y };
}
case PlayerAnimationDirections.Right: {
return { x: this.x + shift, y: this.y };
}
case PlayerAnimationDirections.Up: {
return { x: this.x, y: this.y - shift };
}
} }
} }

View file

@ -73,7 +73,9 @@ export class ActivatablesManager {
} }
public updateActivatableObjectsDistances(objects: ActivatableInterface[]): void { public updateActivatableObjectsDistances(objects: ActivatableInterface[]): void {
const currentPlayerPos = this.currentPlayer.getDirectionalActivationPosition(this.directionalActivationPositionShift); const currentPlayerPos = this.currentPlayer.getDirectionalActivationPosition(
this.directionalActivationPositionShift
);
for (const object of objects) { for (const object of objects) {
const distance = MathUtils.distanceBetween(currentPlayerPos, object.getPosition()); const distance = MathUtils.distanceBetween(currentPlayerPos, object.getPosition());
this.activatableObjectsDistances.set(object, distance); this.activatableObjectsDistances.set(object, distance);
@ -85,7 +87,7 @@ export class ActivatablesManager {
object, object,
MathUtils.distanceBetween( MathUtils.distanceBetween(
this.currentPlayer.getDirectionalActivationPosition(this.directionalActivationPositionShift), this.currentPlayer.getDirectionalActivationPosition(this.directionalActivationPositionShift),
object.getPosition(), object.getPosition()
) )
); );
} }

View file

@ -8,7 +8,6 @@ export function createColorStore() {
let pointedByPointer: number | undefined = undefined; let pointedByPointer: number | undefined = undefined;
let pointedByCharacter: number | undefined = undefined; let pointedByCharacter: number | undefined = undefined;
const updateColor = () => { const updateColor = () => {
set(pointedByPointer ?? pointedByCharacter ?? followColor ?? apiColor); set(pointedByPointer ?? pointedByCharacter ?? followColor ?? apiColor);
}; };