Determining if three values equal a certain value

Hello,

I am really wondering if there is a way to check to see if two or more values equal a certain number but for my game idea I need three values to total 7.

The game is going to have randomly instantiated prefabs with a random number inside. The numbers in the prefab range from 0 to 7. The idea of the game is to line up three blocks and if they equal 7, those blocks will be destroyed and the player will receive points for this.

Example:
Blocks: [0],[1],[2],[3],[4],[5],[6],[7]

If block 1 has a value of 3, block 2 has a value of 4 and block 3 has a value of 0, they should all disappear the player should get points for this.

Another way for a player to score is if block 1 has a value 2, block 2 has a value 2 and block 3 has a value of 3, this would also cause these blocks to disappear and the player will get points.

Below are the only ways that 7 can be attained from a range of 0 to 7, thus below are the only ways a player can receive points.

7+0+0
6+1+0
5+2+0
5+1+1
4+3+0
4+2+1
3+3+1
3+2+2

7+7+7

One last way to score is if three 7’s are matched together. I have included that as the final line for scoring. I think that would be the easiest to figure out because the only way match three 7’s together would be if the total value of three blocks equals 21. I am thinking the code would look something like
if (block_1 + block_2 + block_3 = 21) {
Destroy blocks;
UpdateScore();
}

There is probably an || that would go in the if statement but I am not sure how to code this.


As I am writing this question out, I see how there is a lot of logic that need to go into the scoring and the way the value of blocks are totaled.

The way I am thinking about this is checking each section of grid individually and then checking the two adjacent grid sections either horizontally or vertically and see if combined they equal 7. Now the thing with having a zero as one of the available options throws a wrench in this logic. Because 4+3+0=7 but so does 4+3. I want three blocks to disappear and not just two.

I think having 0 as an option makes the game more interesting but I can have the blocks go from 1 to 7 if that makes more sense and there is not a good way to check for 0 as a third number.

Thank you in advance for any help you may provide and for having to sift through my scatterbrained wording. If anyone needs anything explained a little more, I would be glad to help.

[deleted, misleading]

My problem I am having is if this should be more like example one of more like example 2.

var points = block1 + block2 + block3
If (points ==7){
// insert code to destory blocks.
// insert code to add to player victory point total.
}