X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FSaberMonster2.cs;h=33f94d7a309efeab505538d1da64abc1d72b64e2;hp=f522ab447763fc5faafd12d99f4024076c697127;hb=7431a91b0db64e69e994a2bfced6516b2891086e;hpb=3c616e65a6ecf3ebe7b494c9e22c96bc53a1a36f
diff --git a/CarFire/CarFire/CarFire/SaberMonster2.cs b/CarFire/CarFire/CarFire/SaberMonster2.cs
index f522ab4..33f94d7 100644
--- a/CarFire/CarFire/CarFire/SaberMonster2.cs
+++ b/CarFire/CarFire/CarFire/SaberMonster2.cs
@@ -42,7 +42,7 @@ namespace CarFire
{
mId = identifier;
mMotion = new MovementManager(position);
-
+
// We need to keep the game reference in order to get the grid when we
// need to find paths.
mGame = game;
@@ -213,6 +213,29 @@ namespace CarFire
///
public void Update(TimeSpan timeSpan)
{
+ int closestChar = 0;
+ int closestCharDist = 1000;
+ for (int c = 0; c < mGame.State.mCharacters.Length; c++)
+ {
+ if (mGame.State.mCharacters[c] != null && mGame.AIData.spaceVisible(Coordinates, mGame.State.mCharacters[c].Coordinates))
+ {
+ if (PathFinder.GetManhattanDistance(Coordinates, mGame.State.mCharacters[c].Coordinates) < closestCharDist)
+ {
+ closestCharDist = PathFinder.GetManhattanDistance(Coordinates, mGame.State.mCharacters[c].Coordinates);
+ closestChar = c;
+ }
+ }
+ }
+
+ if (mGame.State.mCharacters[closestChar] != null && mGame.AIData.spaceVisible(Coordinates, mGame.State.mCharacters[closestChar].Coordinates))
+ {
+ Chasing(mGame.State.mCharacters[0].Coordinates);
+ }
+ else
+ {
+ DefaultAction();
+ }
+
switch (mState)
{
case AiState.Pacing:
@@ -286,7 +309,7 @@ namespace CarFire
char mId;
MovementManager mMotion;
-
+ AI mAI;
PathFinder pathFinder;
List mIdlePath = new List(); // List of waypoints that we got from the map.
int mIdlePathIndex; // Index to the waypoint we're heading for.