Resolve WES-43 "Minigame framework"

This commit is contained in:
Dries Van Schuylenbergh
2023-03-06 12:14:25 +00:00
parent f670c0cd0a
commit 9eebf4e4f2
34 changed files with 3092 additions and 2354 deletions

View File

@@ -5,12 +5,6 @@ using UnityEngine.SceneManagement;
public class ChangeSceneOnClick : MonoBehaviour
{
// Backwards compatible because SOMEONE did not use correct naming convention
public void loadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
// Load scene from path name
public void LoadScene(string sceneName)
{

View File

@@ -1,4 +1,3 @@
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using TMPro;
@@ -16,10 +15,15 @@ public class CourseItem : MonoBehaviour
public string courseScene;
[Header("UI references")]
// Reference to thumbnail object
public Image thumbnail;
// Reference to title object
public TMP_Text title;
// Refetence to object so correct callback can be trigger on click
public Button button;
// Reference to progress bar
public GameObject slider;
// Reference to `COMPLETED`
public GameObject completed;
@@ -29,11 +33,6 @@ public class CourseItem : MonoBehaviour
GenerateContent();
}
private void LoadCourseInfo()
{
SceneManager.LoadScene(courseScene);
}
public void GenerateContent()
{
// Set appearance
@@ -45,8 +44,8 @@ public class CourseItem : MonoBehaviour
completed.SetActive(1.0f <= progress);
slider.SetActive(0.0f < progress && progress < 1.0f);
slider.GetComponent<Slider>().value = progress;
// Add click functionality
button.onClick.AddListener(LoadCourseInfo);
button.onClick.AddListener(() => SceneManager.LoadScene(courseScene));
}
}

View File

@@ -1,17 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.UI;
using UnityEngine.SceneManagement;
public class CourseScreenManager : MonoBehaviour
{
[Header("Course Screen Components")]
// Reference to text that displays when there are no recent courses
public GameObject noRecentCourses;
// Reference to recent-courses-list holder object
public Transform recentCourses;
// Reference to recommended-courses-list holder object
public Transform recommendedCourses;
[Header("Prefabs")]
// CourseItem prefab
public GameObject course_item;
// TODO: change to ScriptableObject;
@@ -60,6 +63,7 @@ public class CourseScreenManager : MonoBehaviour
}
}
// Method used as callback for on click events
public void LoadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);

View File

@@ -7,10 +7,12 @@ using UnityEngine.SceneManagement;
public class ListScreenManager : MonoBehaviour
{
[Header("List Screen Components")]
public Transform item_container;
// Reference to item-list holder object
public Transform itemContainer;
[Header("Prefabs")]
public GameObject item_prefab;
// Prefab of item
public GameObject itemPrefab;
// TODO: change to ScriptableObject;
[Header("ScriptableObjects")]
@@ -25,7 +27,7 @@ public class ListScreenManager : MonoBehaviour
for (int i = 0; i < numberOfItems; i++)
{
// Create instance of prefab
GameObject instance = GameObject.Instantiate(item_prefab, item_container);
GameObject instance = GameObject.Instantiate(itemPrefab, itemContainer);
// Dynamically load appearance
CourseItem item = instance.GetComponent<CourseItem>();
@@ -36,6 +38,7 @@ public class ListScreenManager : MonoBehaviour
}
}
// Method used as callback for on click events
public void LoadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);