Need help about scripting coordinates

6947825--817145--upload_2021-3-18_10-11-39.png

Hello, im working with rotate and match hexagon game. Need to idea for multiple selections.
I add every single gameobjects(hexes) in gameobject array like gameobject[,] so i have coordinates of them.
Game should be when you click one hex its need to be clicked 3 hexes like secend image.

This is my solution need to add some controls for -1x and -1y. Its look like noobish. Can i do something diffrent? Thanks.

void findArroundPos(int x, int y){
        List<int[,]> arroundPoss = new List<int[,]>();
           
           
            arroundPoss.Add(new int[x,y]);

            arroundPoss.Add(new int[x+1,y]);
            arroundPoss.Add(new int[x+1,y-1]);   
            arroundPoss.Add(new int[x+1,y+1]);

            arroundPoss.Add(new int[x-1,y]);
            arroundPoss.Add(new int[x-1,y-1]);   
            arroundPoss.Add(new int[x-1,y+1]);

            arroundPoss.Add(new int[x,y+1]);  
            arroundPoss.Add(new int[x,y-1]);
       
    }

You could slightly simplify that code using a couple of loops, although with only 9 lines it doesn’t matter much.

for (int i = x-1; i <= x+1; ++i)
{
    for (int j = y-1; j <= y+1; ++j)
    {
        aroundPos.Add(new int[i, y]);
    }
}

(I am assuming that the order of elements in the list isn’t important. If you need to keep exactly the order shown in your original code, then it probably can’t be simplified.)

Ignore its elegance, does this code actually work ?

You’re adding empty arrays of different sizes into a list, i’m having a hard time seeing what it is for.
Shouldn’t you store the coordinates instead of empty arrays ?