Beispiel #1
0
        public bool CanReach(Point2D p, int easy)
        {
            if (p.X == X && p.Y == Y)
            {
                return(true);
            }

            WalkpathData wpd    = null;
            bool         result = PathHelper.SearchPath(out wpd, Map, Location.Point, p);

            wpd = null;
            return(result);
        }
Beispiel #2
0
        public static void WalkToXY(WorldObjectUnit obj, Point2D targetLoc)
        {
            // Walking in process?
            if (obj.Walkpath != null || obj.WalkTimer != null)
            {
                // Stop and reset walking
                if (obj.WalkTimer != null)
                {
                    obj.WalkTimer.Stop();
                    obj.WalkTimer = null;
                }
                obj.Walkpath = null;
            }

            obj.TargetLocation = targetLoc;
            if (obj.Location.Point == obj.TargetLocation)
            {
                return;
            }

            // Calc path
            WalkpathData wpd;

            if (PathHelper.SearchPath(out wpd, obj.Map, obj.Location.Point, obj.TargetLocation) == false)
            {
                ServerConsole.ErrorLine("Bad path, cancel moving");
                //obj.Map.DrawGat();
                return;
            }

            obj.Walkpath = wpd;
            // Player needs to notify clients about a successfull move
            //if ((obj is Character)) {
            //	(obj as Character).Account.Netstate.Send(new WorldResponseWalkOK(obj as Character));
            //}

            // Get speed and start timer
            //int speed = CalcWalkspeed(obj);
            //if (speed > 0) {
            //	obj.WalkTimer = Timer.DelayCall(TimeSpan.FromMilliseconds(speed), TimeSpan.Zero, 1, new TimerStateCallback<WorldObjectUnit>(WalkToXY_Tick), obj);
            //}
        }