public virtual bool IsOver(GameObjectViewModel other) { var min = this.Left; var max = this.Left + this.Width; var left1 = other.Left; var left2 = other.Left + other.Width; bool isOverHorizontally = (min <= left1 && left1 <= max) || (min <= left2 && left2 <= max); if (!isOverHorizontally) { return false; } min = this.Top; max = this.Top + this.Width; var top1 = other.Top; var top2 = other.Top + other.Width; bool isOverVertically = (min <= top1 && top1 <= max) || (min <= top2 && top2 <= max); return isOverVertically; }
public virtual bool IsOver(GameObjectViewModel other) { var min = this.Left; var max = this.Left + this.Width; var left1 = other.Left; var left2 = other.Left + other.Width; bool isOverHorizontally = (min <= left1 && left1 <= max) || (min <= left2 && left2 <= max); if (!isOverHorizontally) { return(false); } min = this.Top; max = this.Top + this.Width; var top1 = other.Top; var top2 = other.Top + other.Width; bool isOverVertically = (min <= top1 && top1 <= max) || (min <= top2 && top2 <= max); return(isOverVertically); }