private void BuildPathNextTo(IntVector2 position) { // If we're standing on the target, find the neighbor with the lowest // movement cost and move into it. if (this.position == position) { Board.Tile tile = BoardManager.Board.GetTile(position); Board.Tile moveTo = null; foreach (Board.Tile neighbor in tile.GetNeighbors()) { if ( moveTo == null || moveTo.GetHinderance() > neighbor.GetHinderance() ) { moveTo = neighbor; } } if (moveTo.GetHinderance() < AStarResolver.MAX_COST) { path = new Queue <IntVector2>(); path.Enqueue(moveTo.position); } } else { BuildPathTo(position); RemoveLastPathItem(); } }
private ulong GetTileCost(IntVector2 pos) { Board.Tile tile = board.GetTile(pos); if (tile == null) { return(MAX_COST); } return(tile.GetHinderance()); }