X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FPathFinder.cs;fp=CarFire%2FCarFire%2FCarFire%2FPathFinder.cs;h=53e148d1f2cc713b29940cd2613df0ac5462bcfb;hp=91724384ab2ac4cccca98b2c830b66c0bff2c1e7;hb=af9deb873b24dadd0d509ce199fc6cac2b3efbc9;hpb=681f16a95c1c67bdd40ed16842a70f8e10ba31e1 diff --git a/CarFire/CarFire/CarFire/PathFinder.cs b/CarFire/CarFire/CarFire/PathFinder.cs index 9172438..53e148d 100644 --- a/CarFire/CarFire/CarFire/PathFinder.cs +++ b/CarFire/CarFire/CarFire/PathFinder.cs @@ -1,4 +1,8 @@ -using System; + +// Uncomment this to disable diagonal movemet. +//#define ALLOW_DIAGONAL_MOVEMENT + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -136,14 +140,16 @@ namespace CarFire } List neighbors = new List(8); + neighbors.Add(new Point(cell.Point.X, cell.Point.Y - 1)); + neighbors.Add(new Point(cell.Point.X - 1, cell.Point.Y)); + neighbors.Add(new Point(cell.Point.X + 1, cell.Point.Y)); + neighbors.Add(new Point(cell.Point.X, cell.Point.Y + 1)); +#if ALLOW_DIAGONAL_MOVEMENT neighbors.Add(new Point(cell.Point.X - 1, cell.Point.Y - 1)); - neighbors.Add(new Point(cell.Point.X + 0, cell.Point.Y - 1)); neighbors.Add(new Point(cell.Point.X + 1, cell.Point.Y - 1)); - neighbors.Add(new Point(cell.Point.X - 1, cell.Point.Y + 0)); - neighbors.Add(new Point(cell.Point.X + 1, cell.Point.Y + 0)); neighbors.Add(new Point(cell.Point.X - 1, cell.Point.Y + 1)); - neighbors.Add(new Point(cell.Point.X + 0, cell.Point.Y + 1)); neighbors.Add(new Point(cell.Point.X + 1, cell.Point.Y + 1)); +#endif foreach (Point point in neighbors) { Cell inQueue = mCells[point.X, point.Y];