Ejemplo n.º 1
0
    /// <summary>
    /// Takes in a Tile t and a range and returns a list of all the tiles within that range
    /// </summary>
    /// <param name="t">tile we are starting from</param>
    /// <param name="range">range we are covering</param>
    /// <param name="tileValid">delegate that holds special check on tile condition </param>
    /// <returns>returns a set of all the tiles within a given range with t as the center</returns>
    private HashSet <Tile> getTilesInRange(Tile t, int range, tileValid tileValid)
    {
        HashSet <Tile> tiles = new HashSet <Tile>();

        getTilesInRange(t, t, tiles, range, tileValid);
        return(tiles);
    }
Ejemplo n.º 2
0
    private void getTilesInRange(Tile source, Tile t, HashSet <Tile> tiles, int range, tileValid tileValid)
    {
        tiles.Add(t);
        List <Tile> neighbors = getTileNeighbors(t);

        foreach (Tile n in neighbors)
        {
            if (range > 1 && n.active)
            {
                if (tileValid != null && tileValid.Invoke(source, t))
                {
                    getTilesInRange(source, n, tiles, range - 1, tileValid);
                }
            }
        }
    }