*/\r
}\r
\r
+ public AI AIData { get { return mAIData; } }\r
+\r
public long CurrentFrameNumber\r
{\r
get { return State.FrameNumber; }\r
{\r
State.AdvanceFrame(mInputs, elapsedTime.Milliseconds); // Apply the inputs, advance game state.\r
State.mDisplay.Update(elapsedTime, mThisPlayerID);\r
+ /*\r
State.Entities.ForEach(delegate(IEntity e) \r
{\r
IMonster m = e as IMonster;\r
}\r
e.Update(elapsedTime); \r
});\r
- //State.Entities.ForEach(delegate(IEntity e) { e.Update(elapsedTime); });\r
+ */\r
+ State.Entities.ForEach(delegate(IEntity e) { e.Update(elapsedTime); });\r
mInputs = new NextInputs(State.NumberOfPlayers); // Start with inputs cleared on the next frame.\r
//mDisplay.Update(elapsedTime);\r
return State.FrameNumber;\r
{\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
/// <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
\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