void Update() { //If all BodyParts are SnappedIn if ((snapCounter == numPieces) && (temp2 == false)) { Debug.Log("BEGIN PEC MODE"); //scriptLog.file.WriteLine("\n"+System.DateTime.Now.ToString("hh:mm:ss")+" Pec Mode starts"); bodyMatchMode = false; //Switchs mode PECCards.SetActive(true); //Turns on all PECCards pause.SetActive(true); headOutline.SetActive(false); //Turns HeadOutline off to not be in the way of the PECPLACEHOLDER temp2 = true; //To prevent loop pecStarted = true; //Log purpose in Zzero //string csvfile="C:\\Users\\user\\Desktop\\cloud.csv"; //StringBuilder csvcontent=new StringBuilder(); //csvcontent.AppendLine("\nPec Started\n"); //File.AppendAllText(csvfile,csvcontent.ToString()); } //If both objects in the Match array are filled if (match[0] != null && match[1] != null) { //If both object in the Match array have the same name if ((match[0].name == match[1].name) && match[0].name == correctPec.name) /*ADD MATCHES THE CORRECT FACE FOR THE LEVEL*/ //Starts PecCard part of the Game { Debug.Log("CONTINUE"); if (firstTime) { source.PlayOneShot(clapping); //Play Clapping Audio smokeEffect.SetActive(true); //Starts the SmokeEffect firstTime = false; placeHolders[0].gameObject.SetActive(false); placeHolders[1].gameObject.SetActive(false); faceTrackingManager.sendToCsv(); StartCoroutine(wait()); //Wait 3 Secs to activate model and deactivate Parts,PEC Card; } } //When the Players choice for PecParts are incorrect, will reset pieces. else { Debug.Log("RESTART"); scriptLog.file.WriteLine(System.DateTime.Now.ToString("hh:mm:ss") + " Incorret PEC restarts, attempts: " + attempt); attempt++; //Increases the # of attempts source.PlayOneShot(boing); //Plays SFX when incorrect //Sets PEC cards back to there original positions match[0].gameObject.transform.position = match[0].gameObject.GetComponent <Zzero>().origin; match[0].gameObject.GetComponent <Zzero>().IsSnapped = false; match[1].gameObject.transform.position = match[1].gameObject.GetComponent <Zzero>().origin; match[1].gameObject.GetComponent <Zzero>().IsSnapped = false; placeHolders[0].SetActive(true); placeHolders[1].SetActive(true); //Sets the Array set function to true so function can repeate multiple times. //Resets First Element in the PlaceHolders Array //if (placeHolders[0].gameObject.tag == "P1"){ /*Change to "placeHolders[0].gameObject.CompareTag("P1")*/ placeHolders[0].gameObject.GetComponent <PecMatch1>().arraySet = true; placeHolders[0].gameObject.GetComponent <PecMatch1>().occupied = false; // } //else if (placeHolders[0].gameObject.tag == "P2"){ /*Change to "placeHolders[0].gameObject.CompareTag("P2")*/ // placeHolders[0].gameObject.GetComponent<PecMatch1>().arraySet = true; // placeHolders[0].gameObject.GetComponent<PecMatch1>().occupied = false; // } //Resets Second Element in the PlaceHolders Array //if (placeHolders[1].gameObject.tag == "P1"){ /*Change to "placeHolders[0].gameObject.CompareTag("P1")*/ placeHolders[1].gameObject.GetComponent <PecMatch1>().arraySet = true; placeHolders[1].gameObject.GetComponent <PecMatch1>().occupied = false; //} // else if (placeHolders[1].gameObject.tag == "P2"){ /*Change to "placeHolders[0].gameObject.CompareTag("P1")*/ //placeHolders[1].gameObject.GetComponent<PecMatch1>().arraySet = true; // placeHolders[1].gameObject.GetComponent<PecMatch1>().occupied = false; //} //Loops throu the DraggableObjects array in the GrabScript and places the PecPart back into the DraggableObjects array for (int i = 0; i < grabScript.draggableObjects.Length; i++) { /*Change if statement tag compare to "grabScript.draggableObjects[i].CompareTag("Junk")*/ if (grabScript.draggableObjects[i].tag == "Junk") //If draggableObjects[i] is an EmptyObject { if (match[0] != null) //If the First Element in the Match Array is not NULL { grabScript.draggableObjects[i] = match[0]; //Places PecPart back into draggableObjects Array match[0] = null; } else if (match[1] != null) //If the Second Element in the Match Array is not NULL { grabScript.draggableObjects[i] = match[1]; //Places PecPart back into draggableObjects Array match[1] = null; } } } } } }