Beispiel #1
0
    public static void bn_map_forEachTrue(Action <BlockGroup, int, int> fn, BlockGroup blkG, List <string> bin = null)
    {
        if (bin == null)
        {
            bin = TetrominoControls.mapTetromino(blkG.GetPiece());
        }

        bool read_row(int curr)
        {
            if (curr < bin.Count)
            {
                return(read_col(bin[curr], curr, 0));
            }
            return(true);
        }

        bool read_col(string s, int r, int curr) //read all columns of a row
        {
            if (curr < s.Length)
            {
                if (s[curr] == '1')
                {
                    fn(blkG, curr, r);
                }
                return(read_col(s, r, curr + 1));
            }
            return(read_row(r + 1));
        }

        read_row(0);
    }