Example #1
0
        public static MovementPath FindDirectPath(Point a, Point b)
        {
            MovementPath path = new MovementPath(a, b);

            path.BuildDirectPath();
            return(path);
        }
Example #2
0
        public static MovementPath SelectBestPath(List <MovementPath> paths)
        {
            if (paths.Count == 0)
            {
                return(null);
            }
            if (paths.Count == 1)
            {
                return(paths[0]);
            }
            MovementPath best = paths[0];

            foreach (MovementPath current in paths)
            {
                if (current.GetLength() < best.GetLength() && (current.IsComplete() || !best.IsComplete()))
                {
                    best = current;
                }
            }
            return(best);
        }
Example #3
0
 private void SetMovementPath()
 {
     path = MovementPath.FindPath(selected, ConvertPointToGrid(MousePosition));
     Console.WriteLine("1 DONE FINDING PATH");
 }
Example #4
0
        /*protected override void OnMouseMove(MouseEventArgs e)
         * {
         *  base.OnMouseMove(e);
         *  int i = 1000;
         *  while (i-- > 0)
         *  {
         *      // TODO replace this with a Timer or some other alternative to
         *      // thread.Sleep();
         *  }
         *
         *  if (entities.ContainsKey(selected))
         *  {
         *      Entity ent = entities[selected];
         *      if (ent.CanMove())
         *      {
         *          SetMovementPath();
         *          Refresh();
         *          Console.WriteLine("6 done refreshing after mouse move\n");
         *          return;
         *      }
         *  }
         *  path = null;
         * }*/

        private bool CanSee(Point p1, Point p2)
        {
            MovementPath path = MovementPath.FindDirectPath(p1, p2);

            return(path.IsObstructed());
        }