Sprint 4
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
@@ -12,20 +13,16 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
public GameObject previewButton;
|
||||
// ^^^ TEMPORARY STUFF ^^^
|
||||
|
||||
public GameObject restartButton;
|
||||
/// <summary>
|
||||
/// Reference to the courses
|
||||
/// </summary>
|
||||
public CourseList courseList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the course progress
|
||||
/// </summary>
|
||||
private Progress progress;
|
||||
private PersistentDataController.SavedCourseProgress progress;
|
||||
|
||||
/// <summary>
|
||||
/// Title Display
|
||||
@@ -42,11 +39,27 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public Image courseImage;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Progress bar Display
|
||||
/// </summary>
|
||||
public Slider progressBar;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the progressBar gameObject
|
||||
/// </summary>
|
||||
public GameObject progressObject;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the 'completed' gameObject
|
||||
/// </summary>
|
||||
public GameObject completedObject;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the scene playable director
|
||||
/// </summary>
|
||||
public PlayableDirector directorEnterFromCourseMenu;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the infopage for a given course
|
||||
/// </summary>
|
||||
@@ -56,8 +69,8 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
Course course = courseList.courses[index];
|
||||
|
||||
// vvv TEMPORARY STUFF vvv
|
||||
playButton.SetActive(course.theme.model != null);
|
||||
previewButton.SetActive(course.theme.model == null);
|
||||
playButton.SetActive(course.theme.modelIndex != ModelIndex.NONE);
|
||||
previewButton.SetActive(course.theme.modelIndex == ModelIndex.NONE);
|
||||
// ^^^ TEMPORARY STUFF ^^^
|
||||
|
||||
title.text = course.title;
|
||||
@@ -66,12 +79,48 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
//slider.value = progressValue;
|
||||
|
||||
// Set progress
|
||||
userList.Load();
|
||||
progress = userList.GetCurrentUser().GetCourseProgress(course.index);
|
||||
if (progress != null)
|
||||
progressBar.value = progress.Get<float>("courseProgress");
|
||||
PersistentDataController.GetInstance().Load();
|
||||
progress = UserList.GetCurrentUser().GetCourseProgress(course.index);
|
||||
if (progress != null && course.theme.modelIndex != ModelIndex.NONE)
|
||||
{
|
||||
progressBar.value = progress.progress;
|
||||
if (progress.progress == 1.0f)
|
||||
{
|
||||
playButton.SetActive(false);
|
||||
progressObject.SetActive(false);
|
||||
completedObject.SetActive(true);
|
||||
}
|
||||
if (progress.inUseLearnables > 0)
|
||||
{
|
||||
restartButton.SetActive(true);
|
||||
playButton.transform.Find("Button Text").GetComponent<TMP_Text>().text = "Verder";
|
||||
}
|
||||
else
|
||||
{
|
||||
restartButton.SetActive(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progressBar.value = 0.0f;
|
||||
restartButton.SetActive(false);
|
||||
playButton.transform.Find("Button Text").GetComponent<TMP_Text>().text = "Begin";
|
||||
}
|
||||
|
||||
var sys = SystemController.GetInstance();
|
||||
if (sys.previousScene == SystemController.GetSceneIndex("Common/Scenes/CoursesMenuScreen"))
|
||||
directorEnterFromCourseMenu.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback to reset and start the course
|
||||
/// </summary>
|
||||
public void ResetCourseProgress()
|
||||
{
|
||||
UserList.GetCurrentUser().ResetCourseProgress(progress.courseIndex);
|
||||
UserList.Save();
|
||||
progressBar.value = 0.0f;
|
||||
StartCourse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,6 +128,6 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public void StartCourse()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Courses/Scenes/TemplateCourse");
|
||||
SystemController.GetInstance().LoadNextScene("Courses/Scenes/CourseScreen");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user