예제 #1
0
        /// <summary>
        /// Calculates the distance from another Entity.
        /// </summary>
        /// <param name="e">The other Entity.</param>
        /// <param name="useHitboxes">If hitboxes should be used to determine the distance. If not, the Entities' x/y positions are used.</param>
        /// <returns>The distance.</returns>
        public float DistanceFrom(Entity e, bool useHitboxes = false)
        {
            if (!useHitboxes)
            {
                return((float)Math.Sqrt((X - e.X) * (X - e.X) + (Y - e.Y) * (Y - e.Y)));
            }

            return(FP.DistanceRects(X - OriginX, Y - OriginY, Width, Height, e.X - e.OriginX, e.Y - e.OriginY, e.Width, e.Height));
        }
예제 #2
0
 /// <summary>
 /// Calculates the distance from this Entity to the rectangle.
 /// </summary>
 /// <param name="rx">X position of the rectangle.</param>
 /// <param name="ry">Y position of the rectangle.</param>
 /// <param name="rwidth">Width of the rectangle.</param>
 /// <param name="rheight">Height of the rectangle.</param>
 /// <returns>The distance.</returns>
 public float DistanceToRect(float rx, float ry, float rwidth, float rheight)
 {
     return(FP.DistanceRects(rx, ry, rwidth, rheight, X - OriginX, Y - OriginY, Width, Height));
 }