VRLookMgr.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class VRLookMgr
  5. {
  6. public VRLookMgr()
  7. {
  8. this.m_EyeRay = GameMain.Instance.OvrMgr.OvrCamera.EyeRay;
  9. }
  10. public void Clear()
  11. {
  12. }
  13. public void FrameStart()
  14. {
  15. foreach (KeyValuePair<int, Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State>> keyValuePair in this.m_dicState)
  16. {
  17. foreach (KeyValuePair<VRTouchMgr.ETouchPos, VRLookMgr.State> keyValuePair2 in keyValuePair.Value)
  18. {
  19. keyValuePair2.Value.behNow = VRLookMgr.ELookBehavior.無し;
  20. }
  21. }
  22. if (this.m_EyeRay.RayCast(out this.m_hit, VRLookMgr.m_fMaxDistance, 524288))
  23. {
  24. bool flag = false;
  25. GameObject gameObject = this.m_hit.transform.gameObject;
  26. VRTouchMgr.ETouchPos key = VRTouchMgr.ETouchPos.無し;
  27. if (gameObject.name == "OvrTouchHit_Bip01 Spine_SCL_" || gameObject.name == "OvrTouchHit_Bip01 Spine0a_SCL_")
  28. {
  29. flag = true;
  30. key = VRTouchMgr.ETouchPos.お腹;
  31. }
  32. else if (gameObject.name == "OvrTouchHit_Mune_L_sub" || gameObject.name == "OvrTouchHit_Mune_R_sub")
  33. {
  34. flag = true;
  35. key = VRTouchMgr.ETouchPos.胸;
  36. }
  37. else if (gameObject.name == "OvrTouchHit_Bip01 Head")
  38. {
  39. flag = true;
  40. key = VRTouchMgr.ETouchPos.頭頂部;
  41. }
  42. else if (gameObject.name == "OvrTouchHit_Bip01 L Hand" || gameObject.name == "OvrTouchHit_Bip01 R Hand")
  43. {
  44. flag = true;
  45. key = VRTouchMgr.ETouchPos.手;
  46. }
  47. else if (gameObject.name == "OvrTouchHit_Bip01 Pelvis_SCL_")
  48. {
  49. flag = true;
  50. key = VRTouchMgr.ETouchPos.お尻;
  51. }
  52. if (flag)
  53. {
  54. Maid componentInParent = gameObject.GetComponentInParent<Maid>();
  55. int activeSlotNo = componentInParent.ActiveSlotNo;
  56. Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State> dictionary;
  57. if (!this.m_dicState.TryGetValue(activeSlotNo, out dictionary))
  58. {
  59. Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State> dictionary2 = new Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State>();
  60. this.m_dicState[activeSlotNo] = dictionary2;
  61. dictionary = dictionary2;
  62. }
  63. VRLookMgr.State state;
  64. if (!dictionary.TryGetValue(key, out state))
  65. {
  66. VRLookMgr.State state2 = new VRLookMgr.State();
  67. dictionary[key] = state2;
  68. state = state2;
  69. }
  70. state.behNow = VRLookMgr.ELookBehavior.見る;
  71. state.vHitPos = this.m_hit.point;
  72. }
  73. }
  74. }
  75. public void FrameEnd()
  76. {
  77. foreach (KeyValuePair<int, Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State>> keyValuePair in this.m_dicState)
  78. {
  79. foreach (KeyValuePair<VRTouchMgr.ETouchPos, VRLookMgr.State> keyValuePair2 in keyValuePair.Value)
  80. {
  81. keyValuePair2.Value.behBef = keyValuePair2.Value.behNow;
  82. }
  83. }
  84. }
  85. private bool GetState(int f_nMaidNo, VRTouchMgr.ETouchPos f_checkPos, out VRLookMgr.State f_outState)
  86. {
  87. f_outState = null;
  88. Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State> dictionary;
  89. return this.m_dicState.TryGetValue(f_nMaidNo, out dictionary) && dictionary.TryGetValue(f_checkPos, out f_outState);
  90. }
  91. public bool GetBehaviorLookDown(VRTouchMgr.ETouchPos f_checkPos, VRLookMgr.ELookBehavior f_checkBeh, int f_nMaidNo, out VRLookMgr.State f_outState)
  92. {
  93. f_outState = null;
  94. VRLookMgr.State state;
  95. if (!this.GetState(f_nMaidNo, f_checkPos, out state))
  96. {
  97. return false;
  98. }
  99. if (state.behNow == f_checkBeh && state.behBef != state.behNow)
  100. {
  101. f_outState = state;
  102. return true;
  103. }
  104. return false;
  105. }
  106. public bool GetBehaviorTouch(VRTouchMgr.ETouchPos f_checkPos, VRLookMgr.ELookBehavior f_checkBeh, int f_nMaidNo, out VRLookMgr.State f_outState)
  107. {
  108. f_outState = null;
  109. VRLookMgr.State state;
  110. if (!this.GetState(f_nMaidNo, f_checkPos, out state))
  111. {
  112. return false;
  113. }
  114. if (state.behNow == f_checkBeh)
  115. {
  116. f_outState = state;
  117. return true;
  118. }
  119. return false;
  120. }
  121. public static float m_fMaxDistance = 10f;
  122. private RaycastHit m_hit;
  123. private Dictionary<int, Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State>> m_dicState = new Dictionary<int, Dictionary<VRTouchMgr.ETouchPos, VRLookMgr.State>>();
  124. private OvrEyeRay m_EyeRay;
  125. public enum ELookBehavior
  126. {
  127. 無し,
  128. 見る,
  129. MAX
  130. }
  131. public class State
  132. {
  133. public VRLookMgr.ELookBehavior behBef;
  134. public VRLookMgr.ELookBehavior behNow;
  135. public Vector3 vHitPos;
  136. }
  137. }