diff --git a/Assets/GD_manager.cs b/Assets/GD_manager.cs index 87cb38afc421a0903b53e3ab99c330f797fa0141..cc9786e9cc33474aa1ce17bf9b165230aafcbea2 100644 --- a/Assets/GD_manager.cs +++ b/Assets/GD_manager.cs @@ -18,6 +18,7 @@ public class GD_manager : MonoBehaviour sequenceDeDropZones = new List<dropZoneGD>(); toucherLesCHoixGDActif = false; reussiteItem = false; + explanationSoundFinishedBool = false; } public void toucherLesChoix() @@ -272,7 +273,7 @@ public class GD_manager : MonoBehaviour } if (mM.executeAsset(mM.e.fond, null, true, true)) { - Debug.Log("on refait apparaitre image pricnipale"); + //Debug.Log("on refait apparaitre image pricnipale"); if (mM.posScript.currentlyInstanciatedImageEpreuveCentered != null) { mM.posScript.currentlyInstanciatedImageEpreuveCentered.gameObject.SetActive(true); @@ -281,6 +282,7 @@ public class GD_manager : MonoBehaviour } // consigne de l'épreuve (absente du déroulement) if (!mM.epreuveConsignebeenPlayed) { + //Debug.Log("on joue la consigne d'epreuve qui n'a encore jamais été jouée"); mM.texteCheat.text += " /Epreuve id=" + mM.e.id; mM.epreuveConsignebeenPlayed = true; mM.executeAsset(mM.e.consigne, mM.playSteps,false); // consigne de l'épreuve (absente du déroulement) @@ -360,10 +362,10 @@ public class GD_manager : MonoBehaviour } break; case 4: // EXPLICATION (présent dans le déroulement) equivalent au step 5 dans item_gd - Debug.Log("EXPLICATION"); + //Debug.Log("EXPLICATION"); if (mM.i.type == "tuto") { - Debug.Log("mM.i.surlignerExplication="+ mM.i.surlignerExplication); + //Debug.Log("mM.i.surlignerExplication="+ mM.i.surlignerExplication); if (mM.i.surlignerExplication >= 0.0f) { foreach (dropZoneGD b in sequenceDeDropZones) @@ -372,7 +374,7 @@ public class GD_manager : MonoBehaviour { if (b2.elementGDAssocied != null && ((b2.choix.id!=null && b.choix.id !=null && b2.choix.id == b.choix.id) || (b2.choix.son!=null && b.choix.son!=null && b2.choix.son == b.choix.son))) { - Debug.Log("mouvement commence"); + //Debug.Log("mouvement commence"); StartCoroutine(b2.elementGDAssocied.GoingToDropZone(1.0f, b.trans.position, b2.choix.numZone, explanationGDDemoFinished)); break; } diff --git a/Assets/QCM_manager.cs b/Assets/QCM_manager.cs index 5273a80a03462762bff832c8d05aa088c9b8b331..3f9728497d519ef8bdf42dd3e92317fd22586486 100644 --- a/Assets/QCM_manager.cs +++ b/Assets/QCM_manager.cs @@ -33,7 +33,7 @@ public class QCM_manager : MonoBehaviour mM.sessionConsignebeenPlayed = true; if (mM.executeAsset(mM.s.consigne, null, true)) { - Debug.Log("on refait apparaitre image principale de session"); + //Debug.Log("on refait apparaitre image principale de session"); mM.posScript.currentlyInstanciatedprefabImagePrincipale.gameObject.SetActive(true); } // consigne de la session (absente du déroulement) if(mM.executeAsset(mM.s.consigne, mM.playSteps, false)) @@ -45,7 +45,7 @@ public class QCM_manager : MonoBehaviour else { playswitch = true; } break; case 1: - Debug.Log("on destroy image principale"); + //Debug.Log("on destroy image principale"); mM.oreilleListen.SetActive(false); if (mM.posScript.currentlyInstanciatedprefabImagePrincipale != null) { @@ -53,7 +53,7 @@ public class QCM_manager : MonoBehaviour } if (mM.executeAsset(mM.e.fond, null, true,true)) { - Debug.Log("on refait apparaitre image principale d'epreuve"); + //Debug.Log("on refait apparaitre image principale d'epreuve"); if (mM.posScript.currentlyInstanciatedImageEpreuveCentered != null) { mM.posScript.currentlyInstanciatedImageEpreuveCentered.gameObject.SetActive(true); @@ -62,6 +62,8 @@ public class QCM_manager : MonoBehaviour } // consigne de l'épreuve (absente du déroulement) if (!mM.epreuveConsignebeenPlayed) { + //Debug.Log("on joue la consigne d'epreuve qui n'a encore jamais été jouée"); + mM.texteCheat.text += "\nEpreuve id=" + mM.e.id; mM.epreuveConsignebeenPlayed = true; if(mM.executeAsset(mM.e.consigne, mM.playSteps, false)) @@ -112,7 +114,7 @@ public class QCM_manager : MonoBehaviour } else { - Debug.Log("QCM error no image to display this item, lets go to the next one"); + //Debug.Log("QCM error no image to display this item, lets go to the next one"); mM.current_step = 10; } break; @@ -128,7 +130,7 @@ public class QCM_manager : MonoBehaviour { if (b.choix.correct) { - Debug.Log("choix correct explication doit clignoter i.surlignerExplication=" + mM.i.surlignerExplication); + //Debug.Log("choix correct explication doit clignoter i.surlignerExplication=" + mM.i.surlignerExplication); b.boutonqcmAssocied.clignote(mM.i.surlignerExplication); } } @@ -212,7 +214,7 @@ public class QCM_manager : MonoBehaviour { mM.scoreItem = 0; } - Debug.Log("mM.c.id=" + mM.c.id+ " mM.c.son="+ mM.c.son); + //Debug.Log("mM.c.id=" + mM.c.id+ " mM.c.son="+ mM.c.son); if (mM.c.id != null && mM.c.id.Length>0) { mM.user_choix = mM.c.id; @@ -226,7 +228,7 @@ public class QCM_manager : MonoBehaviour Destroy(cc.boutonqcmAssocied.gameobj); } mM.list_choix_associed_with_prefabs.Clear(); - Debug.Log("object clicked"); + //Debug.Log("object clicked"); mM.playSteps(); // on lance le feedback } diff --git a/Assets/mainManager.cs b/Assets/mainManager.cs index c705d9e09567c5501a0fa026a6adcc3619a988ac..f2973d0cf921a32e1283567d82c70a02312e6ff1 100644 --- a/Assets/mainManager.cs +++ b/Assets/mainManager.cs @@ -98,6 +98,33 @@ public class mainManager : MonoBehaviour private void resetItem() { gameObjFin.SetActive(false); + StopAllCoroutines(); + if (list_choix_associed_with_prefabs != null) + { + foreach (groupemementChoixEtPrefabBoutonQCM gc in list_choix_associed_with_prefabs) + { + if (gc != null) + { + if (gc.elementGDAssocied != null) + { + gc.elementGDAssocied.StopAllCoroutines(); + Destroy(gc.elementGDAssocied.gameobj); + } + if (gc.elementDropZoneAssocied != null) + { + gc.elementDropZoneAssocied.StopAllCoroutines(); + Destroy(gc.elementDropZoneAssocied.gameobj); + } + if (gc.boutonqcmAssocied != null) + { + gc.boutonqcmAssocied.StopAllCoroutines(); + Destroy(gc.boutonqcmAssocied.gameobj); + } + } + } + } + + epreuveitemscurrentSet = false; if (posScript.currentlyInstanciatedprefabImagePrincipale != null) { Destroy(posScript.currentlyInstanciatedprefabImagePrincipale.gameObject); @@ -217,6 +244,11 @@ public class mainManager : MonoBehaviour private List<EpreuveItem> epreuvesitemsCurrent; public void playSteps() { + + if (texteCheat.text.Length > 300) + { + texteCheat.text = texteCheat.text.Substring(150); + } // boutonnext cheat if (boutonCheatNext) { @@ -232,41 +264,67 @@ public class mainManager : MonoBehaviour if (!epreuveitemscurrentSet) { - Debug.Log("A"); epreuvesitemsCurrent = e.items; //int rand = UnityEngine.Random.Range(-1, 2); - epreuvesitemsCurrent.Sort((a, b) => UnityEngine.Random.Range(-1, 2)); - epreuveitemscurrentSet = true; - if(e.nbItemsMax == 0) + if (epreuvesitemsCurrent == null) { - e.nbItemsMax = e.items.Count; - Debug.Log("B"); + Debug.LogError("this item is null "); + endItem(); + } + else + { + epreuvesitemsCurrent = ShuffleList(epreuvesitemsCurrent); + epreuveitemscurrentSet = true; + if (e.nbItemsMax == 0) + { + e.nbItemsMax = e.items.Count; + } } - Debug.Log("C" + e.nbItemsMax); + } - i = epreuvesitemsCurrent[currentItem]; - - if (e.modalite == "GD") + if (epreuvesitemsCurrent != null) { - gdmanager.playStepsGD(); + i = epreuvesitemsCurrent[currentItem]; + + if (e.modalite == "GD") + { + gdmanager.playStepsGD(); + } + else if (e.modalite == "QCM") + { + qcmmanager.playStepsQCM(); + } } - else if (e.modalite == "QCM") + + } + + public List<EpreuveItem> ShuffleList(List<EpreuveItem> list) + { + List<EpreuveItem> temp = new List<EpreuveItem>(); + List<EpreuveItem> shuffled = new List<EpreuveItem>(); + temp.AddRange(list); + + for (int i = 0; i < list.Count; i++) { - qcmmanager.playStepsQCM(); + int index = UnityEngine.Random.Range(0, temp.Count - 1); + shuffled.Add(temp[index]); + temp.RemoveAt(index); } + + return shuffled; } + public void endItem() { if (posScript.currentlyInstanciatedImageEpreuveCentered != null) { Destroy(posScript.currentlyInstanciatedImageEpreuveCentered.gameObject); } - Debug.Log("currentItem=" + currentItem + " e.nbItemsMax=" + e.nbItemsMax); - if ((currentItem >= epreuvesitemsCurrent.Count - 1) ||(currentItem>=e.nbItemsMax-1) ) + + if (epreuvesitemsCurrent == null || (currentItem >= epreuvesitemsCurrent.Count - 1) ||(currentItem>=e.nbItemsMax-1) ) { - Debug.Log("end"); // pas d'autre liste d'items dans cette epreuve // on regarde s'il y a une autre epreuve dans la même session à lancer if (currentEpreuve >= s.epreuves.Count - 1) @@ -278,11 +336,8 @@ public class mainManager : MonoBehaviour { currentItem = 0; currentEpreuve++; - epreuveitemscurrentSet = false; epreuveConsignebeenPlayed = false; current_step = -1; - - resetItem(); playSteps(); } @@ -419,6 +474,7 @@ public class mainManager : MonoBehaviour public void makeEachChoiceClignoteOneAfterTheOther() { + Debug.Log("makeEachChoiceClignoteOneAfterTheOther"); if (currentChoix > 0) { list_choix_associed_with_prefabs[currentChoix - 1].boutonqcmAssocied.stopClignote(); @@ -442,7 +498,7 @@ public class mainManager : MonoBehaviour } if (i.enumerer) { - if (currentChoix == (list_choix_associed_with_prefabs.Count - 1)) + if (currentChoix == (list_choix_associed_with_prefabs.Count)) { dernierChoixAudioclip = groupe.choix.son; executeAsset(i.separateurChoix, lireDernierChoixWhenAllAreInstanciated, false); @@ -504,7 +560,7 @@ public class mainManager : MonoBehaviour } if (i.enumerer) { - if (currentChoix == (list_choix_associed_with_prefabs.Count - 1)) + if (currentChoix == (list_choix_associed_with_prefabs.Count)) { dernierChoixAudioclip = groupe.choix.son; executeAsset(i.separateurChoix, lireDernierChoix, false); @@ -593,9 +649,11 @@ public class mainManager : MonoBehaviour currentItem = 0; currentEpreuve=0; currentSession++; + scoreSession = 0; + sessionConsignebeenPlayed = false; epreuveConsignebeenPlayed = false; current_step = -1; - + playerTurn = false; playSteps(); gameObjFin.SetActive(false);