Beispiel #1
0
    public void ChangePath(Path path)
    {
        if (path != null)
        {
            currentPath = path;
        }

        pathChanged.Invoke(currentPath);
    }
        public void OnPress()
        {
#if UNITY_IOS && !UNITY_EDITOR
            IOSVideoPicker.GetVideoPath((string path) =>
            {
                iosPath.text = path;
                pathSetter.Invoke(path);
            });
#endif
        }
Beispiel #3
0
 public void EndPath(Path path)
 {
     pathEnded.Invoke(currentPath);
 }
Beispiel #4
0
 /// <summary>
 /// Is called from InputField (inspector) as well.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public void OnFileNameInput(string fileName)
 {
     pathSetter.Invoke(iosDirectory.text + fileName);
 }
Beispiel #5
0
    IEnumerator PathfindingAnimation()
    {
        if (null != currentTile.previousTile)
        {
            currentTile.previousTile.tileStatus = TileStatus.clear;
        }


        while (unvsitedTiles.Count > 0 && currentTile != goal)
        {
            unvsitedTiles.Remove(currentTile);

            Debug.Assert(currentTile.Connections.Count <= 4); // take out later

            // all neighbors
            foreach (MapTile neighbor in currentTile.Connections)
            {
                if (neighbor.calculatedCost > 1000000)
                {
                    int newCost = currentTile.calculatedCost + neighbor.Data.traversalCost;
                    if (newCost < neighbor.calculatedCost)
                    {
                        neighbor.calculatedCost = newCost;
                        neighbor.previousTile   = currentTile;
                    }
                }
            }

            // currentTile.tileStatus = TileStatus.clear;
            foreach (MapTile tile in currentTile.Connections)
            {
                tile.tileStatus = TileStatus.none;
            }

            // next current
            currentTile = unvsitedTiles[0];
            foreach (MapTile currentCheck in unvsitedTiles)
            {
                if (currentCheck.calculatedCost < currentTile.calculatedCost)
                {
                    currentTile            = currentCheck;
                    currentTile.tileStatus = TileStatus.current;
                    foreach (MapTile neighbor in currentTile.Connections)
                    {
                        neighbor.tileStatus = TileStatus.next;
                    }
                }
            }

            yield return(new WaitForSeconds(waitTime));
        }

        List <MapTile> path     = Pathfinder.GeneratePath(start, goal, false);
        FoundPath      toReturn = new FoundPath
        {
            start = start,
            goal  = goal,
            path  = path
        };

        // cleanup
        foreach (MapTile tile in allTiles)
        {
            tile.ResetPathfinding();
        }

        pathSave = toReturn;

        pathFound?.Invoke();
    }