Esempio n. 1
0
        public override bool InRectange(FreeUIUtil.Rectangle rec, IEventArgs args)
        {
            if (pos == null || change)
            {
                pos = selector.Select(args);
            }
            int   px = (int)(pos.GetX());
            int   py = (int)(pos.GetY());
            float r  = 0f;

            try
            {
                r = /*float.Parse(radius)*/ ParseUtility.QuickFloatParse(radius);
            }
            catch (Exception)
            {
                r = FreeUtil.ReplaceFloat(radius, args);
            }
            float x1 = rec.x - r;
            float x2 = rec.x + rec.width + r;
            float y1 = rec.y - r;
            float y2 = rec.y + rec.height + r;

            // 圆心在矩形的加上圆半径的范围内
            return(px >= x1 && px <= x2 && py >= y1 && py <= y2);
        }
Esempio n. 2
0
        public override bool IsIn(IEventArgs args, UnitPosition entity)
        {
            if (pos == null || change)
            {
                pos = selector.Select(args);
            }
            float r = 0f;

            try
            {
                r = /*float.Parse(radius)*/ ParseUtility.QuickFloatParse(radius);
            }
            catch (Exception)
            {
                r = FreeUtil.ReplaceFloat(radius, args);
            }

            double dx = MyMath.Abs(entity.GetX() - pos.GetX());

            if (dx > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dz = MyMath.Abs(entity.GetZ() - pos.GetZ());

            if (dz > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dy     = MyMath.Abs(entity.GetY() - pos.GetY());
            float  zrange = FreeUtil.ReplaceFloat(zRange, args);

            if (zrange <= 0)
            {
                zrange = 170;
            }

            bool isIn = (dx * dx + dz * dz) <= r * r && (dy < zrange);

            if (useOut)
            {
                return(!isIn);
            }
            return(isIn);
        }