using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ListScreenManager : MonoBehaviour
{
    [Header("List Screen Components")]
    // Reference to item-list holder object
    public Transform itemContainer;

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

    // TODO: change to ScriptableObject;
    [Header("ScriptableObjects")]
    public int numberOfItems;
    public string[] itemTitle;
    public float[] itemProgress;
    public Sprite[] itemThumbnail;
    public string[] itemScene;

    void Start()
    {
        for (int i = 0; i < numberOfItems; i++)
        {
            // Create instance of prefab
            GameObject instance = GameObject.Instantiate(itemPrefab, itemContainer);

            // Dynamically load appearance
            CourseItem item = instance.GetComponent<CourseItem>();
            item.courseTitle = itemTitle[i];
            item.courseThumbnail = itemThumbnail[i];
            item.courseProgress = itemProgress[i];
            item.courseScene = itemScene[i];
        }
    }

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