private IEnumerator PathFindCoroutine(Tile.Tile startTile, Tile.Tile destinationTile, Action <List <Tile.Tile> > callback, bool isPlayer, PathFinder pathFinder) { pathFinder.FindPath(startTile, destinationTile); while (true) { if (pathFinder.IsFinish) { if (callback != null) { callback(pathFinder.Path); } if (FinishPathFindingEvent != null) { FinishPathFindingEvent(isPlayer, pathFinder); } if (!isPlayer) { DeletePathFinder(pathFinder); } yield break; } yield return(null); } }
private bool isExistSamePathFinder(bool isPlayer, Tile.Tile startTile, Tile.Tile destinationTile) { if (isPlayer) { return(playerPathFinder.StartTile == startTile && playerPathFinder.DestinationTile == destinationTile); } return(workingPathFinders.Any(x => { return x.StartTile == startTile && x.DestinationTile == destinationTile; })); }
// NOTE : 패스 파인딩 개시 public static void StartPathFinding(bool isPlayer, Tile.Tile startTile, Tile.Tile destinationTile, Action <List <Tile.Tile> > callback) { var instance = GetInstance(); // NOTE : 이미 같은 조건으로 패스 파인딩이 진행중이라면 무시 if (instance.isExistSamePathFinder(isPlayer, startTile, destinationTile)) { Debug.Log("path finding ignored"); return; } var pathFinder = isPlayer ? instance.playerPathFinder : instance.GetNewPathFinder(); instance.StartCoroutine(instance.PathFindCoroutine(startTile, destinationTile, callback, isPlayer, pathFinder)); if (instance.StartPathFindingEvent != null) { instance.StartPathFindingEvent(isPlayer, pathFinder); } }
public void Activate(Tile.Tile tile) { selectionManager.Activate(tile.GetSelectionInteractor()); focusManager.Activate(tile.GetFocusInteractor()); }
public Node(Tile.Tile tile, Node parent, int f) { this.tile = tile; this.parent = parent; this.f = f; }