FoveEyeRayMgr.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class FoveEyeRayMgr : MonoBehaviour
  5. {
  6. private void Start()
  7. {
  8. }
  9. private IEnumerator CoFaceChange(FoveEyeRayMgr.HIT_REGION f_eType)
  10. {
  11. if (FoveEyeRayMgr.m_TargetMaid != null)
  12. {
  13. if (this.m_strBackFace != null)
  14. {
  15. FoveEyeRayMgr.m_TargetMaid.FaceAnime(this.m_strBackFace, 2f, 0);
  16. }
  17. if (this.m_strBackBlend != null)
  18. {
  19. FoveEyeRayMgr.m_TargetMaid.FaceBlend(this.m_strBackBlend);
  20. }
  21. this.m_strBackFace = FoveEyeRayMgr.m_TargetMaid.ActiveFace;
  22. this.m_strBackBlend = FoveEyeRayMgr.m_TargetMaid.FaceName3;
  23. if (f_eType == FoveEyeRayMgr.HIT_REGION.HEAD)
  24. {
  25. if (this.m_strBackFace != "優しさ")
  26. {
  27. FoveEyeRayMgr.m_TargetMaid.FaceAnime("優しさ", 1f, 0);
  28. }
  29. if (this.m_strBackBlend != "頬1涙0")
  30. {
  31. FoveEyeRayMgr.m_TargetMaid.FaceBlend("頬1涙0");
  32. }
  33. }
  34. else if (f_eType == FoveEyeRayMgr.HIT_REGION.BUST)
  35. {
  36. if (this.m_strBackFace != "困った")
  37. {
  38. FoveEyeRayMgr.m_TargetMaid.FaceAnime("困った", 1f, 0);
  39. }
  40. if (this.m_strBackBlend != "頬1涙0")
  41. {
  42. FoveEyeRayMgr.m_TargetMaid.FaceBlend("頬1涙0");
  43. }
  44. }
  45. else if (f_eType == FoveEyeRayMgr.HIT_REGION.CROTCH)
  46. {
  47. if (this.m_strBackFace != "びっくり")
  48. {
  49. FoveEyeRayMgr.m_TargetMaid.FaceAnime("びっくり", 1f, 0);
  50. }
  51. if (this.m_strBackBlend != "頬2涙0")
  52. {
  53. FoveEyeRayMgr.m_TargetMaid.FaceBlend("頬2涙0");
  54. }
  55. }
  56. this.m_fWaitTime = 5f;
  57. do
  58. {
  59. yield return null;
  60. this.m_fWaitTime -= Time.deltaTime;
  61. if (this.m_fWaitTime <= 0f)
  62. {
  63. break;
  64. }
  65. }
  66. while (!(FoveEyeRayMgr.m_TargetMaid == null));
  67. if (FoveEyeRayMgr.m_TargetMaid != null)
  68. {
  69. FoveEyeRayMgr.m_TargetMaid.FaceAnime(this.m_strBackFace, 2f, 0);
  70. FoveEyeRayMgr.m_TargetMaid.FaceBlend(this.m_strBackBlend);
  71. }
  72. }
  73. this.m_coFaceChage = null;
  74. yield break;
  75. }
  76. private void Update()
  77. {
  78. FoveInterface.EyeRays eyeRays = FoveInterface.GetEyeRays();
  79. this.m_vEyeDirEaseL += (eyeRays.left.direction - this.m_vEyeDirEaseL) * this.EASING;
  80. this.m_rayEaseL.origin = eyeRays.left.origin;
  81. this.m_rayEaseL.direction = eyeRays.left.direction;
  82. this.m_vEyeDirEaseR += (eyeRays.right.direction - this.m_vEyeDirEaseR) * this.EASING;
  83. this.m_rayEaseR.origin = eyeRays.right.origin;
  84. this.m_rayEaseR.direction = eyeRays.right.direction;
  85. bool flag = false;
  86. RaycastHit raycastHit;
  87. if (Physics.Raycast(this.m_rayEaseL, out raycastHit, float.PositiveInfinity, 131072))
  88. {
  89. flag = true;
  90. this.m_goCursorLeft.transform.position = raycastHit.point;
  91. }
  92. else
  93. {
  94. this.m_goCursorLeft.transform.position = eyeRays.left.GetPoint(3f);
  95. }
  96. RaycastHit raycastHit2;
  97. if (Physics.Raycast(this.m_rayEaseR, out raycastHit2, float.PositiveInfinity, 131072))
  98. {
  99. flag = true;
  100. this.m_goCursorRight.transform.position = raycastHit2.point;
  101. }
  102. else
  103. {
  104. this.m_goCursorRight.transform.position = eyeRays.right.GetPoint(3f);
  105. }
  106. if (flag && FoveEyeRayMgr.m_TargetMaid != null)
  107. {
  108. string a = string.Empty;
  109. string a2 = string.Empty;
  110. if (raycastHit.transform != null)
  111. {
  112. a = raycastHit.transform.name;
  113. }
  114. if (raycastHit2.transform != null)
  115. {
  116. a2 = raycastHit2.transform.name;
  117. }
  118. FoveEyeRayMgr.HIT_REGION hit_REGION = FoveEyeRayMgr.HIT_REGION.NON;
  119. if (a == "OvrGrabHit_Bip01 Head" || a2 == "OvrGrabHit_Bip01 Head")
  120. {
  121. hit_REGION = FoveEyeRayMgr.HIT_REGION.HEAD;
  122. }
  123. else if (a == "OvrGrabHit_Mune_L_sub" || a2 == "OvrGrabHit_Mune_L_sub" || a == "OvrGrabHit_Mune_R_sub" || a2 == "OvrGrabHit_Mune_R_sub")
  124. {
  125. hit_REGION = FoveEyeRayMgr.HIT_REGION.BUST;
  126. }
  127. else if (a == "OvrGrabHit_Bip01 Pelvis_SCL_" || a2 == "OvrGrabHit_Bip01 Pelvis_SCL_")
  128. {
  129. hit_REGION = FoveEyeRayMgr.HIT_REGION.CROTCH;
  130. }
  131. if (hit_REGION == FoveEyeRayMgr.HIT_REGION.NON)
  132. {
  133. this.m_fLookTimeNow = 0f;
  134. }
  135. else if (hit_REGION != this.m_hitBefore)
  136. {
  137. this.m_fLookTimeNow = 0f;
  138. if (this.m_coFaceChage != null)
  139. {
  140. base.StopCoroutine(this.m_coFaceChage);
  141. this.m_coFaceChage = null;
  142. }
  143. }
  144. else
  145. {
  146. this.m_fLookTimeNow += Time.deltaTime;
  147. if (this.m_fLookTimeNow > 2f)
  148. {
  149. if (this.m_coFaceChage == null)
  150. {
  151. this.m_coFaceChage = base.StartCoroutine(this.CoFaceChange(hit_REGION));
  152. }
  153. else
  154. {
  155. this.m_fWaitTime = 5f;
  156. }
  157. this.m_fLookTimeNow = 0f;
  158. }
  159. }
  160. this.m_hitBefore = hit_REGION;
  161. }
  162. else
  163. {
  164. this.m_fLookTimeNow = 0f;
  165. this.m_hitBefore = FoveEyeRayMgr.HIT_REGION.NON;
  166. }
  167. }
  168. public static Maid m_TargetMaid;
  169. public GameObject m_goCursorLeft;
  170. public GameObject m_goCursorRight;
  171. private float m_fLookTimeNow;
  172. private Coroutine m_coFaceChage;
  173. private float m_fWaitTime = 5f;
  174. private string m_strBackFace;
  175. private string m_strBackBlend;
  176. private FoveEyeRayMgr.HIT_REGION m_hitBefore;
  177. private Vector3 m_vEyeDirEaseL;
  178. private Vector3 m_vEyeDirEaseR;
  179. private Ray m_rayEaseL;
  180. private Ray m_rayEaseR;
  181. private float EASING = 0.05f;
  182. private enum HIT_REGION
  183. {
  184. NON,
  185. HEAD,
  186. BUST,
  187. CROTCH
  188. }
  189. }