Esempio 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 <= 0.6 || Position.SquareData == 3) // 3 = chair?
                    {
                        double Distance = Position.GetDistance;
                        if (Closest > Distance)
                        {
                            Closest      = Distance;
                            ClosestPoint = Position;
                        }
                    }
                }
            }
            return(ClosestPoint);
        }
Esempio n. 2
0
        internal static SquarePoint GetNextStep(int pUserX, int pUserY,
                                                int pUserTargetX, int pUserTargetY,
                                                byte[,] pGameMap, double[,] pHeight,
                                                int MaxX, int MaxY,
                                                bool pUserOverride, bool pDiagonal)
        {
            ModelInfo   MapInfo     = new ModelInfo(MaxX, MaxY, pGameMap);
            SquarePoint TargetPoint = new SquarePoint(pUserTargetX, pUserTargetY, pUserTargetX, pUserTargetY, MapInfo.GetState(pUserTargetX, pUserTargetY), pUserOverride);

            if (pUserX == pUserTargetX && pUserY == pUserTargetY) //User is allready standing on its target
            {
                return(TargetPoint);
            }

            SquareInformation SquareOnUser = new SquareInformation(pUserX, pUserY, TargetPoint, MapInfo, pUserOverride, pDiagonal);

            //if (!TargetPoint.CanWalk)
            //    return SquareOnUser.Point;

            return(GetClosetSqare(SquareOnUser, new HeightInfo(MaxX, MaxY, pHeight)));
        }
Esempio n. 3
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 <= 0.6 || Position.SquareData == 3) // 3 = chair?
                    {
                        double Distance = Position.GetDistance;
                        if (Closest > Distance)
                        {
                            Closest = Distance;
                            ClosestPoint = Position;
                        }
                    }
                }
            }
            return ClosestPoint;
        }
Esempio n. 4
0
        internal static SquarePoint GetNextStep(int pUserX, int pUserY,
            int pUserTargetX, int pUserTargetY,
            byte[,] pGameMap, double[,] pHeight,
            int MaxX, int MaxY,
            bool pUserOverride, bool pDiagonal)
        {
            ModelInfo MapInfo = new ModelInfo(MaxX, MaxY, pGameMap);
            SquarePoint TargetPoint = new SquarePoint(pUserTargetX, pUserTargetY, pUserTargetX, pUserTargetY, MapInfo.GetState(pUserTargetX, pUserTargetY), pUserOverride);
            if (pUserX == pUserTargetX && pUserY == pUserTargetY) //User is allready standing on its target
                return TargetPoint;

            SquareInformation SquareOnUser = new SquareInformation(pUserX, pUserY, TargetPoint, MapInfo, pUserOverride, pDiagonal);

            //if (!TargetPoint.CanWalk)
            //    return SquareOnUser.Point;

            return GetClosetSqare(SquareOnUser, new HeightInfo(MaxX, MaxY, pHeight));
        }