This commit is contained in:
Jelle De Geest
2023-05-24 21:08:16 +02:00
parent 2a172bdb28
commit 163eb40c0f
1052 changed files with 20520 additions and 17253 deletions

View File

@@ -1,11 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
/// <summary>
/// Class to handle panel with multiple choice options
/// </summary>
public class PanelMultipleChoice : MonoBehaviour
{
/// <summary>
@@ -95,15 +98,21 @@ public class PanelMultipleChoice : MonoBehaviour
/// <returns></returns>
public List<Learnable> GetWrongOptions(int notThisIndex)
{
List<Learnable> randomSigns = new List<Learnable>();
// TODO: find more koosjer way to do this
while (randomSigns.Count < 3)
var test = progress.learnables.FindAll((l) => l.index != notThisIndex && l.inUse);
for (int i = test.Count - 1; i > 0; i--)
{
int index = progress.GetRandomLearnable().index;
if (index != notThisIndex && !randomSigns.Contains(signs[index]))
{
randomSigns.Add(signs[index]);
}
// Generate a random index between 0 and i (inclusive)
int j = UnityEngine.Random.Range(0, i + 1);
// Swap the values at indices i and j
(test[j], test[i]) = (test[i], test[j]);
}
List<Learnable> randomSigns = new List<Learnable>();
foreach (var sign in test.Take(3))
{
randomSigns.Add(signs[sign.index]);
}
return randomSigns;
@@ -145,7 +154,6 @@ public class PanelMultipleChoice : MonoBehaviour
}
});
}
}
/// <summary>
@@ -204,13 +212,11 @@ public class PanelMultipleChoice : MonoBehaviour
playButton.sprite = pauseSprite;
videoPlayer.Play();
}
else
{
// Pause video and and switch sprite of button
playButton.sprite = playSprite;
videoPlayer.Pause();
}
}
}