Theme selection screen

This commit is contained in:
lvrossem
2023-03-02 14:42:35 +01:00
parent 62ee8b9097
commit 49b91f062e
5 changed files with 244 additions and 603 deletions

View File

@@ -34,7 +34,8 @@ public class SpellingBeeController : MonoBehaviour {
// Start is called before the first frame update
void Start() {
themeList = ThemeLoader.loadJson();
currentTheme = themeList.themes[0];
currentTheme = findThemeByName(PlayerPrefs.GetString("themeName"));
words = currentTheme.words;
SetRandomWord();
@@ -60,6 +61,21 @@ public class SpellingBeeController : MonoBehaviour {
}
}
Theme findThemeByName(string themeName) {
int themeIndex = 0;
while (themeIndex < themeList.themes.Length) {
Theme theme = themeList.themes[themeIndex];
if (theme.name == themeName) {
return theme;
}
themeIndex++;
}
Debug.Log("Requested theme not found");
return null;
}
// Pick a new random word from words and initialize the needed variables
void SetRandomWord() {
currentIndex = 0;