示例#1
0
        /// <summary>
        /// Checks if the current position is within the specified boundaries
        /// </summary>
        /// <param name="bounds">Bounds to check if they contain the current position</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="UnknownEnumValueException"/>
        public bool InsideBounds(Bounds2D bounds)
        {
            bounds.ThrowIfNull(nameof(bounds));

            return
                (X.Between(bounds.X.Min, bounds.X.Max) &&
                 Y.Between(bounds.Y.Min, bounds.Y.Max));
        }
示例#2
0
        /// <summary>
        /// Checks if a position relative to the current one is within the specified boundaries
        /// </summary>
        /// <param name="bounds">Bounds to check if they contain the relative position</param>
        /// <param name="direction">Direction in which the movement should occurr</param>
        /// <param name="amount">How many tiles should the movement cover</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="UnknownEnumValueException"/>
        public bool InsideBoundsAfterMovement(Bounds2D bounds, Direction direction, int amount)
        {
            bounds.ThrowIfNull(nameof(bounds));

            return(GetRelativePosition(direction, amount).InsideBounds(bounds));
        }