void Start() { startTime = Time.time; Random.InitState(System.DateTime.Now.Millisecond); audioSource.volume = volumeScaler; foreach (var instrument in System.Enum.GetValues(typeof(InstrumentType))) { var request = ScriptableObject.CreateInstance <Request>(); request.instrumentType = (InstrumentType)instrument; request.maxTimeLeft = 10.0; request.timeLeft = request.maxTimeLeft; freeRequests.Add(request); } spawner = GetComponent <AudienceSpawner>(); while (members.Count < maxMemberCount) { AudienceMember newMember = spawner.TrySpawnMember(); if (newMember != null) { members.Add(newMember); freeMembers.Add(newMember); } } gameOverDisplay.enabled = false; restart.enabled = false; restart.gameObject.SetActive(false); for (int i = 0; i < restart.transform.childCount; i++) { restart.transform.GetChild(i).gameObject.SetActive(false); } }
public void DrawGizmosMember(AudienceMember member) { Gizmos.DrawWireSphere(member.transform.position, obstacleCheckRadius); }
/// <summary> /// Main method to recognize which view area the user is looking at /// Modified by Baptiste Germond /// </summary> public static void lookRecognizer() { //Using a counter so it won't go to much in the try/catch and make the software lag //It prevents the method to be executed if the face is not recognize if (count == 30 || faceDetected == true) { count = 0; int direction = 0; try { var temp = KinectDevice.skeletonFaceTracker.facePoints3D; try { faceDetected = true; var rightEye = temp.ElementAt(20); var leftEye = temp.ElementAt(53); //Test if the user is looking at the center area if (rightEye.Z - leftEye.Z >= -0.015 && rightEye.Z - leftEye.Z <= 0.015) { // add look center if (rec) { if (!lookCenter.Contains((int)(Tools.getStopWatch() / 100))) { lookCenter.Add((int)(Tools.getStopWatch() / 100)); } } /*If he just entered the zone (!centre) * and he is not just passing by to go to another area (countC > 4)*/ if (!centre && countC > 4) { addHistorical(CENTER); //Adding the center area to the historical boolManagement(CENTER); // Indicate that the user is looking at the center and reseting all counter } countC++; //Counter to know howlong the user is looking at the same view area direction = CENTER; } //Test if the user is looking at the right area else if (rightEye.Z - leftEye.Z >= -0.057 && rightEye.Z - leftEye.Z < -0.015) { // add look rigth if (rec) { if (!lookRight.Contains((int)(Tools.getStopWatch() / 100))) { lookRight.Add((int)(Tools.getStopWatch() / 100)); } } if (!right) { addHistorical(RIGHT); boolManagement(RIGHT); } countR++; direction = RIGHT; } //Test if the user is looking at the extrem right area else if (rightEye.Z - leftEye.Z < -0.057) { // add look ExtrRight if (rec) { if (!lookExtrRight.Contains((int)(Tools.getStopWatch() / 100))) { lookExtrRight.Add((int)(Tools.getStopWatch() / 100)); } } if (!extremRight) { addHistorical(RIGHT); boolManagement(EXTRIGHT); } countER++; direction = EXTRIGHT; } //Test if the user is looking at the left area else if (rightEye.Z - leftEye.Z > 0.015 && rightEye.Z - leftEye.Z <= 0.057) { // add look left if (rec) { if (!lookLeft.Contains((int)(Tools.getStopWatch() / 100))) { lookLeft.Add((int)(Tools.getStopWatch() / 100)); } } if (!left) { addHistorical(LEFT); boolManagement(LEFT); } countL++; direction = LEFT; } else if (rightEye.Z - leftEye.Z > 0.057) { // add look ExtrLeft if (rec) { if (!lookExtrLeft.Contains((int)(Tools.getStopWatch() / 100))) { lookExtrLeft.Add((int)(Tools.getStopWatch() / 100)); } } if (!extremLeft) { addHistorical(LEFT); boolManagement(EXTLEFT); } countEL++; direction = EXTLEFT; } if (GeneralSideTool.Get().AudienceControlCheckBox.IsChecked == true) { AudienceMember.updateAudienceInterest(direction); } //If the user is still looking at the same view area and if the counter reached the limit if (centre && countC > limitHigh) { int lessUsed = countInHistorical(RIGHT, LEFT); //We decide which was less used between the two other areas updateFeedback(lessUsed); //We display the feedback to notifie the user that he should look at another area feedbackActive = true; } else if (right && countR > limitHigh) { int lessUsed = countInHistorical(CENTER, LEFT); updateFeedback(lessUsed); feedbackActive = true; } else if (extremRight && countER > limitLow) { int lessUsed = countInHistorical(CENTER, LEFT); updateFeedback(lessUsed); feedbackActive = true; } else if (left && countL > limitHigh) { int lessUsed = countInHistorical(CENTER, RIGHT); updateFeedback(lessUsed); feedbackActive = true; } else if (extremLeft && countEL > limitLow) { int lessUsed = countInHistorical(CENTER, RIGHT); updateFeedback(lessUsed); feedbackActive = true; } else { //Value very different from the others which means that all feedback should be deactivate updateFeedback(-100); feedbackActive = false; } if (rec) { if (feedbackActive) { lookingDirectionRecord.Add(Tools.getStopWatch() / 1000.0, 1); } else { lookingDirectionRecord.Add(Tools.getStopWatch() / 1000.0, 0); } } } catch (System.ArgumentException) { faceDetected = false; } } catch (NullReferenceException) { faceDetected = false; } } else { count++; } }
public IEnumerator SetAnim(AudienceMember watcher, float interest) { yield return(new WaitForSeconds(UnityEngine.Random.Range(0, 5.0f))); watcher.SetInterest(interest); }