// checks whether there would be a collison of the tetramino with the grid if the tetramino // was moved by offset and rotated according to rotation type public static bool Collision (Grid grid, Tetramino tetramino, Vector2Int offset, Tetramino.RotationType rotation) { bool collision = false; Vector2Int[] tryPoses = tetramino.GetAbsPoses(offset, rotation); foreach (Vector2Int pos in tryPoses) { if (0 <= pos.x && pos.x < grid.blocks.GetLength(0) && 0 <= pos.y && pos.y < grid.blocks.GetLength(1)) { collision = grid[pos] != null; } else { collision = true; } if (collision) { break; } } return(collision); }