Sprint 6
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user