Resolve WES-80 "Data"

This commit is contained in:
Helena Van Breugel
2023-03-18 22:32:36 +00:00
parent 8ff5c6c4c8
commit a19d89db03
1092 changed files with 18349 additions and 30118 deletions

View File

@@ -11,7 +11,8 @@ public partial class GameController : MonoBehaviour
/// <summary>
/// All of the words that can be used in this session
/// </summary>
private string[] words;
//private string[] words;
private List<Learnable> words = new List<Learnable>();
/// <summary>
/// Where we currently are in the word
@@ -31,7 +32,7 @@ public partial class GameController : MonoBehaviour
/// <summary>
/// All of the available themes
/// </summary>
private ThemeList themeList;
public ThemeList themeList;
/// <summary>
/// The theme we are currently using
@@ -197,6 +198,7 @@ public partial class GameController : MonoBehaviour
/// </summary>
public void Start()
{
words.Clear();
correctLetters = 0;
incorrectLetters = 0;
// We use -1 instead of 0 so SetNextWord can simply increment it each time
@@ -223,10 +225,8 @@ public partial class GameController : MonoBehaviour
DeleteWord();
// TODO: change to ScriptableObject
themeList = ThemeLoader.LoadJson();
currentTheme = FindThemeByName(PlayerPrefs.GetString("themeName"));
words = currentTheme.words;
currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex];
words.AddRange(currentTheme.learnables);
ShuffleWords();
SetNextWord();
}
@@ -283,7 +283,7 @@ public partial class GameController : MonoBehaviour
/// </summary>
private void ShuffleWords()
{
for (int i = words.Length - 1; i > 0; i--)
for (int i = words.Count - 1; i > 0; i--)
{
// Generate a random index between 0 and i (inclusive)
int j = UnityEngine.Random.Range(0, i + 1);
@@ -534,29 +534,6 @@ public partial class GameController : MonoBehaviour
timerValue += (float)seconds;
}
/// <summary>
/// Find the chosen theme by its name
/// </summary>
/// <param name="themeName">The name of the theme to find</param>
/// <returns>The requested theme</returns>
private 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;
}
/// <summary>
/// Display next word in the series
/// </summary>
@@ -564,11 +541,12 @@ public partial class GameController : MonoBehaviour
{
spelledWords++;
if (wordIndex < words.Length)
if (wordIndex < words.Count)
{
currentWord = words[wordIndex];
currentWord = words[wordIndex].name;
ChangeSprite(currentWord);
//ChangeSprite(currentWord);
DisplayWord(currentWord);
AddSeconds(currentWord.Length * secondsPerLetter + 1);
@@ -599,19 +577,7 @@ public partial class GameController : MonoBehaviour
TMP_Text txt = instance.GetComponentInChildren<TMP_Text>();
txt.text = Char.ToString(Char.ToUpper(word[i]));
}
}
/// <summary>
/// Change the image that is being displayed
/// </summary>
/// <param name="spriteName">Name of the new sprite</param>
private void ChangeSprite(string spriteName)
{
// Load the new sprite from the Resources folder
Sprite sprite = Resources.Load<Sprite>("SpellingBee/images/" + spriteName);
// Set the new sprite as the Image component's source image
wordImage.sprite = sprite;
wordImage.sprite = words[wordIndex].image;
}
/// <summary>