AudioFeedback.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //***********************************************************
  2. // Filename: AudioFeedback.cs
  3. // Author: Marco Fendrich, Moritz Kolvenbach
  4. // Last changes: Thursday, 9th of August 2018
  5. // Content: Handles the audio feedback during the trials
  6. //***********************************************************
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using UnityEngine;
  10. /// <summary>
  11. /// A class managing the audio cues throughout the experiment
  12. /// </summary>
  13. public class AudioFeedback : MonoBehaviour
  14. {
  15. // the sound being played on targetConfirmation
  16. public AudioSource targetAudio;
  17. // the sound being played when all targets of the current condition have been completed
  18. public AudioSource gameEndAudio;
  19. /// <summary>
  20. /// Registers the listeners for each event that triggers an audio cue
  21. /// </summary>
  22. void Start ()
  23. {
  24. TargetReachedEvent.RegisterListener(OnTargetConfirmation);
  25. ExperimentEndEvent.RegisterListener(OnExperimentEnd);
  26. }
  27. /// <summary>
  28. /// On target confirmation play sound
  29. /// </summary>
  30. /// <param name="trEv"> An event being triggerd whenever the player confirms a target</param>
  31. void OnTargetConfirmation(TargetReachedEvent trEv)
  32. {
  33. targetAudio.Play(0);
  34. }
  35. /// <summary>
  36. /// On experiment end play sound
  37. /// </summary>
  38. /// <param name="eeEv"> An event being triggerd when experiment is over</param>
  39. void OnExperimentEnd(ExperimentEndEvent eeEv)
  40. {
  41. gameEndAudio.Play(0);
  42. }
  43. }