public static void OpenAttackTiles(List <TilePath> open, List <Tile> closed, int range) { while (open.Count > 0) { TilePath current = open[0]; open.RemoveAt(0); if (closed.Contains(current.lastTile)) { continue; } if (current.pathCost > range) { continue; } closed.Add(current.lastTile); List <Tile> xq = current.lastTile.neighbours.Where(x => x != null).ToList(); for (int i = 0; i < xq.Count; i++) { TilePath newTilePath = new TilePath(current); newTilePath.addNStaticTile(xq[i], 1); open.Add(newTilePath); } } }
//hightlight attack public static List <Tile> Attack(Tile startingTile, int attackDistance, int nonAttackDistance) { if (nonAttackDistance >= attackDistance) { return(new List <Tile>()); } List <Tile> closed = new List <Tile>(); List <Tile> closed2 = new List <Tile>(); List <TilePath> open = new List <TilePath>(); List <TilePath> open2 = new List <TilePath>(); TilePath originTilePath = new TilePath(); originTilePath.addFirstTile(startingTile); open.Add(originTilePath); open2.Add(originTilePath); /*Highlight.OpenAttackTiles (open, closed, attackDistance, nonAttackDistance); * Highlight.OpenAttackTiles (open2, closed2, nonAttackDistance); * //with first tile */ while (open.Count > 0) { TilePath current = open[0]; open.RemoveAt(0); if (closed.Contains(current.lastTile)) { continue; } if (current.pathCost > attackDistance) { continue; } closed.Add(current.lastTile); if (current.pathCost <= nonAttackDistance) { closed2.Add(current.lastTile); } List <Tile> xq = current.lastTile.neighbours.Where(x => x != null).ToList(); for (int i = 0; i < xq.Count; i++) { TilePath newTilePath = new TilePath(current); newTilePath.addNStaticTile(xq[i], 1); open.Add(newTilePath); if (current.pathCost <= nonAttackDistance) { open2.Add(newTilePath); } } } foreach (Tile t in closed2) { if (closed.Contains(t)) { closed.Remove(t); } } return(closed); }