public facing ( IInteractable other ) : bool | ||
other | IInteractable | The other Interactable |
Résultat | bool |
public bool facing(IInteractable other)
{
Rectangle rect = other.getBoundingRect();
return ((this.getDirection().Equals(Direction.North) && this.getY() > rect.Y) ||
(this.getDirection().Equals(Direction.South) && this.getY() < rect.Y) ||
(this.getDirection().Equals(Direction.East) && this.getX() < rect.X) ||
(this.getDirection().Equals(Direction.West) && this.getX() > rect.X));
}
/// <summary> /// Checks if two Characters are facing each other /// </summary> /// <param name="other">The other Character</param> /// <returns>True if both characters are facing each other, false if not</returns> public bool bothFacing(Character other) { return this.facing(other) && other.facing(this); }