Ejemplo n.º 1
0
    private string StartSearchAsync(string point1, string point2)
    {
        SearchTypeDropdown.interactable = false;
        Point1InputField.interactable   = false;
        Point2InputField.interactable   = false;

        StartPoint = GameObject.Find(point1).GetComponent <Point>();
        EndPoint   = GameObject.Find(point2).GetComponent <Point>();

        //Set the default settings to start
        foreach (var path in paths)
        {
            path.ResetToDefault();
        }

        foreach (var path in EndPoint.Paths)
        {
            if (path.Type != MMPath.PathType.OneWay)
            {
                path.Type = MMPath.PathType.OneWay;
                if (EndPoint == path.PointA)
                {
                    path.OneWayDirection = MMPath.OneWayMode.BToA;
                }
                else
                {
                    path.OneWayDirection = MMPath.OneWayMode.AToB;
                }
            }
        }

        var searchType = SearchTypeDropdown.value;

        switch (searchType)
        {
        case 0:
            diijkstraSearch.Setup(StartPoint, EndPoint);
            diijkstraSearch.BeginAsync();
            break;

        case 1:
            aStarSeach.Setup(StartPoint, EndPoint);
            aStarSeach.BeginAsync();
            break;
        }

        return(CurrentDistanceToStartValueText.text);
    }