private static List<GenericFloorItem> findCombo(final GenericFloorItem tile, final int find, int X, int Y, int xCan, int yCan, int curRot, int turn) {
final boolean[] moves = new boolean[4];
if(xCan == -1) {
moves[0] = true;
} else if(xCan == 1) {
moves[2] = true;
} else if(xCan == 0) {
moves[0] = true;
moves[2] = true;
}
if(yCan == -1) {
moves[1] = true;
} else if(yCan == 1) {
moves[3] = true;
} else if(yCan == 0) {
moves[1] = true;
moves[3] = true;
}
if((xCan != 0 || yCan != 0) && tile.getX() == X && tile.getY() == Y) {
return new ArrayList<GenericFloorItem>();
}
for(int i=0;i<4;i++) {
if(!moves[i]) {
continue;
}
int x,y;
if(i == 0) {
x = X + 1;
y = Y;
} else if(i == 1) {
x = X;
y = Y + 1;
} else if(i == 2) {
x = X - 1;
y = Y;
} else { // if(i == 3)
x = X;
y = Y - 1;
}
final RoomTask room = tile.getRoom();
final int nextXY = x + (y * room.model.widthX);
if(x < room.model.widthX && y < room.model.heightY) {
final GenericFloorItem top = (GenericFloorItem)room.topFloorItems.get(nextXY);
if(top != null) {
if(top.getIntData() == find) {
if(curRot != i && curRot != -1) {
if(turn != 0) {
List<GenericFloorItem> found = null;
if(i == 0) {
found = findCombo(tile, find, x, y, -1, (yCan*-1), i, (turn - 1));
} else if(i == 1) {
found = findCombo(tile, find, x, y, (xCan*-1), -1, i, (turn - 1));
} else if(i == 2) {
found = findCombo(tile, find, x, y, 1, (yCan*-1), i, (turn - 1));
} else if(i == 3) {
found = findCombo(tile, find, x, y, (xCan*-1), 1, i, (turn - 1));
}
if(found != null) {
found.add(top);
return found;
}
}
} else {
List<GenericFloorItem> found = null;
if(i == 0) {
found = findCombo(tile, find, x, y, -1, yCan, i, turn);
} else if(i == 1) {
found = findCombo(tile, find, x, y, xCan, -1, i, turn);
} else if(i == 2) {
found = findCombo(tile, find, x, y, 1, yCan, i, turn);
} else if(i == 3) {
found = findCombo(tile, find, x, y, xCan, 1, i, turn);
}
if(found != null) {
found.add(top);
return found;
}
}
}
}
}
}
return null;
}