Esempio n. 1
0
        /// <summary>
        /// Checks whether this location is inside a pre-defined area.
        /// </summary>
        /// <param name="areaEffect">The area effect used.</param>
        /// <param name="location">The center of the area.</param>
        /// <param name="direction">The direction of the area effect used.</param>
        /// <returns></returns>
        public bool IsInAreaEffect(Objects.AreaEffect areaEffect, Objects.Location location,
            Enums.Direction direction)
        {
            ushort y = 0;
            Objects.Location currentLoc = this.Clone();
            byte dir = areaEffect.Type == AreaEffect.EffectType.Spell ? (byte)direction : (byte)1;

            foreach (byte[] row in areaEffect.GetArea())
            {
                int center = row.Length / 2;
                for (int i = 0; i < row.Length; i++)
                {
                    if (row[i] != dir) continue;
                    if (location.Offset(i - center, y, 0) == currentLoc) return true;
                }
                y++;
            }
            return false;
        }