Fixed course freezing and other course-ending bugs
This commit is contained in:
@@ -4,6 +4,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Video;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
public class PanelMultipleChoice : MonoBehaviour
|
||||
@@ -95,15 +96,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;
|
||||
|
||||
Reference in New Issue
Block a user