using UnityEngine;
///
/// ListCourseScreen scene manager
///
public class ListCoursesScreen : MonoBehaviour
{
///
/// Reference to the userlist
///
public UserList userList;
///
/// Reference to the course-list container object
///
public Transform courseContainer;
///
/// Prefab of the course item object
///
public GameObject courseItemPrefab;
///
/// Reference to the list of all courses
///
public CourseList courseList;
///
/// Start is called before the first frame update
///
void Start()
{
User user = userList.GetCurrentUser();
foreach (Course course in courseList.courses)
{
// Create instance of prefab
GameObject instance = GameObject.Instantiate(courseItemPrefab, courseContainer);
// Dynamically load appearance
CourseItem item = instance.GetComponent();
item.course = course;
Progress progress = user.GetCourseProgress(course.index);
item.progress = progress != null ? progress.Get("courseProgress") : 0.0f;
}
}
///
/// Method used as callback for course item onClick events
///
public void GotoCourseInfo()
{
SystemController.GetInstance().LoadNextScene("Common/Scenes/CourseActivityScreen");
}
}