private void timer1_Tick(object sender, EventArgs e)
{
aStar = new AStar(tileMap);
List<Tile> path = aStar.FindPath();
int index = r.Next(path.Count);
if (path.Count > 0)
{
while (path[index].TileType == TileType.Goal || path[index].TileType == TileType.Start ||
index == path.Count - 2 || index == 1)
{
index = r.Next(path.Count);
}
blocked.Add(path[index]);
panel33_MouseDown(path[index].Panel, null);
ExecuteAStar();
}
else
{
int count = 0;
int index2;
int minRemove = blocked.Count / 3;
while (path.Count == 0 || count < minRemove)
{
index2 = r.Next(blocked.Count);
panel33_MouseDown(blocked[index2].Panel, null);
blocked.RemoveAt(index2);
ExecuteAStar();
aStar = new AStar(tileMap);
path = aStar.FindPath();
count++;
}
}
}