Beispiel #1
0
 /// <summary>
 /// Gets the first <see cref="IUsableEntity"/> that intersects a specified area.
 /// </summary>
 /// <param name="c">The <see cref="ISpatialCollection"/>.</param>
 /// <param name="rect"><see cref="Rectangle"/> of the area to check.</param>
 /// <param name="charEntity"><see cref="CharacterEntity"/> that must be able to use the
 /// <see cref="IUsableEntity"/>.</param>
 /// <returns>First <see cref="IUsableEntity"/> that intersects the specified area that the
 /// <paramref name="charEntity"/> is able to use, or null if none.</returns>
 public static IUsableEntity GetUsable(this ISpatialCollection c, Rectangle rect, CharacterEntity charEntity)
 {
     return c.Get<IUsableEntity>(rect, x => x.CanUse(charEntity));
 }
Beispiel #2
0
 /// <summary>
 /// Picks up this <see cref="Entity"/>.
 /// </summary>
 /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to pick up this <see cref="Entity"/>.</param>
 /// <returns>True if this <see cref="Entity"/> was successfully picked up, else false.</returns>
 public abstract bool Pickup(CharacterEntity charEntity);
Beispiel #3
0
        /// <summary>
        /// Gets a <see cref="Rectangle"/> containing the hit area for a melee attack.
        /// </summary>
        /// <param name="c">The <see cref="CharacterEntity"/> that is attacking.</param>
        /// <param name="range">The range of the attack.</param>
        /// <returns>The <see cref="Rectangle"/> that describes the hit area for a melee attack.</returns>
        public static Rectangle GetMeleeAttackArea(CharacterEntity c, ushort range)
        {
            // Start with the rect for the char's area
            var ret = c.ToRectangle();

            // Add the range to the width
            ret.Width += range;

            // If looking left, subtract the range from the X position so that the area is to the left, not right
            if (c.Heading == Direction.West || c.Heading == Direction.SouthWest || c.Heading == Direction.NorthWest)
                ret.X -= range;

            return ret;
        }
Beispiel #4
0
 /// <summary>
 /// Picks up this <see cref="Entity"/>.
 /// </summary>
 /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to pick up this <see cref="Entity"/>.</param>
 /// <returns>True if this <see cref="Entity"/> was successfully picked up, else false.</returns>
 public abstract bool Pickup(CharacterEntity charEntity);