void FormatNode(NodeComponent _node, NodeComponent _parent)
 {
     _node.SetNodeParent(_parent);
     _node.SetG(_parent.GetG() + Vector3.Magnitude(_node.transform.position - _parent.transform.position));
     _node.SetH(End.transform.position);
     ChangeTileToColor(_node, Color.yellow);
 }
    // 1 => path found!, 0 => next step required, -1 => no path possible
    public int NextStep()
    {
        if (Open.Count == 0)
        {
            return(-1);
        }

        NodeComponent currentTile = Open.Pop();

        if (currentTile == null)
        {
            return(-1);
        }

        if (currentTile == End)
        {
            return(1);
        }

        List <NodeComponent> neighbours = currentTile.GetComponent <TileComponent>().GetCrossNeighbours();

        if (DoDiagonal)
        {
            neighbours.AddRange(currentTile.GetComponent <TileComponent>().GetDiagonalNeighbours());
        }

        for (int i = 0; i < neighbours.Count; i++)
        {
            NodeComponent currentNeighbour = neighbours[i];

            if (Open.Contains(currentNeighbour))
            {
                float currentF = currentTile.GetG() + currentNeighbour.GetH() + Vector3.Magnitude(currentNeighbour.transform.position - currentTile.transform.position);

                if (currentF < currentNeighbour.GetF())
                {
                    Open.Remove(currentNeighbour);
                    Open.Add(currentNeighbour);
                }
            }
            else if (Closed.Contains(currentNeighbour))
            {
                float currentF = currentTile.GetG() + currentNeighbour.GetH() + Vector3.Magnitude(currentNeighbour.transform.position - currentTile.transform.position);

                if (currentF < currentNeighbour.GetF())
                {
                    Closed.Remove(currentNeighbour);
                    Open.Add(currentNeighbour);
                }
            }
            else
            {
                FormatNode(currentNeighbour, currentTile);
                Open.Add(currentNeighbour);
            }
        }

        ChangeTileToColor(currentTile, Color.blue);
        Closed.Add(currentTile);

        return(0);
    }