public static HashSet <GridCell> GetMoveRange(GridCell location, int mp)
    {
        GetGridCells();
        //Reset tile values.
        foreach (GridCell c in cells.Values)
        {
            c.parent   = null;
            c.distance = int.MaxValue;
        }

        //Create lists.
        HashSet <GridCell> reachable = new HashSet <GridCell> ();
        Queue <GridCell>   toCheck   = new Queue <GridCell> ();

        //Begin queue.
        GridCell start = location;

        start.distance = 0;
        toCheck.Enqueue(start);

        //Begin while loop.
        while (toCheck.Count > 0)
        {
            //Check for neighbours.
            GridCell current = toCheck.Dequeue();

            //Check X axis.
            for (int x = -1; x <= 1; x++)
            {
                GridPos check = new GridPos(current.gridPos.x - x, current.gridPos.y);
                if (cells.ContainsKey(check) && check != current.gridPos)
                {
                    GridCell next = cells [check];

                    //Check cell content.
                    if (next.CanMoveThrough())
                    {
                        //Check if already in queue.
                        if (!toCheck.Contains(next) && next.distance == int.MaxValue)
                        {
                            next.distance = current.distance + 1;
                            next.parent   = current;
                            toCheck.Enqueue(next);

                            //Check if in mp range.
                            if (next.distance <= mp && !reachable.Contains(next))
                            {
                                reachable.Add(next);
                            }
                        }
                    }
                }
            }

            //Check Y axis.
            for (int y = -1; y <= 1; y++)
            {
                GridPos check = new GridPos(current.gridPos.x, current.gridPos.y - y);
                if (cells.ContainsKey(check) && check != current.gridPos)
                {
                    GridCell next = cells [check];

                    //Check cell content.
                    if (next.CanMoveThrough())
                    {
                        //Check if already in queue.
                        if (!toCheck.Contains(next) && next.distance == int.MaxValue)
                        {
                            next.distance = current.distance + 1;
                            next.parent   = current;
                            toCheck.Enqueue(next);

                            //Check if in mp range.
                            if (next.distance <= mp && !reachable.Contains(next))
                            {
                                reachable.Add(next);
                            }
                        }
                    }
                }
            }

            //End for loops.
        }

        //End while loop.

        return(reachable);
    }
    public static Stack <GridCell> GetPath(GridCell start, GridCell end)
    {
        GetGridCells();

        //Instantiate lists
        Stack <GridCell>   path       = new Stack <GridCell> ();
        HashSet <GridCell> openList   = new HashSet <GridCell> ();
        HashSet <GridCell> closedList = new HashSet <GridCell> ();

        GridCell currentGridCell = start;

        openList.Add(currentGridCell);

        while (openList.Count > 0)
        {
            //Check x axis
            for (int x = -1; x <= 1; x++)
            {
                GridPos pos = new GridPos(currentGridCell.gridPos.x - x, currentGridCell.gridPos.y);
                if (cells.ContainsKey(pos))
                {
                    GridCell nextGridCell = cells [pos];

                    //Check content
                    if (nextGridCell.CanMoveThrough())
                    {
                        //Check if already in open list, if so, check if a better parent.
                        if (openList.Contains(nextGridCell))
                        {
                            if (currentGridCell.g + 1 < nextGridCell.g)
                            {
                                nextGridCell.CalcValues(currentGridCell, end);
                            }
                        }

                        //Check if not in closed list, if so, add to open list.
                        else if (!closedList.Contains(nextGridCell))
                        {
                            openList.Add(nextGridCell);
                            nextGridCell.CalcValues(currentGridCell, end);
                        }
                    }
                }
            }

            //Check y axis
            for (int y = -1; y <= 1; y++)
            {
                GridPos pos = new GridPos(currentGridCell.gridPos.x, currentGridCell.gridPos.y - y);
                if (cells.ContainsKey(pos))
                {
                    GridCell nextGridCell = cells [pos];

                    //Check content
                    if (nextGridCell.CanMoveThrough())
                    {
                        //Check if already in open list, if so, check if a better parent.
                        if (openList.Contains(nextGridCell))
                        {
                            if (currentGridCell.g + 1 < nextGridCell.g)
                            {
                                nextGridCell.CalcValues(currentGridCell, end);
                            }
                        }

                        //Check if not in closed list, if so, add to open list.
                        else if (!closedList.Contains(nextGridCell))
                        {
                            openList.Add(nextGridCell);
                            nextGridCell.CalcValues(currentGridCell, end);
                        }
                    }
                }
            }
            //End for loops.
            //Remove current tile from open list and add it to the closed list.
            openList.Remove(currentGridCell);
            closedList.Add(currentGridCell);

            //Sort the open list by lowest F score.
            if (openList.Count > 0)
            {
                currentGridCell = openList.OrderBy(c => c.f).First();
            }

            //If goal is found, add it and it's parents to the Path. Then break.
            if (currentGridCell == end)
            {
                while (currentGridCell.gridPos != start.gridPos)
                {
                    path.Push(currentGridCell);
                    currentGridCell = currentGridCell.parent;
                }
                break;
            }
        }
        //End while loop
        return(path);
    }