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

Merge branch 'main' into sampleData

parents 2836776f de463a28
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,32 @@ public class ChargementJSONStructure : MonoBehaviour
public List<Session> sessions;
}
public bool checkifitemexists(string assetname, bool checkofimgpath)
{
if (data.assets.ContainsKey(assetname))
{
if (checkofimgpath && data.assets[assetname].img_path != null)
{
Sprite image = Resources.Load<Sprite>(data.assets[assetname].img_path);
if(image != null)
{
return true;
}
}
else if(data.assets[assetname].snd_path != null)
{
AudioClip aud = Resources.Load<AudioClip>(data.assets[assetname].snd_path);
if(aud != null)
{
return true;
}
}
}
return false;
}
public void chargeJsonStructure()
{
// Chargement du fichier JSON depuis le dossier "Assets"
......
......@@ -107,7 +107,7 @@ public class GD_manager : MonoBehaviour
oneElementIsMoving.dropZOneWhereItsCurrentlyPlaced = currentLandingZoneRolledOver;
currentLandingZoneRolledOver.elementgdActuellementOnIt = oneElementIsMoving;
currentLandingZoneRolledOver.occupied = true;
if (currentLandingZoneRolledOver.choix.son == oneElementIsMoving.choix.son)
if ((currentLandingZoneRolledOver.choix.id != null && oneElementIsMoving.choix.id != null && currentLandingZoneRolledOver.choix.id == oneElementIsMoving.choix.id) || (currentLandingZoneRolledOver.choix.son!=null && oneElementIsMoving.choix.son!=null && currentLandingZoneRolledOver.choix.son == oneElementIsMoving.choix.son))
{
// bonne rponse les sons sont les mmes
oneElementIsMoving.transform.localPosition = currentLandingZoneRolledOver.transform.localPosition;
......@@ -199,9 +199,16 @@ public class GD_manager : MonoBehaviour
//Debug.Log("suite pas encore termine et non reussie!");
}
mM.playerTurn = false;
mM.user_choix = mM.c.son;
if(mM.c.id != null)
{
mM.user_choix = mM.c.id;
}
else if (mM.c.son != null)
{
mM.user_choix = mM.c.son;
}
//Debug.Log("playSteps final GD");
mM.playSteps(); // on lance le feedback
......@@ -303,12 +310,11 @@ public class GD_manager : MonoBehaviour
mM.list_choix_associed_with_prefabs = new List<groupemementChoixEtPrefabBoutonQCM>();
foreach (Choix ccc in mM.i.choix)
{
if (ccc.son != null && ccc.son.Length > 0)
if (((ccc.id != null && ccc.id.Length > 0) || (ccc.son != null && ccc.son.Length > 0)) && mM.jsonStructureScript.checkifitemexists(ccc.image,true))
{
groupemementChoixEtPrefabBoutonQCM q = new groupemementChoixEtPrefabBoutonQCM();
q.choix = ccc;
mM.list_choix_associed_with_prefabs.Add(q);
}
else
{
......@@ -316,37 +322,48 @@ public class GD_manager : MonoBehaviour
}
}
if (mM.i.randomiser)
{
mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2));
}
mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
int indexdropzone = 0;
int indexgdel = 0;
foreach (groupemementChoixEtPrefabBoutonQCM gcpq in mM.list_choix_associed_with_prefabs)
if (mM.list_choix_associed_with_prefabs.Count > 0)
{
gcpq.boutonqcmAssocied = gcpq.elementGDAssocied = mM.posScript.placeImages(indexgdel, gcpq.choix).GetComponent<elementGD>();
if (gcpq.choix.numZone > 0)
if (mM.i.randomiser)
{
gcpq.elementDropZoneAssocied = mM.posScript.placeImages(indexdropzone, gcpq.choix, true).GetComponent<dropZoneGD>();
indexdropzone++;
mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2));
}
mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
int indexdropzone = 0;
int indexgdel = 0;
foreach (groupemementChoixEtPrefabBoutonQCM gcpq in mM.list_choix_associed_with_prefabs)
{
gcpq.boutonqcmAssocied = gcpq.elementGDAssocied = mM.posScript.placeImages(indexgdel, gcpq.choix).GetComponent<elementGD>();
if (gcpq.choix.numZone > 0)
{
gcpq.elementDropZoneAssocied = mM.posScript.placeImages(indexdropzone, gcpq.choix, true).GetComponent<dropZoneGD>();
indexdropzone++;
}
indexgdel++;
}
if (indexdropzone == 0)
{
enditemToBeLaunched = true;
// probleme, cet item est invalide car aucune dropzone ne peut etre placee
}
else
{
// c'est bon on continue
if (mM.i.type == "tuto")
{
mM.executeAsset(mM.i.toucherLesChoix, toucherLesChoix, false); // consigne de l'item (prsent dans le droulement)
}
else { playswitch = true; }
}
indexgdel++;
}
if (indexdropzone == 0)
{
enditemToBeLaunched = true;
// probleme, cet item est invalide car aucune dropzone ne peut etre placee
}
else
{
// c'est bon on continue
if (mM.i.type == "tuto")
{
mM.executeAsset(mM.i.toucherLesChoix, toucherLesChoix, false); // consigne de l'item (prsent dans le droulement)
}
else { playswitch = true; }
Debug.Log("GD error no image to display this item, lets go to the next one");
mM.current_step = 10;
}
break;
case 4: // EXPLICATION (prsent dans le droulement) equivalent au step 5 dans item_gd
......@@ -360,7 +377,7 @@ public class GD_manager : MonoBehaviour
{
foreach (groupemementChoixEtPrefabBoutonQCM b2 in mM.list_choix_associed_with_prefabs)
{
if (b2.elementGDAssocied != null && b2.choix.son == b.choix.son)
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");
StartCoroutine(b2.elementGDAssocied.GoingToDropZone(1.0f, b.trans.position, b2.choix.numZone, explanationGDDemoFinished));
......@@ -397,7 +414,16 @@ public class GD_manager : MonoBehaviour
mM.user_choixPossibles = new string[mM.i.choix.Count];
for (int indexi = 0; indexi < mM.i.choix.Count; indexi++)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].son;
if (mM.i.choix[indexi].id != null)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].id;
}
else if (mM.i.choix[indexi].son != null)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].son;
}
}
if (mM.i.type == "tuto" && mM.i.miseEnAction != null && mM.i.miseEnAction.Length > 0)
{ mM.executeAsset(mM.i.miseEnAction, mM.playerturnnow, false); }
......@@ -444,7 +470,15 @@ public class GD_manager : MonoBehaviour
{
if (cc.elementDropZoneAssocied != null)
{
mM.user_choix_ChoisiDansLordre[indexzone] = cc.choix.son;
if (cc.choix.id != null)
{
mM.user_choix_ChoisiDansLordre[indexzone] = cc.choix.id;
}
else if (cc.choix.son != null)
{
mM.user_choix_ChoisiDansLordre[indexzone] = cc.choix.son;
}
indexzone++;
}
}
......
......@@ -86,7 +86,7 @@ public class QCM_manager : MonoBehaviour
mM.list_choix_associed_with_prefabs = new List<groupemementChoixEtPrefabBoutonQCM>();
foreach (Choix ccc in mM.i.choix)
{
if (ccc.son != null && ccc.son.Length > 0)
if (((ccc.id != null && ccc.id.Length > 0) || (ccc.son != null && ccc.son.Length > 0))&& mM.jsonStructureScript.checkifitemexists(ccc.image,true))
{
groupemementChoixEtPrefabBoutonQCM q = new groupemementChoixEtPrefabBoutonQCM();
q.choix = ccc;
......@@ -99,14 +99,21 @@ public class QCM_manager : MonoBehaviour
}
}
if (mM.i.randomiser)
if(mM.list_choix_associed_with_prefabs.Count > 0)
{
mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2));
if (mM.i.randomiser)
{
mM.list_choix_associed_with_prefabs.Sort((a, b) => UnityEngine.Random.Range(-1, 2));
}
mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
mM.instancieAndPlayCHoix();
}
else
{
Debug.Log("QCM error no image to display this item, lets go to the next one");
mM.current_step = 10;
}
mM.posScript.CalculateAlignment(mM.list_choix_associed_with_prefabs);
mM.instancieAndPlayCHoix();
break;
case 4: // EXPLICATION (prsent dans le droulement)
if (mM.i.type == "tuto" && mM.i.explication != null && mM.i.explication.Length > 0)
......@@ -134,7 +141,15 @@ public class QCM_manager : MonoBehaviour
mM.user_choixPossibles = new string[mM.i.choix.Count];
for (int indexi = 0; indexi < mM.i.choix.Count; indexi++)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].son;
if (mM.i.choix[indexi].id != null)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].id;
}
else if (mM.i.choix[indexi].son!=null)
{
mM.user_choixPossibles[indexi] = mM.i.choix[indexi].son;
}
}
if (mM.i.type == "tuto" && mM.i.miseEnAction != null && mM.i.miseEnAction.Length > 0)
{ mM.executeAsset(mM.i.miseEnAction, mM.playerturnnow,false); }
......
......@@ -119,6 +119,7 @@ public class mainManager : MonoBehaviour
private ChargementJSONStructure.Asset checkAssetValidity(string id)
{
Debug.Log("checkAssetValidity");
if (id != null && id.Length > 0)
{
ChargementJSONStructure.Asset a = returnA(id);
......@@ -132,6 +133,7 @@ public class mainManager : MonoBehaviour
public bool executeAsset(string id, Action mafonction, bool img=false)
{
Debug.Log("executeAsset " + id);
bool anAssetSoundExists = false;
if(id!=null && id.Length>0)
{
......@@ -180,10 +182,19 @@ public class mainManager : MonoBehaviour
public void flecheReadyDisplayed()
{
playerTurn = true;
posScript.currentlyInstanciatedprefabImagePrincipale.gameObject.SetActive(true);
Debug.Log("flecheReadyDisplayed playerTurn=" + playerTurn);
// le son ready a bien t jou, on attends que le joueur clic sur la fleche ready.
if (posScript.currentlyInstanciatedprefabImagePrincipale != null)
{
playerTurn = true;
// le son ready a bien t jou, on attends que le joueur clic sur la fleche ready.
posScript.currentlyInstanciatedprefabImagePrincipale.gameObject.SetActive(true);
}
else
{
flecheReadyBeenClicked();
}
}
public void flecheReadyBeenClicked()
{
......@@ -357,13 +368,14 @@ public class mainManager : MonoBehaviour
else
{
groupemementChoixEtPrefabBoutonQCM groupe = list_choix_associed_with_prefabs[currentChoix];
GameObject ggg = posScript.placeImages(currentChoix, groupe.choix);
if (e.modalite == "GD")
{
groupe.boutonqcmAssocied = groupe.elementGDAssocied = posScript.placeImages(currentChoix, groupe.choix).GetComponent<elementGD>();
groupe.boutonqcmAssocied = groupe.elementGDAssocied = ggg.GetComponent<elementGD>();
}
else
{
boutonQCM b = posScript.placeImages(currentChoix, groupe.choix).GetComponent<boutonQCM>();
boutonQCM b = ggg.GetComponent<boutonQCM>();
list_choix_associed_with_prefabs[currentChoix].boutonqcmAssocied = b;
}
......@@ -379,11 +391,11 @@ public class mainManager : MonoBehaviour
if (currentChoix == (list_choix_associed_with_prefabs.Count - 1))
{
dernierChoixAudioclip = groupe.choix.son;
executeAsset(i.separateurChoix, lireDernierChoix,false);
executeAsset(i.separateurChoix, lireDernierChoix, false);
}
else
{
executeAsset(groupe.choix.son, instancieAndPlayCHoix,false);
executeAsset(groupe.choix.son, instancieAndPlayCHoix, false);
}
}
......@@ -391,6 +403,7 @@ public class mainManager : MonoBehaviour
{
StartCoroutine(justWaitOneFrameBeforeLaunchingFunction(instancieAndPlayCHoix));
}
}
else
{
......
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