diff --git a/Assets/GD_manager.cs b/Assets/GD_manager.cs index dea2251ce7a8908d2e45113ce2aa1f9f93cdc630..c2e9bceca5384af5fd969d7b67532c0c939f030a 100644 --- a/Assets/GD_manager.cs +++ b/Assets/GD_manager.cs @@ -323,7 +323,7 @@ public class GD_manager : MonoBehaviour if (mM.i.randomiser) { - mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2)); + mM.list_choix_associed_with_prefabs = mM.ShuffleItems(mM.list_choix_associed_with_prefabs); } mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs); diff --git a/Assets/QCM_manager.cs b/Assets/QCM_manager.cs index 3fd3f4ea453702419b0785f8082f0d5b2cc90d7f..143e36725573a5a0b1ec0e18423a5a5ae29762f1 100644 --- a/Assets/QCM_manager.cs +++ b/Assets/QCM_manager.cs @@ -108,7 +108,7 @@ public class QCM_manager : MonoBehaviour { if (mM.i.randomiser) { - mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2)); + mM.list_choix_associed_with_prefabs = mM.ShuffleItems(mM.list_choix_associed_with_prefabs); } mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs); mM.instancieAllChoixAtOnce(); diff --git a/Assets/mainManager.cs b/Assets/mainManager.cs index a87e3a2336c90d4d3bf0fb04216172b0a8c71562..d5594c3de3480296ec52d79608a0e66ac25b8ec7 100644 --- a/Assets/mainManager.cs +++ b/Assets/mainManager.cs @@ -433,13 +433,30 @@ public class mainManager : MonoBehaviour for (int i = 0; i < list.Count; i++) { - int index = UnityEngine.Random.Range(0, temp.Count - 1); + int index = UnityEngine.Random.Range(0, temp.Count); shuffled.Add(temp[index]); temp.RemoveAt(index); } return shuffled; } + + public List<groupemementChoixEtPrefabBoutonQCM> ShuffleItems(List<groupemementChoixEtPrefabBoutonQCM> list) + { + List<groupemementChoixEtPrefabBoutonQCM> temp = new List<groupemementChoixEtPrefabBoutonQCM>(); + List<groupemementChoixEtPrefabBoutonQCM> shuffled = new List<groupemementChoixEtPrefabBoutonQCM>(); + temp.AddRange(list); + + for (int i = 0; i < list.Count; i++) + { + int index = UnityEngine.Random.Range(0, temp.Count); + shuffled.Add(temp[index]); + temp.RemoveAt(index); + } + + return shuffled; + } + private bool initialisationFirstEpreuve_EnCours = false; public void nextEpreuve(bool initialisation=false) { @@ -982,7 +999,7 @@ public class mainManager : MonoBehaviour { bannissementIsOver = false; nextEpreuve(true); - + } } }