VREventNotifierLook.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using UnityEngine;
  3. public class VREventNotifierLook : VREventNotifier
  4. {
  5. protected override void Start()
  6. {
  7. this.m_EyeRay = GameMain.Instance.OvrMgr.OvrCamera.EyeRay;
  8. this.LookTimeCountDownStop();
  9. }
  10. private void LookTimeCountDownStart()
  11. {
  12. this.m_fMaxTime = this.m_HitLookTarget.GetTimeOutTime();
  13. this.m_fNowTime = this.m_fMaxTime;
  14. this.m_EventText.SetGaugeRate(0f);
  15. this.m_EventText.Show(VREventText.TYPE.LOOK, this.m_HitLookTarget.GetEventName(), 0f);
  16. }
  17. private void LookTimeCountDownStop()
  18. {
  19. if (this.m_EventText != null)
  20. {
  21. this.m_EventText.Hide(VREventText.TYPE.LOOK);
  22. }
  23. }
  24. private void LookTimeOut()
  25. {
  26. Debug.Log("Look:StartScript");
  27. this.LookTimeCountDownStop();
  28. if (this.m_HitLookTarget != null)
  29. {
  30. this.m_HitLookTarget.StartScript();
  31. this.m_HitLookTarget = null;
  32. }
  33. }
  34. private void Update()
  35. {
  36. GameMain.Instance.OvrMgr.OvrCamera.HideDummyHand(OvrCamera.DUMMY_HAND.EVENT_GRAB);
  37. if (SceneVRCommunication.Instance == null || !SceneVRCommunication.Instance.IsFreeMode)
  38. {
  39. this.LookTimeCountDownStop();
  40. return;
  41. }
  42. this.m_HitLookTarget = null;
  43. if (GameMain.Instance.MainCamera.IsFadeOut())
  44. {
  45. this.m_HitBackLookTarget = null;
  46. if (object.ReferenceEquals(VREventNotifier.m_clSingle, this))
  47. {
  48. VREventNotifier.m_clSingle = null;
  49. }
  50. this.LookTimeCountDownStop();
  51. return;
  52. }
  53. if (this.m_EyeRay.RayCast(out this.m_hit, VREventNotifierLook.m_fMaxDistance, 2097152))
  54. {
  55. this.m_HitLookTarget = this.m_hit.transform.GetComponentInChildren<VREventTriggerLook>();
  56. if (this.m_HitLookTarget != null && !this.m_HitLookTarget.IsEnableEvent())
  57. {
  58. this.m_HitLookTarget = null;
  59. }
  60. }
  61. bool flag = false;
  62. if (GameMain.Instance.OvrMgr.OvrCamera.IsNoHandController && this.m_EyeRay.RayCast(out this.m_hit, VREventNotifierLook.m_fMaxDistance, 131072))
  63. {
  64. this.m_HitLookTarget = this.m_hit.transform.GetComponentInChildren<VREventTriggerGrab>();
  65. if (this.m_HitLookTarget != null && !this.m_HitLookTarget.IsEnableEvent())
  66. {
  67. this.m_HitLookTarget = null;
  68. }
  69. else
  70. {
  71. flag = true;
  72. this.m_vDummyGrabPos = this.m_hit.point;
  73. }
  74. }
  75. if (VREventNotifier.m_clSingle == null || object.ReferenceEquals(VREventNotifier.m_clSingle, this))
  76. {
  77. if (this.m_HitLookTarget != null && this.m_HitBackLookTarget == null)
  78. {
  79. this.m_HitLookTarget.OnEvnetCountDownEnter(base.gameObject);
  80. this.LookTimeCountDownStart();
  81. VREventNotifier.m_clSingle = this;
  82. }
  83. else if (this.m_HitLookTarget != null && this.m_HitBackLookTarget != null)
  84. {
  85. if (!object.ReferenceEquals(this.m_HitLookTarget, this.m_HitBackLookTarget))
  86. {
  87. this.m_HitBackLookTarget.OnEventCountDownExit(base.gameObject);
  88. this.LookTimeCountDownStop();
  89. this.m_HitLookTarget.OnEvnetCountDownEnter(base.gameObject);
  90. this.LookTimeCountDownStart();
  91. }
  92. VREventNotifier.m_clSingle = this;
  93. this.m_fNowTime -= Time.deltaTime;
  94. if (this.m_fNowTime <= 0f)
  95. {
  96. this.LookTimeOut();
  97. this.m_EventText.SetGaugeRate(1f);
  98. }
  99. else
  100. {
  101. this.m_EventText.SetGaugeRate(1f - this.m_fNowTime / this.m_fMaxTime);
  102. }
  103. if (flag)
  104. {
  105. GameMain.Instance.OvrMgr.OvrCamera.ShowDummyHand(OvrCamera.DUMMY_HAND.EVENT_GRAB, this.m_vDummyGrabPos, true);
  106. }
  107. }
  108. else if (this.m_HitLookTarget == null && this.m_HitBackLookTarget != null)
  109. {
  110. this.m_HitBackLookTarget.OnEventCountDownExit(base.gameObject);
  111. this.LookTimeCountDownStop();
  112. this.m_HitLookTarget = null;
  113. GameMain.Instance.OvrMgr.OvrCamera.HideDummyHand(OvrCamera.DUMMY_HAND.EVENT_GRAB);
  114. VREventNotifier.m_clSingle = null;
  115. }
  116. }
  117. this.m_HitBackLookTarget = this.m_HitLookTarget;
  118. }
  119. public static float m_fMaxDistance = 10f;
  120. public VREventText m_EventText;
  121. private RaycastHit m_hit;
  122. private VREventTrigger m_HitLookTarget;
  123. private VREventTrigger m_HitBackLookTarget;
  124. private float m_fMaxTime = 5f;
  125. private float m_fNowTime;
  126. private OvrEyeRay m_EyeRay;
  127. private Vector3 m_vDummyGrabPos;
  128. }