Files
unity-application/Assets/Common/Interfaces/CourseList.cs
2023-04-04 17:00:47 +00:00

39 lines
1.2 KiB
C#

using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Keep track of all courses
/// </summary>
[CreateAssetMenu(menuName = "Create new Scriptable/Course List")]
public class CourseList : ScriptableObject
{
/// <summary>
/// Index of the active/to be loaded/current course
/// </summary>
public int currentCourseIndex = 0;
/// <summary>
/// List of all installed courses
/// </summary>
public List<Course> courses = new List<Course>();
/// <summary>
/// Get a course by CourseIndex
/// </summary>
/// <param name="courseIndex">CourseIndex of the course, each unique course has a unique CourseIndex</param>
/// <returns>Course associated with this index, null if no course was found</returns>
public Course GetCourseByIndex(CourseIndex courseIndex)
{
return courses.Find((c) => c.index == courseIndex);
}
/// <summary>
/// Function to find a minigame-index in the list based on its index
/// </summary>
/// <param name="title"></param>
public void SetCurrentCourse(CourseIndex index)
{
this.currentCourseIndex = courses.FindIndex((mi) => mi.index == index);
}
}