]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/SaberMonster2.cs
Changed where AI is stored, adjusted to work with Multiplayer
[chaz/carfire] / CarFire / CarFire / CarFire / SaberMonster2.cs
index f522ab447763fc5faafd12d99f4024076c697127..33f94d7a309efeab505538d1da64abc1d72b64e2 100644 (file)
@@ -42,7 +42,7 @@ namespace CarFire
         {\r
             mId = identifier;\r
             mMotion = new MovementManager(position);\r
-\r
+            \r
             // We need to keep the game reference in order to get the grid when we\r
             // need to find paths.\r
             mGame = game;\r
@@ -213,6 +213,29 @@ namespace CarFire
         /// <param name="timeSpan"></param>\r
         public void Update(TimeSpan timeSpan)\r
         {\r
+            int closestChar = 0;\r
+            int closestCharDist = 1000;\r
+            for (int c = 0; c < mGame.State.mCharacters.Length; c++)\r
+            {\r
+                if (mGame.State.mCharacters[c] != null && mGame.AIData.spaceVisible(Coordinates, mGame.State.mCharacters[c].Coordinates))\r
+                {\r
+                    if (PathFinder.GetManhattanDistance(Coordinates, mGame.State.mCharacters[c].Coordinates) < closestCharDist)\r
+                    {\r
+                        closestCharDist = PathFinder.GetManhattanDistance(Coordinates, mGame.State.mCharacters[c].Coordinates);\r
+                        closestChar = c;\r
+                    }\r
+                }\r
+            }\r
+\r
+            if (mGame.State.mCharacters[closestChar] != null && mGame.AIData.spaceVisible(Coordinates, mGame.State.mCharacters[closestChar].Coordinates))\r
+            {\r
+                Chasing(mGame.State.mCharacters[0].Coordinates);\r
+            }\r
+            else\r
+            {\r
+                DefaultAction();\r
+            }\r
+        \r
             switch (mState)\r
             {\r
                 case AiState.Pacing:\r
@@ -286,7 +309,7 @@ namespace CarFire
 \r
         char mId;\r
         MovementManager mMotion;\r
-\r
+        AI mAI;\r
         PathFinder pathFinder;\r
         List<Point> mIdlePath = new List<Point>();      // List of waypoints that we got from the map.\r
         int mIdlePathIndex;                             // Index to the waypoint we're heading for.\r
This page took 0.02124 seconds and 4 git commands to generate.