private void PlayAudioFeedbackAndSailAway(int audioIndex = 0) { if (assignmentElements.CorrectAudio.Count > audioIndex) { AudioLibraryClipPlayer correctAudio = assignmentElements.CorrectAudio[audioIndex]; if (correctAudio) { correctAudio.Play(.5f); correctAudio.Finished.AddListener(() => { correctAudio.Finished.RemoveAllListeners(); PlayAudioFeedbackAndSailAway(audioIndex + 1); } ); } else { PlayAudioFeedbackAndSailAway(audioIndex + 1); } } else { StartSailingToNextAssignment(); } }
protected override void OnButtonSelected(GazeButton b) { if (playingFeedbackAudio) { playingFeedbackAudio.Stop(); playingFeedbackAudio = default; } if (rightStars.Remove(b)) { // found one! if (assignmentElements.CorrectAudio.Count > 0) { SkipTurtle(); playingFeedbackAudio = assignmentElements.CorrectAudio.First(); playingFeedbackAudio?.Play(); assignmentElements.CorrectAudio.RemoveAt(0); } } else if (b.name.Contains("Wrong"))// found a wrong one, but don't want this sound when activating the turtle! { SkipTurtle(); assignmentElements.IncorrectAudio?.Play(); } // no more stars to find if (rightStars.Count == 0) { // found all! foundTimeline.Resume(); turtleTimeline.Seek(turtleTimeline.duration); // switch all correct stars off again foreach (GazeButton star in assignmentElements.CorrectButtons) { Image selected = star.GetComponentsInChildren <Image>().FirstOrDefault(i => i.gameObject.name == "Selected"); if (selected) { selected.enabled = false; } } // also disable all gazebuttons EnableAllGazeButtons(false); foundTimeline.paused += OnFoundTimelineComplete; context.SetAssignmentCompleted(); playingFeedbackAudio.Finished.AddListener( () => { playingFeedbackAudio.Finished.RemoveAllListeners(); playingFeedbackAudio = default; } ); } }
protected override void OnButtonSelected(GazeButton b) { if (Array.IndexOf(assignmentElements.CorrectButtons, b) > -1) { Debug.Log($"{this}: gazed at correct cloud {b}", b); HideAllGazeButtons(); AudioLibraryClipPlayer correctAudio = default; if (assignmentElements.CorrectAudio.Count > 0) { correctAudio = assignmentElements.CorrectAudio[0]; if (correctAudio) { turtleTimeline.Stop(); turtleTimeline.Seek(turtleTimeline.duration); correctAudio.Play(); correctAudio.Finished.AddListener(() => { correctAudio.Finished.RemoveAllListeners(); Next(); } ); } else { Next(); } } } else if (b.name.Contains("Wrong")) { if (assignmentElements.IncorrectAudio) { SkipTurtle(); assignmentElements.IncorrectAudio.Play(); Debug.Log($"{this}: gazed at wrong cloud", b); } } }
protected override void OnButtonSelected(GazeButton b) { // Debug.Log($"{this}: gaze button triggered {b.name}"); if (b.name.Contains("Wrong"))// found a wrong one, but don't want this sound when activating the turtle! { SkipTurtle(); assignmentElements.IncorrectAudio?.Play(); } else if (b.name.Contains("Correct")) { AudioLibraryClipPlayer correctAudio = default; done = true; // birds that are spawned now will not be enabled SetAllBirdsGazeButtons(false); turtleTimeline.Stop(); turtleTimeline.Seek(turtleTimeline.duration); if (assignmentElements.CorrectAudio.Count > 0) { correctAudio = assignmentElements.CorrectAudio[0]; if (correctAudio) { correctAudio.Play(); correctAudio.Finished.AddListener(() => { correctAudio.Finished.RemoveAllListeners(); Next(); } ); } } else { Next(); } } }