Exemple #1
0
        public bool IsCorrectTarget(RPGObject source, RPGObject target, Point targetLocation)
        {
            if (source == null || target == null)
            {
                return(false);
            }

            bool    result = false;
            RPGCalc calc   = new RPGCalc();

            switch (range)
            {
            case (EffectRange.Self):
            {
                result = (source == target);
                break;
            }

            case (EffectRange.Target):
            {
                // target is roughly at location
                result = calc.ObjectOnPoint(target, targetLocation);
                break;
            }

            case (EffectRange.Touch):
            {
                // target within touch distance
                int d = calc.DistanceBetween(source, target);
                result = (d <= RPGCalc.DEFAULT_TOUCH_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                // target within item distance
                int d = calc.DistanceBetween(source, target);
                result = (d <= this.distance);
                break;
            }

            case (EffectRange.TargetArea):
            {
                // target within item distance and radius
                int d = calc.DistanceBetween(target, targetLocation);
                result = (d <= this.radius);
                break;
            }

            default:
            {
                break;
            }
            } // end switch
            return(result);
        }
Exemple #2
0
        public RPGObject GetObjectAt(Point point)
        {
            RPGCalc calc = new RPGCalc();

            foreach (RPGObject obj in RPGObjects)
            {
                if (obj != null &&
                    calc.ObjectOnPoint(obj, point))
                {
                    return(obj);
                }
            }

            // if nothing found...
            return(null);
        }