public static List <Tile> FindHighlight(Tile originTile, int movementPoints, Vector2[] occupied, bool staticRange) { List <Tile> closed = new List <Tile>(); List <TilePath> open = new List <TilePath>(); TilePath originPath = new TilePath(); if (staticRange) { originPath.addStaticTile(originTile); } else { originPath.addTile(originTile); } open.Add(originPath); while (open.Count > 0) { TilePath current = open[0]; open.Remove(open[0]); if (closed.Contains(current.lastTile)) { continue; } if (current.costOfPath > movementPoints + 1) { continue; } closed.Add(current.lastTile); foreach (Tile t in current.lastTile.neighbors) { if (t.impassible || occupied.Contains(t.gridPosition)) { continue; } TilePath newTilePath = new TilePath(current); if (staticRange) { newTilePath.addStaticTile(t); } else { newTilePath.addTile(t); } open.Add(newTilePath); } } closed.Remove(originTile); closed.Distinct(); return(closed); }
public static List<Tile> FindHighlight(Tile originTile, int movementPoints, Vector2[] occupied, bool staticRange, bool dontremoveorigin) { List<Tile> closed = new List<Tile>(); List<TilePath> open = new List<TilePath>(); TilePath originPath = new TilePath(); if (staticRange) originPath.addStaticTile(originTile); else originPath.addTile(originTile); open.Add(originPath); while (open.Count > 0) { TilePath current = open[0]; open.Remove(open[0]); if (closed.Contains(current.lastTile)) { continue; } if (current.costOfPath > movementPoints + 1.5f) { continue; } closed.Add(current.lastTile); foreach (Tile t in current.lastTile.neighbors) { if (t.impassible || occupied.Contains(t.gridPosition)|| (GameManager.instance.GetComponent<GameManager>(). playerTurns[GameManager.instance.GetComponent<GameManager>().PlayerTurnIndex].GetPhalanx()==true&&t.frontLiners<16)) continue; TilePath newTilePath = new TilePath(current); if (staticRange) newTilePath.addStaticTile(t); else newTilePath.addTile(t); open.Add(newTilePath); } } closed.Remove(originTile); closed.Distinct(); if (dontremoveorigin && !occupied.Contains(originTile.gridPosition)) closed.Add(originTile); return closed; }
public static List <Tile> FindHighlight(Tile originTile, int movementPoints, Vector2[] occupied, bool staticRange) { List <Tile> closed = new List <Tile>(); List <TilePath> open = new List <TilePath>(); TilePath originPath = new TilePath(); if (staticRange) { originPath.addStaticTile(originTile); } else { originPath.addTile(originTile); } open.Add(originPath); while (open.Count > 0) { TilePath current = open[0]; open.Remove(open[0]); if (closed.Contains(current.lastTile)) { continue; } if (current.costOfPath > movementPoints + 1) { continue; } closed.Add(current.lastTile); foreach (Tile t in current.lastTile.neighbors) { if ( //t.impassable || occupied.Contains(t.gridPosition)) { continue; } TilePath newTilePath = new TilePath(current); if (staticRange) { newTilePath.addStaticTile(t); } else { newTilePath.addTile(t); } open.Add(newTilePath); } } closed.Remove(originTile); // closed.Remove(alliedUnitTiles), which is something we'll have to define and add to the method that determines that stuff, // just like it determines that we can't move past occupied tiles // we'll have to hope this doesn't obliterate pathing. // if it does i'm not sure what to do yet closed.Distinct(); return(closed); }