パブリックに格納されている9x9配列にすべてのタイルを格納し、特定のタイルのiとjの位置を渡すことができます。タイルをクリックすると、クリックしたタイルのiとjを取るグローバルメソッドを呼び出して、周囲のタイルのそれぞれに対してメソッドを実行できます。
public Tile[] tiles = [[tile1,tile2,...],[row2...],...[row9...]];
public void triggerTiles(int ith, int jth) {
for (int i = ith - 1; i <= ith + 1; i ++) {
if(i < tiles.length && i >= 0) {// check if we are in bounds
for(int j = jth - 1; j <= jth + 1; j ++) {
if(j < tiles[i].length && j >= 0) {// check if we are in bounds
if(i != ith && j != jth) { //If not the center tile
tiles[i][j].callMethod();
}
}
}
}
}
}
2次元配列に格納すると、それらの座標で参照できます。 –