public void SetAsDestination() { cost = 0; bestCost = 0; bestDirection = GridDirection.None; }
public void ResetCell() { cost = 1; bestCost = ushort.MaxValue; bestDirection = GridDirection.None; }
public Cell(bool _walkable, Vector3 _worldPos, Vector2Int _gridIndex) { worldPos = _worldPos; gridIndex = _gridIndex; cost = 1; bestCost = ushort.MaxValue; bestDirection = GridDirection.None; }
public void CreateFlowField() { foreach (Cell curCell in grid) { curCell.bestDirection = GridDirection.None; List <Cell> curNeighbors = GetNeighborCells(curCell.gridIndex, GridDirection.AllDirections); int bestCost = curCell.bestCost; foreach (Cell curNeighbor in curNeighbors) { if (curNeighbor.bestCost < bestCost) { bestCost = curNeighbor.bestCost; curCell.bestDirection = GridDirection.GetDirectionFromV2I(curNeighbor.gridIndex - curCell.gridIndex); } } } }