示例#1
0
文件: GameData.cs 项目: wtfcolt/game
        /// <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);
        }
示例#2
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;
        }