using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PuzzleManager : MonoBehaviour { public GameObject tilePrefab; // Prefab untuk tile public Sprite[] tileSprites; // Array berisi potongan gambar public int gridSize = 3; // Ukuran grid (3x3) public float tileSize = 100f; // Ukuran tile private GameObject[,] grid; // Grid untuk menyimpan tile private Vector2Int emptyTilePos; // Posisi tile kosong void Start() { InitializeGrid(); ShuffleTiles(); } void InitializeGrid() { grid = new GameObject[gridSize, gridSize]; emptyTilePos = new Vector2Int(gridSize - 1, gridSize - 1); // Tile kosong di pojok kanan bawah for (int y = 0; y < gridSize; y++) { for (int x = 0; x < gridSize; x++) { // Buat tile GameObject tile = Instantiate(tilePrefab, transform); tile.GetComponent().sprite = tileSprites[y * gridSize + x]; tile.GetComponent