Exemplo n.º 1
0
        /// <summary>
        /// Returns attackable monsters in the given radius around position.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public List <ICombatEntity> GetAttackableEntitiesInRectangle(ICombatEntity attacker, Position attackerPos, Position targetPos, int rectWidth)
        {
            var result = new List <ICombatEntity>();

            var rectPoints = GetRectangle(attackerPos, targetPos, rectWidth);

            // Debugging
            //foreach (var point in rectPoints)
            //{
            //	var monster = new Monster(10005, NpcType.Friendly);
            //	monster.Position = new Position(point.X, attackerPos.Y, point.Z);
            //	monster.DisappearTime = DateTime.Now.AddSeconds(5);
            //	attacker.Map.AddMonster(monster);
            //}

            lock (_combatEntities)
            {
                var entities = _combatEntities.Values.Where(a => attacker.CanAttack(a) && a.Position.InPolygon2D(rectPoints));
                result.AddRange(entities);
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns attackable monsters in the given radius around position.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public List <ICombatEntity> GetAttackableEntitiesInRange(ICombatEntity attacker, Position position, int radius)
        {
            var result = new List <ICombatEntity>();

            lock (_combatEntities)
            {
                var entities = _combatEntities.Values.Where(a => a.Position.InRange2D(position, radius) && attacker.CanAttack(a));
                result.AddRange(entities);
            }

            return(result);
        }