AVRController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using UnityEngine;
  3. public abstract class AVRController : MonoBehaviour
  4. {
  5. public bool IsControllerTypeNew
  6. {
  7. get
  8. {
  9. return this.m_bControllerModeNew;
  10. }
  11. }
  12. public AVRControllerButtons VRControllerButtons
  13. {
  14. get
  15. {
  16. return this.m_CtrlBtn;
  17. }
  18. }
  19. public OvrMgr.OvrObject.Controller VRControllerObj
  20. {
  21. get
  22. {
  23. return this.m_obj_controller;
  24. }
  25. }
  26. public bool HandEnable
  27. {
  28. get
  29. {
  30. return this.m_bHandEnable;
  31. }
  32. set
  33. {
  34. this.m_bHandEnable = value;
  35. }
  36. }
  37. public Transform UIRayTrans
  38. {
  39. get
  40. {
  41. return this.m_trUIRayTrans;
  42. }
  43. }
  44. public bool UIRayEnable
  45. {
  46. get
  47. {
  48. return this.m_bUIRayEnable;
  49. }
  50. set
  51. {
  52. this.m_bUIRayEnable = value;
  53. }
  54. }
  55. public abstract bool IsHandCameraMode { get; }
  56. public abstract bool HandCameraMode { get; set; }
  57. public abstract bool IsHandPenMode { get; }
  58. public abstract AVRControllerBehavior.LIMIT_MODE HandLimitMode { get; set; }
  59. public abstract bool HandModelVisible { get; set; }
  60. public abstract bool HandDanceMode { get; set; }
  61. public abstract bool HandVRIKMode { get; set; }
  62. public abstract bool HandYotogiMode { get; set; }
  63. public virtual void Init()
  64. {
  65. this.m_CtrlBtn = base.GetComponent<AVRControllerButtons>();
  66. OvrMgr.OvrObject ovr_obj = GameMain.Instance.OvrMgr.ovr_obj;
  67. if (base.gameObject.name.ToLower().Contains("left"))
  68. {
  69. this.m_bHandL = true;
  70. this.m_obj_controller = ovr_obj.left_controller;
  71. }
  72. else if (base.gameObject.name.ToLower().Contains("right"))
  73. {
  74. this.m_bHandL = false;
  75. this.m_obj_controller = ovr_obj.right_controller;
  76. }
  77. this.m_obj_controller.hand_trans = base.transform;
  78. this.m_obj_controller.controller = this;
  79. this.m_obj_controller.controller_buttons = this.m_CtrlBtn;
  80. Transform transform = base.transform.Find("Grab");
  81. this.m_obj_controller.grip_collider = transform.GetComponent<OvrGripCollider>();
  82. this.m_obj_controller.grip_collider.Init(this.m_CtrlBtn);
  83. this.m_trHandHit = base.transform.Find("HandHit");
  84. NDebug.Assert(this.m_trHandHit != null);
  85. this.m_obj_controller.hand_trans_hit = this.m_trHandHit;
  86. this.m_trUIRayTrans = base.transform.Find("UIRay");
  87. NDebug.Assert(this.m_trUIRayTrans != null, "UIRayがみつかりません。");
  88. this.m_VREventGrab = base.GetComponent<VREventNotifierGrab>();
  89. if (this.m_VREventGrab != null)
  90. {
  91. this.m_VREventGrab.Init(this.m_obj_controller);
  92. }
  93. }
  94. public virtual void ChangeControllerNew(bool f_bNew)
  95. {
  96. if (f_bNew)
  97. {
  98. this.m_CtrlBehOld.enabled = false;
  99. this.m_CtrlBehNew.enabled = true;
  100. this.m_CtrlBehNow = this.m_CtrlBehNew;
  101. }
  102. else
  103. {
  104. this.m_CtrlBehNew.enabled = false;
  105. this.m_CtrlBehOld.enabled = true;
  106. this.m_CtrlBehNow = this.m_CtrlBehOld;
  107. }
  108. this.m_CtrlBehNow.HandCameraMode = false;
  109. this.m_CtrlBehNow.HandLimitMode = AVRControllerBehavior.LIMIT_MODE.NORMAL;
  110. this.m_bControllerModeNew = f_bNew;
  111. }
  112. public virtual void DefaultControllerMode(bool f_bEnable)
  113. {
  114. if (f_bEnable)
  115. {
  116. this.ChangeControllerNew(this.m_bControllerModeNew);
  117. }
  118. else
  119. {
  120. this.m_CtrlBehOld.enabled = false;
  121. this.m_CtrlBehNew.enabled = false;
  122. }
  123. }
  124. public virtual void OnEnable()
  125. {
  126. this.HandHitReset();
  127. }
  128. private void HandHitReset()
  129. {
  130. if (this.m_trHandHit == null)
  131. {
  132. return;
  133. }
  134. int maidCount = GameMain.Instance.CharacterMgr.GetMaidCount();
  135. for (int i = 0; i < maidCount; i++)
  136. {
  137. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i);
  138. if (maid != null && maid.body0)
  139. {
  140. if (this.m_bHandL)
  141. {
  142. maid.body0.m_trHandHitL = this.m_trHandHit;
  143. }
  144. else
  145. {
  146. maid.body0.m_trHandHitR = this.m_trHandHit;
  147. }
  148. }
  149. }
  150. }
  151. public Vector3 GetHandMoveVelocity()
  152. {
  153. return this.m_CtrlBehNow.GetVelocityHand();
  154. }
  155. public float GetHandRotVelocityY()
  156. {
  157. return this.m_CtrlBehNow.GetRotHandY();
  158. }
  159. public Vector3 GetCamMoveVelocity()
  160. {
  161. return this.m_CtrlBehNow.m_vMoveCam;
  162. }
  163. public float GetCamRotVelocityY()
  164. {
  165. return this.m_CtrlBehNow.m_fRotCam;
  166. }
  167. public bool m_bHandL = true;
  168. protected bool m_bHandEnable = true;
  169. protected bool m_bControllerModeNew;
  170. protected AVRControllerBehavior m_CtrlBehNow;
  171. protected AVRControllerBehavior m_CtrlBehOld;
  172. protected AVRControllerBehavior m_CtrlBehNew;
  173. protected AVRControllerButtons m_CtrlBtn;
  174. protected VREventNotifierGrab m_VREventGrab;
  175. protected OvrMgr.OvrObject.Controller m_obj_controller;
  176. protected Transform m_trUIRayTrans;
  177. protected bool m_bUIRayEnable = true;
  178. protected Transform m_trHandHit;
  179. }