//TODO: Stop it from stopping at a tile that has a unit on it. This should be handled in the validater private void Validate(Tile t, int dist, int height, validater func, int origDist, int origHeight) { //If the distance has been reached, return if (dist <= 0) { return; } //loop through all surrounding tiles for (int i = 0; i < t._adjacentTiles.Length; i++) { if (t._adjacentTiles[i] == null) { continue; } //check if it's allowed to be validated if ( Mathf.Abs(t.getHeight() - t._adjacentTiles[i].getHeight()) <= height && func( t._adjacentTiles[i], t, i, origDist - dist, origHeight - height )) { t._adjacentTiles[i].Validate(); } else { continue; } //recurse if (Mathf.Abs(t.getHeight() - t._adjacentTiles[i].getHeight()) <= height) { Validate(t._adjacentTiles[i], dist - 1, height, func, origDist, origHeight); } //END LOOP } }
public void Validate(Tile t, int dist, int height, validater func) { Validate(t, dist, height, func, dist, height); }