Skip to content
Snippets Groups Projects
Commit e902dffc authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

amélioration aléatoire

parent 23d95c30
No related branches found
No related tags found
No related merge requests found
...@@ -323,7 +323,7 @@ public class GD_manager : MonoBehaviour ...@@ -323,7 +323,7 @@ public class GD_manager : MonoBehaviour
if (mM.i.randomiser) 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.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
......
...@@ -108,7 +108,7 @@ public class QCM_manager : MonoBehaviour ...@@ -108,7 +108,7 @@ public class QCM_manager : MonoBehaviour
{ {
if (mM.i.randomiser) 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.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
mM.instancieAllChoixAtOnce(); mM.instancieAllChoixAtOnce();
......
...@@ -433,13 +433,30 @@ public class mainManager : MonoBehaviour ...@@ -433,13 +433,30 @@ public class mainManager : MonoBehaviour
for (int i = 0; i < list.Count; i++) 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]); shuffled.Add(temp[index]);
temp.RemoveAt(index); temp.RemoveAt(index);
} }
return shuffled; 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; private bool initialisationFirstEpreuve_EnCours = false;
public void nextEpreuve(bool initialisation=false) public void nextEpreuve(bool initialisation=false)
{ {
...@@ -982,7 +999,7 @@ public class mainManager : MonoBehaviour ...@@ -982,7 +999,7 @@ public class mainManager : MonoBehaviour
{ {
bannissementIsOver = false; bannissementIsOver = false;
nextEpreuve(true); nextEpreuve(true);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment