]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/MovementManager.cs
colosseum is now crowded with monsters; made the SaberMonster moving code more robust...
[chaz/carfire] / CarFire / CarFire / CarFire / MovementManager.cs
index 73caa5775b02eca70e009bff5874bf2946cfad13..7d818681993a47e22b09e4566046992e9072bdd3 100644 (file)
@@ -195,7 +195,7 @@ namespace CarFire
 \r
 \r
         /// <summary>\r
 \r
 \r
         /// <summary>\r
-        /// Helper method to get neighbor cells from a point and directions.\r
+        /// Helper method to get a neighbor cell from a point and directions.\r
         /// </summary>\r
         /// <param name="point">The point.</param>\r
         /// <param name="left">To the left.</param>\r
         /// </summary>\r
         /// <param name="point">The point.</param>\r
         /// <param name="left">To the left.</param>\r
@@ -212,6 +212,28 @@ namespace CarFire
             return point;\r
         }\r
 \r
             return point;\r
         }\r
 \r
+        /// <summary>\r
+        /// Helper method to get a neighbor cell from a point and a direction.\r
+        /// </summary>\r
+        /// <param name="point">The point.</param>\r
+        /// <param name="direction">The direction.</param>\r
+        /// <returns>The neighbor cell coordinates.</returns>\r
+        public static Point GetNeighbor(Point point, Direction direction)\r
+        {\r
+            switch (direction)\r
+            {\r
+                case Direction.Left: return new Point(point.X - 1, point.Y);\r
+                case Direction.UpperLeft: return new Point(point.X - 1, point.Y - 1);\r
+                case Direction.Up: return new Point(point.X, point.Y - 1);\r
+                case Direction.UpperRight: return new Point(point.X + 1, point.Y - 1);\r
+                case Direction.Right: return new Point(point.X + 1, point.Y);\r
+                case Direction.LowerRight: return new Point(point.X + 1, point.Y + 1);\r
+                case Direction.Down: return new Point(point.X, point.Y + 1);\r
+                case Direction.LowerLeft: return new Point(point.X - 1, point.Y + 1);\r
+            }\r
+            return point;\r
+        }\r
+\r
         /// <summary>\r
         /// Helper method to get the two neighbor cells of two nearby cells.\r
         /// </summary>\r
         /// <summary>\r
         /// Helper method to get the two neighbor cells of two nearby cells.\r
         /// </summary>\r
This page took 0.022198 seconds and 4 git commands to generate.