SunsetHigh.Character.facing C# (CSharp) Метод

facing() публичный Метод

Checks if this Character is facing another Interactable (e.g. other Character); used as a check for talking action
public facing ( IInteractable other ) : bool
other IInteractable The other Interactable
Результат 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));
        }

Usage Example

Пример #1
0
 /// <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);
 }