private static bool HasFeature(Block.Feature feature) { var a = _selectedBlocks[0].GetComponent <Block>().Features; var b = _selectedBlocks[1].GetComponent <Block>().Features; return(a.HasFlag(feature) || b.HasFlag(feature)); }
public Block Generate(Block.Feature features) { var instance = InstantiateBlock(); var block = instance.GetComponent <Block>(); block.Features = features; return(block); }
private bool Solve(Block.Feature current, Block.Feature expected, int row, int column) { if (!current.HasFlag(expected)) { return(false); } if (Block.HasFeaturesPair(current, expected, Block.Feature.Top)) { if (row - 1 >= 0 && !Block.IsEmpty(_board[row - 1, column])) { var next = (Block.Feature)_board[row - 1, column]; return(Solve(next, Block.Feature.Bottom, row - 1, column)); } } if (Block.HasFeaturesPair(current, expected, Block.Feature.Bottom)) { if (row + 1 < _board.GetLength(0) && !Block.IsEmpty(_board[row + 1, column])) { var next = (Block.Feature)_board[row + 1, column]; return(Solve(next, Block.Feature.Top, row + 1, column)); } } if (Block.HasFeaturesPair(current, expected, Block.Feature.Left)) { if (column - 1 >= 0 && !Block.IsEmpty(_board[row, column - 1])) { var next = (Block.Feature)_board[row, column - 1]; return(Solve(next, Block.Feature.Right, row, column - 1)); } } if (Block.HasFeaturesPair(current, expected, Block.Feature.Right)) { if (column + 1 < _board.GetLength(1) && !Block.IsEmpty(_board[row, column + 1])) { var next = (Block.Feature)_board[row, column + 1]; return(Solve(next, Block.Feature.Left, row, column + 1)); } } return(Block.HasFeaturesPair(current, expected, Block.Feature.Target)); }