Пример #1
0
        /// <summary>
        /// This method is always performed first when acquiring a target with arguments.
        /// </summary>
        /// <param name="targeter">The Character object doing the targetting.</param>
        /// <param name="args">The full arguments for target acquisition.</param>
        /// <returns>Character object target or null.</returns>
        public static Character AcquireTarget(Character targeter, string args, int maxDistance, int minDistance)
        {
            string[] sArgs   = args.Split(" ".ToCharArray());
            int      countTo = 0;

            Character target = null;

            // acquiring target in targeter's current cell
            if (maxDistance == 0 && minDistance == 0)
            {
                if (Int32.TryParse(sArgs[0], out countTo))
                {
                    if (sArgs.Length >= 2)
                    {
                        target = TargetAquisition.FindTargetInCell(targeter, sArgs[1], countTo);
                    }
                    else
                    {
                        target = TargetAquisition.FindTargetInCell(targeter, sArgs[0]);
                    }
                }
                else
                {
                    target = TargetAquisition.FindTargetInCell(targeter, sArgs[0]);
                }
            }

            if (target == null)
            {
                if (sArgs.Length >= 2 && Int32.TryParse(sArgs[0], out countTo))
                {
                    target = TargetAquisition.FindTargetInView(targeter, sArgs[1], countTo);
                }
                else
                {
                    target = TargetAquisition.FindTargetInView(targeter, sArgs[0], false, true);
                }
            }

            if (target == null || Cell.GetCellDistance(targeter.X, targeter.Y, target.X, target.Y) > maxDistance)
            {
                return(null);
            }

            return(target);
        }
Пример #2
0
        public static Character AcquireTarget(Character targeter, string[] sArgs, int maxDistance, int minDistance)
        {
            int countTo = 0;

            Character target = null;

            // acquiring target in targeter's current cell
            if (maxDistance == 0)
            {
                if (Int32.TryParse(sArgs[0], out countTo))
                {
                    if (sArgs.Length >= 2) // # target
                    {
                        target = FindTargetInCell(targeter, sArgs[1], countTo);
                    }
                    else
                    {
                        target = FindTargetInCell(targeter, sArgs[0]);  // target is unique ID
                    }
                }
                else
                {
                    target = FindTargetInCell(targeter, sArgs[0]);
                }
            }

            if (sArgs.Length >= 2 && Int32.TryParse(sArgs[0], out countTo)) // <command> # <target>
            {
                target = FindTargetInView(targeter, sArgs[1], countTo);
            }
            else
            {
                target = FindTargetInView(targeter, sArgs[0], false, true);
            }

            if (target == null || Cell.GetCellDistance(targeter.X, targeter.Y, target.X, target.Y) > maxDistance)
            {
                return(null);
            }

            return(target);
        }