ConditionManager.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using Routes;
  3. using Sensors;
  4. using SicknessReduction.Haptic;
  5. using SicknessReduction.Visual.DoF;
  6. using SicknessReduction.Visual.Vignetting;
  7. using UnityEngine;
  8. namespace Study
  9. {
  10. public enum SicknessMeasure
  11. {
  12. Vignetting,
  13. DepthOfField,
  14. VirtualHelmet,
  15. Fan,
  16. Vibration,
  17. None
  18. }
  19. [Serializable]
  20. public struct Condition
  21. {
  22. public int routeNumber;
  23. public SicknessMeasure activeMeasure;
  24. }
  25. public class ConditionManager : MonoBehaviour
  26. {
  27. [Header("Game Objects")] public RouteManager routeManager;
  28. public DynamicVignetting dynamicVignetting;
  29. public DynamicDoF dynamicDoF;
  30. public GameObject virtualHelmet;
  31. public DeskFanController fanController;
  32. public VibrationController vibrationController;
  33. public GameObject ppVolume;
  34. public SensorStatus waitForSensors;
  35. [Header("Configuration")] public Condition[] conditions;
  36. public int activeCondition;
  37. private void OnEnable()
  38. {
  39. var c = conditions[activeCondition];
  40. routeManager.selectedRoute = c.routeNumber;
  41. ppVolume.SetActive(false);
  42. fanController.enabled = c.activeMeasure == SicknessMeasure.Fan;
  43. vibrationController.enabled = c.activeMeasure == SicknessMeasure.Vibration;
  44. virtualHelmet.SetActive(c.activeMeasure == SicknessMeasure.VirtualHelmet);
  45. ppVolume.SetActive(c.activeMeasure == SicknessMeasure.DepthOfField);
  46. dynamicDoF.enabled = c.activeMeasure == SicknessMeasure.DepthOfField;
  47. dynamicVignetting.enabled = c.activeMeasure == SicknessMeasure.Vignetting;
  48. waitForSensors.waitForMqtt =
  49. c.activeMeasure == SicknessMeasure.Vibration || c.activeMeasure == SicknessMeasure.Fan;
  50. }
  51. }
  52. }