FanActivationScript.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.PlayerLoop;
  5. public class FanActivationScript : MonoBehaviour
  6. {
  7. public Transform FanKnobTransform1;
  8. public Transform FanKnobTransform2;
  9. public Transform FanKnobTransform3;
  10. public List<Transform> FanaList1;
  11. public List<Transform> FanaList2;
  12. public List<Transform> FanaList3;
  13. public float Speed;
  14. public bool isOpen1 = true;
  15. public bool isOpen2 = false;
  16. public bool isOpen3 = false;
  17. void FixedUpdate()
  18. {
  19. if (isOpen1)
  20. {
  21. for (int i = 0; i < FanaList1.Count; i++)
  22. {
  23. Vector3 rotation = FanaList1[i].eulerAngles;
  24. rotation.z += Speed;
  25. FanaList1[i].eulerAngles = rotation;
  26. }
  27. }
  28. if (isOpen2)
  29. {
  30. for (int i = 0; i < FanaList2.Count; i++)
  31. {
  32. Vector3 rotation = FanaList2[i].eulerAngles;
  33. rotation.z += Speed;
  34. FanaList2[i].eulerAngles = rotation;
  35. }
  36. }
  37. if (isOpen3)
  38. {
  39. for (int i = 0; i < FanaList3.Count; i++)
  40. {
  41. Vector3 rotation = FanaList3[i].eulerAngles;
  42. rotation.z += Speed;
  43. FanaList3[i].eulerAngles = rotation;
  44. }
  45. }
  46. }
  47. public void isOpenFanList1()
  48. {
  49. isOpen1 = !isOpen1;
  50. }
  51. public void isOpenFanList2()
  52. {
  53. isOpen2 = !isOpen2;
  54. }
  55. public void isOpenFanList3()
  56. {
  57. isOpen3 = !isOpen3;
  58. }
  59. }