Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. // your tile class that inherits a PathNode
  2. public class MyTile : PathNode
  3. {
  4.     public MyTile()
  5.     {
  6.         // passible by default
  7.         IsPassible = true;
  8.     }
  9. }
  10.  
  11. // creating a grid with size "width" and "height"
  12. TileGrid<MyTile> grid = new TileGrid<MyTile>(width, height);
  13.  
  14. // make (0, 1) impassible
  15. grid[0][1].IsPassible = false;
  16.  
  17. // starting point
  18. Point start = new Point(0, 0);
  19.  
  20. // destination point
  21. Point end = new Point(5, 5);
  22.  
  23. // points along the shortest path. The last flag is whether or not to allow diagonal movement.
  24. List<Point> path = grid.FindPath(start, end, true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement