public static void FindPath() { if (!Settings.AIMode) { return; } var exitPoint = Program.currentMap.GetPointOfTile("Exit"); if (exitPoint == null) { Messaging.WriteEndGameMessage("На карте отсутствует точка выхода(Q)."); return; } var path = (new Path(Program.currentMap.mapTiles, new Point(X, Y), exitPoint)).BuildPossiblePath(); if (path == null) { return; } CurrentPathPoints.Clear(); foreach (var e in path) { CurrentPathPoints.Push(e); } }
public static void MoveAI() { if (IsMoving || GameOver) { return; } if (CurrentPathPoints.Count == 0) { FindPath(); } Direction direction = GetDirection(CurrentPathPoints.Pop()); Move(direction); if (direction != Direction.None) { PathWalked.Append(direction.ToString()[0]); } }