X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FMovementManager.cs;fp=CarFire%2FCarFire%2FCarFire%2FMovementManager.cs;h=73caa5775b02eca70e009bff5874bf2946cfad13;hp=3511e4202d1af2e711f2485a81088ee781cfd7f2;hb=198cb6056e93fecd69e65351ca8d0b34a077523f;hpb=08f41ef45f3c41ca6302150bc6d5270c8e7143db diff --git a/CarFire/CarFire/CarFire/MovementManager.cs b/CarFire/CarFire/CarFire/MovementManager.cs index 3511e42..73caa57 100644 --- a/CarFire/CarFire/CarFire/MovementManager.cs +++ b/CarFire/CarFire/CarFire/MovementManager.cs @@ -203,7 +203,7 @@ namespace CarFire /// Above. /// Below. /// The neighbor cell coordinates. - public static Point GetNeighborCell(Point point, bool left, bool right, bool up, bool down) + public static Point GetNeighbor(Point point, bool left, bool right, bool up, bool down) { if (left) point.X--; if (right) point.X++; @@ -212,6 +212,21 @@ namespace CarFire return point; } + /// + /// Helper method to get the two neighbor cells of two nearby cells. + /// + /// A point. + /// Another point. + /// An array of two points representing the neighbor cells. + public static Point[] GetNeighbors(Point a, Point b) + { + Point[] neighbors = new Point[2]; + neighbors[0] = new Point(a.X, b.Y); + neighbors[1] = new Point(b.X, a.Y); + return neighbors; + } + + /// /// Helper method to get a Direction type from directions. /// @@ -282,7 +297,7 @@ namespace CarFire void UpdateCoordinates(bool moveLeft, bool moveRight, bool moveUp, bool moveDown) { mLastCoordinates = mCoordinates; - mCoordinates = GetNeighborCell(mCoordinates, moveLeft, moveRight, moveUp, moveDown); + mCoordinates = GetNeighbor(mCoordinates, moveLeft, moveRight, moveUp, moveDown); if ((moveLeft && moveUp) || (moveUp && moveRight) || (moveRight && moveDown) || (moveDown && moveLeft)) {