// Load a particular course with step information. // Param courseName (in): the name that represents the course in the courseToPath dictionary public void LoadCourse(string courseName) { // Delete the previous course that was loaded ClearState(); // Find course to be loaded string jsonPath; bool courseFound = courseToPath.TryGetValue(courseName, out jsonPath); if (!courseFound) { Debug.Log("Course not found: " + courseName + ". Check that the Course Button, CourseMenuHelper.courseToPath and JSON filepath are sync."); return; } // Read the course string json_data = File.ReadAllText(jsonPath); CourseJSON course_steps = JsonUtility.FromJson <CourseJSON>(json_data); foreach (StepContainer step in course_steps.steps) { steps.Add((step.Position), step); } foreach (CoreographieContainer coreographie in course_steps.coreographies) { coreographies.Add(coreographie.Position, coreographie); } courses.CurrentCourse = course_steps.CourseID; isTraining = true; GenerateCourseMenu(); }
// Loads the Course info without storing the steps for all available courses public void LoadAllCourseInfos() { foreach (KeyValuePair <string, string> entry in courseToPath) { string json_data = File.ReadAllText(entry.Value); CourseJSON course_steps = JsonUtility.FromJson <CourseJSON>(json_data); CourseInfoHolder course = new CourseInfoHolder(); course.CourseID = course_steps.CourseID; course.CourseTitle = course_steps.CourseTitle; course.CourseShortDescription = course_steps.CourseShortDescription; course.CourseDescription = course_steps.CourseDescription; courses.Courses.Add(course); } }
// Load all Coreographies. public void LoadFreeplay() { ClearState(); int id = 0; foreach (KeyValuePair <string, string> entry in courseToPath) { string json_data = File.ReadAllText(entry.Value); CourseJSON course_steps = JsonUtility.FromJson <CourseJSON>(json_data); CourseInfoHolder course = new CourseInfoHolder(); foreach (CoreographieContainer coreographie in course_steps.coreographies) { coreographies.Add(id++, coreographie); } } isTraining = false; GenerateCourseMenu(); }