Ejemplo n.º 1
0
        private static SquarePoint GetClosetSqare(SquareInformation pInfo, HeightInfo Height)
        {
            double Closest = pInfo.Point.GetDistance; //Initialized

            SquarePoint ClosestPoint = pInfo.Point;
            double InfoOnSqare = Height.GetState(pInfo.Point.X, pInfo.Point.Y);

            for (int i = 0; i < 8; i++)
            {
                SquarePoint Position = pInfo.Pos(i);
                if (!Position.InUse)
                    continue;

                if (Position.CanWalk)
                {
                    if (Height.GetState(Position.X, Position.Y) - InfoOnSqare < 3) //<3
                    {
                        double Distance = Position.GetDistance;
                        if (Closest > Distance)
                        {
                            Closest = Distance;
                            ClosestPoint = Position;
                        }
                    }
                }
            }
            return ClosestPoint;
        }