GetDistance() public static method

public static GetDistance ( System.Point p1, System.Point p2 ) : int
p1 System.Point
p2 System.Point
return int
Exemplo n.º 1
0
        protected int GetObjActToObjActDist(int a, int b)
        {
            Actor acta = null;
            Actor actb = null;

            if (IsActor(a))
            {
                acta = Actors[ObjToActor(a)];
            }

            if (IsActor(b))
            {
                actb = Actors[ObjToActor(b)];
            }

            if ((acta != null) && (actb != null) && (acta.Room == actb.Room) && (acta.Room != 0) && !acta.IsInCurrentRoom)
            {
                return(0);
            }

            Point pA;

            if (!GetObjectOrActorXY(a, out pA))
            {
                return(0xFF);
            }

            Point pB;

            if (!GetObjectOrActorXY(b, out pB))
            {
                return(0xFF);
            }

            // Perform adjustXYToBeInBox() *only* if the first item is an
            // actor and the second is an object. This used to not check
            // whether the second item is a non-actor, which caused bug
            // #853874).
            if (acta != null && actb == null)
            {
                var r = acta.AdjustXYToBeInBox(pB);
                pB = r.Position;
            }

            // Now compute the distance between the two points
            return(ScummMath.GetDistance(pA, pB));
        }
Exemplo n.º 2
0
        int GetDistanceBetween(bool isObj1, int b, int c, bool isObj2, int e, int f)
        {
            int   i, j;
            Point pos1;
            Point pos2;

            j = i = 0xFF;

            if (isObj1)
            {
                if (!GetObjectOrActorXY(b, out pos1))
                {
                    return(-1);
                }
                if (b < Actors.Length)
                {
                    i = Actors[b].ScaleX;
                }
            }
            else
            {
                pos1 = new Point(b, c);
            }

            if (isObj2)
            {
                if (!GetObjectOrActorXY(e, out pos2))
                {
                    return(-1);
                }
                if (e < Actors.Length)
                {
                    j = Actors[e].ScaleX;
                }
            }
            else
            {
                pos2 = new Point(e, f);
            }

            return(ScummMath.GetDistance(pos1, pos2) * 0xFF / ((i + j) / 2));
        }