Resolve WES-99 "Cc refactor"
This commit is contained in:
15
Assets/Common/Scripts/BackButton.cs
Normal file
15
Assets/Common/Scripts/BackButton.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Script managing the default 'back'-button action
|
||||
/// </summary>
|
||||
public class BackButton : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// The default 'back'-button action: go back to the previous scene
|
||||
/// </summary>
|
||||
public void Back()
|
||||
{
|
||||
SystemController.GetInstance().BackToPreviousScene();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e2726fda637a1488461b7a43e46343
|
||||
guid: c3dd279b546423e4a8a1b28819a6c4a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Authorize and check for available webcam(s)
|
||||
/// </summary>
|
||||
public class WebcamAuthorization : MonoBehaviour
|
||||
public class BootScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// UI Reference to the text object to display an error message
|
||||
@@ -24,7 +23,7 @@ public class WebcamAuthorization : MonoBehaviour
|
||||
{
|
||||
if (0 < WebCamTexture.devices.Length)
|
||||
{
|
||||
SceneManager.LoadScene("Common/Scenes/StartScreen");
|
||||
SystemController.GetInstance().SwapScene("Common/Scenes/MainMenuScreen");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1,35 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Class to handle scene loading callbacks
|
||||
/// </summary>
|
||||
public class ChangeSceneOnClick : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Method used as callback for gameobject onClick events
|
||||
/// </summary>
|
||||
/// <param name="sceneName">The path to the new scene (<c>path == $"Assets/{sceneName}"</c>)</param>
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method used as callback for gameobject onClick events
|
||||
/// </summary>
|
||||
/// <param name="scene">Reference to a scene</param>
|
||||
public void LoadScene(Scene scene)
|
||||
{
|
||||
SceneManager.LoadScene(scene.buildIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method used as callback from gameobject onClick events
|
||||
/// </summary>
|
||||
/// <param name="buildIndex">Build index of the scene to be loaded</param>
|
||||
public void LoadScene(int buildIndex)
|
||||
{
|
||||
SceneManager.LoadScene(buildIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro; // For text
|
||||
|
||||
/// <summary>
|
||||
/// Manager infopage for the Courses
|
||||
/// </summary>
|
||||
public class InfoCourse : MonoBehaviour
|
||||
public class CourseActivityScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the courses
|
||||
/// </summary>
|
||||
public CourseList list;
|
||||
public CourseList courseList;
|
||||
// private float maxvalue; In case we want to change progress e.g. amount of words correct, then change maxvalue amount of words etc.
|
||||
|
||||
/// <summary>
|
||||
@@ -43,17 +41,15 @@ public class InfoCourse : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Progress bar Display
|
||||
/// </summary>
|
||||
public Slider slider;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
public Slider progressBar;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the infopage for a given course
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
int index = list.currentCourseIndex;
|
||||
Course course = list.courses[index];
|
||||
int index = courseList.currentCourseIndex;
|
||||
Course course = courseList.courses[index];
|
||||
|
||||
title.text = course.title;
|
||||
description.text = course.description;
|
||||
@@ -63,9 +59,16 @@ public class InfoCourse : MonoBehaviour
|
||||
// Set progress
|
||||
progress = userList.GetCurrentUser().GetCourseProgress(course.index);
|
||||
if (progress != null)
|
||||
slider.value = progress.Get<float>("courseProgress");
|
||||
progressBar.value = progress.Get<float>("courseProgress");
|
||||
else
|
||||
slider.value = 0.0f;
|
||||
progressBar.value = 0.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback to start the course
|
||||
/// </summary>
|
||||
public void StartCourse()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Courses/Scenes/TemplateCourse");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
@@ -68,6 +67,6 @@ public class CourseItem : MonoBehaviour
|
||||
slider.GetComponent<Slider>().value = progress;
|
||||
|
||||
// Add click functionality
|
||||
button.onClick.AddListener(() => SceneManager.LoadScene("Common/Scenes/InfoCourse"));
|
||||
button.onClick.AddListener(() => SystemController.GetInstance().LoadNextScene("Common/Scenes/CourseActivityScreen"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// CourseScreen scene manager
|
||||
/// </summary>
|
||||
public class CourseScreenManager : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to text that displays when there are no recent courses
|
||||
/// </summary>
|
||||
public GameObject noRecentCourses;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to recent-courses-list container object
|
||||
/// </summary>
|
||||
public Transform recentCoursesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to recommended-courses-list container object
|
||||
/// </summary>
|
||||
public Transform recommendedCoursesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Prefab of the course item object
|
||||
/// </summary>
|
||||
public GameObject courseItem;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users so we can get the current user;
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the courses
|
||||
/// </summary>
|
||||
public CourseList courseList;
|
||||
|
||||
/// <summary>
|
||||
/// Start is called before the first frame update
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
User user = userList.GetCurrentUser();
|
||||
|
||||
// Recent courses
|
||||
List<Tuple<CourseIndex, float>> recentCourses = user.GetRecentCourses();
|
||||
noRecentCourses.SetActive(recentCourses.Count <= 0);
|
||||
foreach (Tuple<CourseIndex, float> course in recentCourses)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(courseItem, recentCoursesContainer);
|
||||
|
||||
// Dynamically load appearance
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.course = courseList.courses.Find((j) => j.index == course.Item1);
|
||||
item.progress = course.Item2;
|
||||
}
|
||||
|
||||
// Recommended courses
|
||||
List<Tuple<CourseIndex, float>> recommenedCourses = user.GetRecommendedCourses();
|
||||
foreach (Tuple<CourseIndex, float> course in recommenedCourses)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(courseItem, recommendedCoursesContainer);
|
||||
|
||||
// Dynamically load appearance
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.course = courseList.courses.Find((j) => j.index == course.Item1);
|
||||
item.progress = course.Item2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method used as callback for course item onClick events
|
||||
/// </summary>
|
||||
/// <param name="sceneName">The path to the new scene (<c>path == $"Assets/{sceneName}"</c>)</param>
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// ListCourseScreen scene manager
|
||||
/// </summary>
|
||||
public class CourseListManager : MonoBehaviour
|
||||
public class ListCoursesScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the course-list container object
|
||||
@@ -40,9 +39,8 @@ public class CourseListManager : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Method used as callback for course item onClick events
|
||||
/// </summary>
|
||||
/// <param name="sceneName">The path to the new scene (<c>path == $"Assets/{sceneName}"</c>)</param>
|
||||
public void LoadScene(string sceneName)
|
||||
public void GotoCourseInfo()
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CourseActivityScreen");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// ListMinigameScreen scene manager
|
||||
/// </summary>
|
||||
public class MinigameListManager : MonoBehaviour
|
||||
public class ListMinigamesScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to minigame-list container object
|
||||
@@ -43,6 +42,6 @@ public class MinigameListManager : MonoBehaviour
|
||||
/// <param name="sceneName">The path to the new scene (<c>path == $"Assets/{sceneName}"</c>)</param>
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
SystemController.GetInstance().LoadNextScene(sceneName);
|
||||
}
|
||||
}
|
||||
57
Assets/Common/Scripts/MainMenuScreen.cs
Normal file
57
Assets/Common/Scripts/MainMenuScreen.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// StartScreen scene manager
|
||||
/// </summary>
|
||||
public class MainMenuScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Referece to the userlist to check whether an user account is present
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Check on load whether a user is already present,
|
||||
/// if not load the UserCreationScreen scene so the user can create a new account
|
||||
/// </summary>
|
||||
void Awake()
|
||||
{
|
||||
if (!File.Exists(UserList.PATH) || userList.GetUsers().Count <= 0)
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Accounts/Scenes/UserCreationScreen");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Quit the application
|
||||
/// </summary>
|
||||
public void QuitApplication()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the `CoursesMenuScreen` scene
|
||||
/// </summary>
|
||||
public void GotoCourses()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CoursesMenuScreen");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the `ListMinigamesScreen` scene
|
||||
/// </summary>
|
||||
public void GotoMinigames()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the `SettingsScreen` scene
|
||||
/// </summary>
|
||||
public void GotoSettings()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/SettingsScreen");
|
||||
}
|
||||
}
|
||||
@@ -40,5 +40,4 @@ public class Minigame : ScriptableObject
|
||||
/// An explanation on how to play the game and score points
|
||||
/// </summary>
|
||||
public string controls;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using static GameController;
|
||||
|
||||
/// <summary>
|
||||
/// Manager infopage for the Minigames
|
||||
/// </summary>
|
||||
public class InfoMinigame : MonoBehaviour
|
||||
public class MinigameActivityScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the Minigames
|
||||
/// </summary>
|
||||
public MinigameList list;
|
||||
public MinigameList minigameList;
|
||||
|
||||
/// <summary>
|
||||
/// Title Display
|
||||
@@ -44,8 +40,6 @@ public class InfoMinigame : MonoBehaviour
|
||||
/// </summary>
|
||||
public TMP_Text controls;
|
||||
|
||||
// Scores for each user
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users
|
||||
/// </summary>
|
||||
@@ -66,7 +60,6 @@ public class InfoMinigame : MonoBehaviour
|
||||
/// </summary>
|
||||
public GameObject prefab;
|
||||
|
||||
// Start is called before the first frame update
|
||||
/// <summary>
|
||||
/// Sets the infopage for a given minigame
|
||||
/// </summary>
|
||||
@@ -82,9 +75,9 @@ public class InfoMinigame : MonoBehaviour
|
||||
private void GenerateContent()
|
||||
{
|
||||
// Get current minigame
|
||||
int index = list.currentMinigameIndex;
|
||||
Minigame minigame = list.minigames[index];
|
||||
|
||||
int index = minigameList.currentMinigameIndex;
|
||||
Minigame minigame = minigameList.minigames[index];
|
||||
|
||||
// Set main screen
|
||||
title.text = minigame.title;
|
||||
description.text = minigame.description;
|
||||
@@ -92,10 +85,13 @@ public class InfoMinigame : MonoBehaviour
|
||||
controls.text = minigame.controls;
|
||||
|
||||
// Add click
|
||||
if (minigame.needsTheme) {
|
||||
button.onClick.AddListener(() => SceneManager.LoadScene("Common/Scenes/ThemeSelection"));
|
||||
} else {
|
||||
button.onClick.AddListener(() => SceneManager.LoadScene(minigame.minigameEntryPoint));
|
||||
if (minigame.needsTheme)
|
||||
{
|
||||
button.onClick.AddListener(() => SystemController.GetInstance().LoadNextScene("Common/Scenes/ThemeSelectionScreen"));
|
||||
}
|
||||
else
|
||||
{
|
||||
button.onClick.AddListener(() => SystemController.GetInstance().LoadNextScene(minigame.minigameEntryPoint));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,10 +104,10 @@ public class InfoMinigame : MonoBehaviour
|
||||
private void GenerateHighScores()
|
||||
{
|
||||
// Get current minigame
|
||||
int index = list.currentMinigameIndex;
|
||||
Minigame minigame = list.minigames[index];
|
||||
int index = minigameList.currentMinigameIndex;
|
||||
Minigame minigame = minigameList.minigames[index];
|
||||
|
||||
List<Tuple<string, Sprite, Score>> allScores = new List<Tuple<string, Sprite, Score>>();
|
||||
List<Tuple<string, Sprite, GameController.Score>> allScores = new List<Tuple<string, Sprite, GameController.Score>>();
|
||||
foreach (User user in userList.GetUsers())
|
||||
{
|
||||
// Get user's progress for this minigame
|
||||
@@ -119,10 +115,10 @@ public class InfoMinigame : MonoBehaviour
|
||||
if (progress != null)
|
||||
{
|
||||
// Add scores to dictionary
|
||||
List<Score> scores = progress.Get<List<Score>>("scores");
|
||||
foreach (Score score in scores)
|
||||
List<GameController.Score> scores = progress.Get<List<GameController.Score>>("scores");
|
||||
foreach (GameController.Score score in scores)
|
||||
{
|
||||
allScores.Add(new Tuple<string, Sprite, Score>(user.username, user.avatar, score));
|
||||
allScores.Add(new Tuple<string, Sprite, GameController.Score>(user.username, user.avatar, score));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,17 +127,16 @@ public class InfoMinigame : MonoBehaviour
|
||||
allScores.Sort((a, b) => b.Item3.scoreValue.CompareTo(a.Item3.scoreValue));
|
||||
|
||||
// Instantiate scoreboard entries
|
||||
foreach (Tuple<string, Sprite, Score> tup in allScores.Take(3))
|
||||
foreach (Tuple<string, Sprite, GameController.Score> tup in allScores.Take(3))
|
||||
{
|
||||
string username = tup.Item1;
|
||||
Sprite sprite = tup.Item2;
|
||||
Score score = tup.Item3;
|
||||
GameController.Score score = tup.Item3;
|
||||
|
||||
GameObject instance = GameObject.Instantiate(prefab, userContainer);
|
||||
instance.transform.Find("Title").GetComponent<TMP_Text>().text = username;
|
||||
instance.transform.Find("Avatar").GetComponent<Image>().sprite = sprite;
|
||||
instance.transform.Find("Score").GetComponent<TMP_Text>().text = score.scoreValue.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the display of minigames in the ListMinigameScreen scene
|
||||
/// </summary>
|
||||
public class MinigameItem : MonoBehaviour
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the minigame object
|
||||
/// </summary>
|
||||
@@ -46,11 +44,12 @@ public class MinigameItem : MonoBehaviour
|
||||
// Set appearance
|
||||
thumbnail.sprite = minigame.thumbnail;
|
||||
title.text = minigame.title;
|
||||
|
||||
|
||||
// Add click functionality
|
||||
button.onClick.AddListener(() => {
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
PlayerPrefs.SetString("gamePath", minigame.minigameEntryPoint);
|
||||
SceneManager.LoadScene("Common/Scenes/InfoMinigame");
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/MinigameActivityScreen");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// StartScreen scene manager
|
||||
/// </summary>
|
||||
public class StartScreenManager : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Referece to the userlist to check whether an user account is present
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Check on load whether a user is already present,
|
||||
/// if not load the UserCreationScreen scene so the user can create a new account
|
||||
/// </summary>
|
||||
void Awake()
|
||||
{
|
||||
if (!File.Exists(UserList.PATH) || userList.GetUsers().Count <= 0)
|
||||
{
|
||||
SceneManager.LoadScene("Accounts/Scenes/UserCreationScreen");
|
||||
}
|
||||
}
|
||||
|
||||
public void QuitApplication()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
104
Assets/Common/Scripts/SystemController.cs
Normal file
104
Assets/Common/Scripts/SystemController.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// SystemController singleton
|
||||
/// </summary>
|
||||
public class SystemController
|
||||
{
|
||||
/// <summary>
|
||||
/// The instance controlling the singleton
|
||||
/// </summary>
|
||||
private static SystemController instance = null;
|
||||
|
||||
/// <summary>
|
||||
/// Stack of the loaded scenes, used to easily go back to previous scenes
|
||||
/// </summary>
|
||||
private Stack<int> sceneStack = new Stack<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Get the instance loaded by the singleton
|
||||
/// </summary>
|
||||
/// <returns>SystemController instance</returns>
|
||||
public static SystemController GetInstance()
|
||||
{
|
||||
// Create a new instance if non exists
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new SystemController();
|
||||
instance.sceneStack.Push(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the scene and push on the stack
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void LoadNextScene(string scenePath)
|
||||
{
|
||||
LoadNextScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the scene and push on the stack
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void LoadNextScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Push(sceneIndex);
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap the current scene with the new scene on the stack
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void SwapScene(string scenePath)
|
||||
{
|
||||
SwapScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap the current scene with the new scene on the stack
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void SwapScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Pop();
|
||||
LoadNextScene(sceneIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to the previous scene and unload the current scene
|
||||
/// </summary>
|
||||
public void BackToPreviousScene()
|
||||
{
|
||||
sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to a specific scene, unloading all the scenes on the way
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void BackToScene(string scenePath)
|
||||
{
|
||||
BackToScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to a specific scene, unloading all the scene on the way
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void BackToScene(int sceneIndex)
|
||||
{
|
||||
while (0 < sceneStack.Count && sceneStack.Peek() != sceneIndex) sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949ba4da8595d52aebc98e6f9b6a405e
|
||||
guid: e901944427bb1104a881881efebd3737
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,12 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Controller for the theme selection screen
|
||||
/// ThemeSelectionScreen scene manager
|
||||
/// </summary>
|
||||
public class ThemeSelectionController : MonoBehaviour
|
||||
public class ThemeSelectionScreen : MonoBehaviour
|
||||
{
|
||||
[Header("Theme Selection")]
|
||||
/// <summary>
|
||||
/// Theme prefab
|
||||
/// </summary>
|
||||
@@ -18,9 +16,9 @@ public class ThemeSelectionController : MonoBehaviour
|
||||
public Transform themesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Function that is called upon loading the scene
|
||||
/// Start is called before the first frame update
|
||||
/// </summary>
|
||||
public void Start()
|
||||
void Start()
|
||||
{
|
||||
// TODO: change to ScriptableObject
|
||||
ThemeList themeList = ThemeLoader.LoadJson();
|
||||
@@ -41,11 +39,12 @@ public class ThemeSelectionController : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function that is called upon a button click
|
||||
/// Load the game with a specified theme
|
||||
/// </summary>
|
||||
/// <param name="clickedTheme">Name of the clicked theme</param>
|
||||
public void OnButtonClick(string clickedTheme)
|
||||
{
|
||||
PlayerPrefs.SetString("themeName", clickedTheme);
|
||||
SceneManager.LoadScene(PlayerPrefs.GetString("gamePath"));
|
||||
SystemController.GetInstance().SwapScene(PlayerPrefs.GetString("gamePath"));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68caaa5508a4d40448b47630ff86f035
|
||||
guid: 30d9f9130bf1d414aaad006b2177bdea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,6 +1,5 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +43,7 @@ public class UserButton : MonoBehaviour
|
||||
/// </summary>
|
||||
public void OpenProgressCallback()
|
||||
{
|
||||
SceneManager.LoadScene("Accounts/Scenes/UserProgressScreen");
|
||||
SystemController.GetInstance().LoadNextScene("Accounts/Scenes/UserProgressScreen");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +51,7 @@ public class UserButton : MonoBehaviour
|
||||
/// </summary>
|
||||
public void ChangeUserCallback()
|
||||
{
|
||||
SceneManager.LoadScene("Accounts/Scenes/ChangeUserScreen");
|
||||
SystemController.GetInstance().LoadNextScene("Accounts/Scenes/ChangeUserScreen");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user