//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); }
public static List <Tile> Movement(Tile startingTile, int range, List <Tile> enemyLocation) { List <TilePath> closed = new List <TilePath>(); List <TilePath> open = new List <TilePath>(); TilePath originTilePath = new TilePath(); originTilePath.addFirstTile(startingTile); open.Add(originTilePath); Highlight.OpenMovementTiles(open, closed, enemyLocation, range); closed.Remove(originTilePath); return(closed.Select(x => x.lastTile).ToList()); }
public static List <Tile> FindPath(Tile startingTile, Tile endingTile, List <Tile> enemyLocation) { List <TilePath> closed = new List <TilePath>(); List <TilePath> open = new List <TilePath>(); TilePath originPath = new TilePath(); originPath.addFirstTile(startingTile); open.Add(originPath); while (open.Count > 0) { TilePath current = open[0]; open.Remove(open[0]); if (closed.Select(x => x.lastTile).ToList().Contains(current.lastTile)) { if (current.pathCost >= closed.Where(x => x.lastTile == current.lastTile).First().pathCost) { continue; } else { closed.Remove(closed.Where(x => x.lastTile == current.lastTile).First()); } } if (current.lastTile == endingTile) { //current.listOfTiles.Remove (startingTile); return(current.listOfTiles); } closed.Add(current); Highlight.AllExpand(current, enemyLocation, open); } return(null); }