using UnityEngine;
using UnityEngine.SceneManagement;

public class MinigameListManager : MonoBehaviour
{
    [Header("Minigame list UI components")]
    // Reference to minigame-list holder object
    public Transform minigameContainer;

    [Header("Prefabs")]
    // Prefab of item
    public GameObject minigameItemPrefab;

    [Header("Minigames")]
    // Reference to the list of all minigames
    public MinigameList minigameList;

    void Start()
    {
        foreach (Minigame minigame in minigameList.minigames)
        {
            // Create instance of prefab
            GameObject instance = GameObject.Instantiate(minigameItemPrefab, minigameContainer);

            // Dynamically load appearance
            MinigameItem item = instance.GetComponent<MinigameItem>();
            item.minigame = minigame;
        }
    }

    // Method used as callback for on click events
    public void LoadScene(string sceneName)
    {
        SceneManager.LoadScene(sceneName);
    }
}
