ViveControllerBehavior2.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using Valve.VR;
  6. public class ViveControllerBehavior2 : ViveControllerBehavior
  7. {
  8. public override AVRControllerBehavior.BEH_TYPE BehaviourType
  9. {
  10. get
  11. {
  12. return AVRControllerBehavior.BEH_TYPE.NEW;
  13. }
  14. }
  15. public override bool HandCameraMode
  16. {
  17. get
  18. {
  19. return this.m_eMode == ViveControllerBehavior2.OvrControllerMode.CAMERA;
  20. }
  21. set
  22. {
  23. if (value)
  24. {
  25. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.CAMERA);
  26. }
  27. }
  28. }
  29. public override bool IsHandCameraMode
  30. {
  31. get
  32. {
  33. return this.m_eModeBack == ViveControllerBehavior2.OvrControllerMode.CAMERA;
  34. }
  35. }
  36. public override bool IsHandPenMode
  37. {
  38. get
  39. {
  40. return this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN;
  41. }
  42. }
  43. public override bool HandModelVisible
  44. {
  45. get
  46. {
  47. return this.m_bHandModelVisible;
  48. }
  49. set
  50. {
  51. this.m_bHandModelVisible = value;
  52. this.ChangeMode(this.m_eMode);
  53. }
  54. }
  55. public override AVRControllerBehavior.LIMIT_MODE HandLimitMode
  56. {
  57. set
  58. {
  59. if (value == AVRControllerBehavior.LIMIT_MODE.HAND_ONLY)
  60. {
  61. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  62. }
  63. base.HandLimitMode = value;
  64. }
  65. }
  66. public override bool HandDanceMode
  67. {
  68. get
  69. {
  70. return this.m_bHandDanceMode && this.m_eMode == ViveControllerBehavior2.OvrControllerMode.DANCE;
  71. }
  72. set
  73. {
  74. this.m_bHandDanceMode = value;
  75. if (value)
  76. {
  77. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.DANCE);
  78. }
  79. else if (!value)
  80. {
  81. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  82. {
  83. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  84. }
  85. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.DANCE)
  86. {
  87. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  88. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  89. }
  90. }
  91. }
  92. }
  93. public override bool HandVRIKMode
  94. {
  95. get
  96. {
  97. return this.m_bHandVRIKMode;
  98. }
  99. set
  100. {
  101. this.m_bHandVRIKMode = value;
  102. if (value)
  103. {
  104. this.m_bModeHide[5] = false;
  105. this.m_bModeHide[6] = false;
  106. this.m_bModeHide[7] = false;
  107. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.VRIK_FACE);
  108. }
  109. else if (!value)
  110. {
  111. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  112. {
  113. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  114. }
  115. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.VRIK_FACE)
  116. {
  117. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  118. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  119. }
  120. this.m_bModeHide[5] = true;
  121. this.m_bModeHide[6] = true;
  122. this.m_bModeHide[7] = true;
  123. }
  124. }
  125. }
  126. public override bool HandYotogiMode
  127. {
  128. get
  129. {
  130. return this.m_bHandYotogiMode && this.m_eMode == ViveControllerBehavior2.OvrControllerMode.YOTOGI;
  131. }
  132. set
  133. {
  134. this.m_bHandYotogiMode = value;
  135. if (value)
  136. {
  137. this.m_bModeHide[8] = false;
  138. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.YOTOGI);
  139. }
  140. else if (!value)
  141. {
  142. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  143. {
  144. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  145. }
  146. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.YOTOGI)
  147. {
  148. this.m_eModeBack = ViveControllerBehavior2.OvrControllerMode.HAND;
  149. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  150. }
  151. this.m_bModeHide[8] = true;
  152. }
  153. }
  154. }
  155. protected override void Awake()
  156. {
  157. base.Awake();
  158. NDebug.Assert(this.m_Pair != null, "Pairコントローラがありません。");
  159. GameMain.Instance.CMSystem.OvrPointerMode = Mathf.Max(Mathf.Min(0, GameMain.Instance.CMSystem.OvrPointerMode), 0);
  160. GameMain.Instance.CMSystem.OvrMoveMode = Mathf.Max(Mathf.Min(2, GameMain.Instance.CMSystem.OvrMoveMode), 0);
  161. OvrMgr.OvrObject ovr_obj = GameMain.Instance.OvrMgr.ovr_obj;
  162. this.m_trackedObject = base.GetComponent<SteamVR_TrackedObject>();
  163. this.m_txMode = base.transform.Find("UI/Canvas/Text").GetComponent<Text>();
  164. this.m_goHandCamera = base.transform.Find("HandCamera").gameObject;
  165. this.m_HandCamera = this.m_goHandCamera.GetComponent<OvrHandCamera>();
  166. this.m_HandCamera.m_ctrl = this;
  167. this.m_trTrackedDeviceParent = base.transform.parent.Find("Tracked Devices");
  168. this.m_TrackObjs = this.m_trTrackedDeviceParent.GetComponentsInChildren<SteamVR_TrackedObject>(true);
  169. this.m_ArcTeleport = base.transform.Find("ArcTeleport").GetComponentInChildren<ArcTeleport>(true);
  170. this.m_ArcTeleport.SetCallBackOnMove(new ArcTeleport.dgOnMove(this.OnWarpMove));
  171. this.m_HandItem = base.transform.Find("HandItem").GetComponent<OvrHandItemMgr>();
  172. this.m_HandItem.m_ctrl = this;
  173. this.m_HandItem.SetButtons(this.m_buttons);
  174. this.m_HandItem.gameObject.SetActive(false);
  175. this.m_goManHand = base.transform.Find("HandPlayer").gameObject;
  176. NDebug.Assert(this.m_goManHand != null, "HandPlayer 男の手が見つかりません。");
  177. this.m_goManHand.GetComponent<ViveHandAnimator>().Init(this.m_buttons);
  178. this.m_fCursorLaserEasing = GameMain.Instance.CMSystem.OvrViveCursorLaserEasing;
  179. this.m_trTabletPenRoot = base.transform.Find("UIRay");
  180. NDebug.Assert(this.m_trTabletPenRoot != null, "UIRayが見つかりません。");
  181. this.m_goTabletPen = base.transform.Find("UIRay/Odogu_Styluspen_red").gameObject;
  182. NDebug.Assert(this.m_goTabletPen != null, "UI用タブレットペンモデルが見つかりません。");
  183. OvrUIPen component = this.m_goTabletPen.GetComponent<OvrUIPen>();
  184. if (component != null)
  185. {
  186. component.m_ctrl = this;
  187. }
  188. this.m_goManHand.SetActive(false);
  189. this.m_bIsInit = true;
  190. }
  191. private void Start()
  192. {
  193. GameMain.Instance.OvrMgr.OvrCamera.m_bWheelToZoom = false;
  194. this.ChangeMode(this.m_eMode);
  195. }
  196. private void OnEnable()
  197. {
  198. this.m_trTabletPenRoot.gameObject.SetActive(true);
  199. this.ChangeMode(this.m_eMode);
  200. }
  201. private void OnDisable()
  202. {
  203. this.m_trTabletPenRoot.gameObject.SetActive(false);
  204. this.m_goTabletPen.SetActive(false);
  205. this.m_goManHand.SetActive(false);
  206. }
  207. private void ChangeMode(ViveControllerBehavior2.OvrControllerMode f_eNewMode)
  208. {
  209. if (this.m_bIsInit)
  210. {
  211. bool flag = false;
  212. bool active = false;
  213. bool enabled = false;
  214. bool active2 = false;
  215. bool flag2 = false;
  216. bool enabled2 = true;
  217. bool active3 = false;
  218. bool isEnableHandUI = false;
  219. bool isEnableHandUI2 = false;
  220. bool isEnableHandUI3 = false;
  221. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.HAND || f_eNewMode == ViveControllerBehavior2.OvrControllerMode.YOTOGI)
  222. {
  223. enabled = true;
  224. if (this.m_bHandModelVisible)
  225. {
  226. if (this.m_eHandSubMode == ViveControllerBehavior2.HandSubMode.CONTROLLER)
  227. {
  228. flag = true;
  229. active = false;
  230. }
  231. else
  232. {
  233. flag = false;
  234. active = true;
  235. }
  236. }
  237. else
  238. {
  239. flag = false;
  240. active = false;
  241. }
  242. }
  243. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.CAMERA)
  244. {
  245. active2 = true;
  246. enabled2 = false;
  247. }
  248. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  249. {
  250. enabled = true;
  251. flag2 = true;
  252. }
  253. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.ITEM)
  254. {
  255. active3 = true;
  256. }
  257. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.VRIK_FACE)
  258. {
  259. enabled = true;
  260. isEnableHandUI = true;
  261. }
  262. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.VRIK_HAND)
  263. {
  264. enabled = true;
  265. isEnableHandUI2 = true;
  266. }
  267. if (f_eNewMode == ViveControllerBehavior2.OvrControllerMode.VRIK_OTHER)
  268. {
  269. enabled = true;
  270. isEnableHandUI3 = true;
  271. }
  272. if (flag)
  273. {
  274. foreach (SteamVR_TrackedObject steamVR_TrackedObject in this.m_TrackObjs)
  275. {
  276. if (steamVR_TrackedObject.index == this.m_trackedObject.index)
  277. {
  278. steamVR_TrackedObject.gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
  279. }
  280. }
  281. }
  282. else
  283. {
  284. foreach (SteamVR_TrackedObject steamVR_TrackedObject2 in this.m_TrackObjs)
  285. {
  286. if (steamVR_TrackedObject2.index == this.m_trackedObject.index)
  287. {
  288. steamVR_TrackedObject2.gameObject.transform.localScale = new Vector3(0f, 0f, 0f);
  289. }
  290. }
  291. }
  292. PhotoFaceDataShortcutParent componentInChildren = base.gameObject.GetComponentInChildren<PhotoFaceDataShortcutParent>();
  293. if (componentInChildren != null)
  294. {
  295. componentInChildren.isEnableHandUI = isEnableHandUI;
  296. }
  297. HandSignShortcut componentInChildren2 = base.gameObject.GetComponentInChildren<HandSignShortcut>();
  298. if (componentInChildren2 != null)
  299. {
  300. componentInChildren2.isEnableHandUI = isEnableHandUI2;
  301. }
  302. OtherCommandShortcut componentInChildren3 = base.gameObject.GetComponentInChildren<OtherCommandShortcut>();
  303. if (componentInChildren3 != null)
  304. {
  305. componentInChildren3.isEnableHandUI = isEnableHandUI3;
  306. }
  307. this.m_obj_controller.grip_collider.enabled = enabled;
  308. this.m_goHandCamera.SetActive(active2);
  309. this.m_goTabletPen.SetActive(flag2);
  310. this.m_controller.UIRayEnable = flag2;
  311. this.m_HandItem.gameObject.SetActive(active3);
  312. GameMain.Instance.OvrMgr.SystemUICamera.SetActiveVirtualCursorObjByNocurrent((!this.m_bHandL) ? UICamera.VCURSOR.RIGHT : UICamera.VCURSOR.LEFT, flag2);
  313. this.m_goManHand.SetActive(active);
  314. this.m_txMode.enabled = enabled2;
  315. this.m_txMode.text = this.m_strMode[(int)f_eNewMode];
  316. }
  317. this.m_eMode = f_eNewMode;
  318. }
  319. private void ChangePointerMode(ViveControllerBehavior2.PointerSubMode f_ePMode)
  320. {
  321. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  322. }
  323. private void ChangeMoveMode(ViveControllerBehavior2.MoveSubMode f_eSubMode)
  324. {
  325. GameMain.Instance.CMSystem.OvrMoveMode = (int)f_eSubMode;
  326. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  327. }
  328. private void ChangeHandMode(ViveControllerBehavior2.HandSubMode f_eSubMode)
  329. {
  330. this.m_eHandSubMode = f_eSubMode;
  331. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.HAND);
  332. }
  333. private void TouchPadToClick()
  334. {
  335. if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_L_CLICK) || this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_R_CLICK))
  336. {
  337. this.m_bCursorMoveEnable = false;
  338. GameMain.Instance.OvrMgr.SystemUICamera.SetCurrentCursorSide((!this.m_bHandL) ? UICamera.VCURSOR.RIGHT : UICamera.VCURSOR.LEFT);
  339. if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_L_CLICK))
  340. {
  341. NUty.EmurateMouseButton(2);
  342. this.m_bPressLeft = true;
  343. }
  344. else if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_R_CLICK))
  345. {
  346. NUty.EmurateMouseButton(8);
  347. this.m_bPressLeft = false;
  348. }
  349. if (this.m_coCursorMoveWait != null)
  350. {
  351. base.StopCoroutine(this.m_coCursorMoveWait);
  352. }
  353. this.m_coCursorMoveWait = base.StartCoroutine(this.CoCursorMoveWait());
  354. }
  355. else if (this.m_buttons.GetPressUp(AVRControllerButtons.BTN.VIRTUAL_L_CLICK) || this.m_buttons.GetPressUp(AVRControllerButtons.BTN.VIRTUAL_R_CLICK))
  356. {
  357. if (this.m_bPressLeft)
  358. {
  359. NUty.EmurateMouseButton(4);
  360. }
  361. else
  362. {
  363. GameMain.Instance.OvrMgr.OvrCamera.m_bRightClickUIToggle = false;
  364. NUty.EmurateMouseButton(16);
  365. }
  366. }
  367. }
  368. private IEnumerator CoCursorMoveWait()
  369. {
  370. yield return new WaitForSeconds(0.3f);
  371. this.m_bCursorMoveEnable = true;
  372. yield break;
  373. }
  374. private void TouchPadWheel()
  375. {
  376. if (this.m_device.GetTouchDown(4294967296UL))
  377. {
  378. this.m_fTrackPadBefY = this.m_device.GetAxis(EVRButtonId.k_EButton_Axis0).y;
  379. }
  380. else if (this.m_device.GetTouch(4294967296UL))
  381. {
  382. Vector2 axis = this.m_device.GetAxis(EVRButtonId.k_EButton_Axis0);
  383. float num = axis.y - this.m_fTrackPadBefY;
  384. if (0.1f < Mathf.Abs(num))
  385. {
  386. NUty.EmurateMouseWheel((int)(num * 10f));
  387. this.m_fTrackPadBefY = axis.y;
  388. }
  389. }
  390. }
  391. private void OnWarpMove(Vector3 f_vPosWorld, Vector3 f_vRotWorld)
  392. {
  393. GameMain.Instance.MainCamera.SetFootPos(f_vPosWorld, CameraMain.STAND_SIT.STAND);
  394. GameMain.Instance.MainCamera.SetRealHeadRot(f_vRotWorld, true);
  395. }
  396. public bool IsGrabTablet()
  397. {
  398. return this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN && this.m_buttons.GetPress(AVRControllerButtons.BTN.TRIGGER);
  399. }
  400. private void TabletSizeChange()
  401. {
  402. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  403. {
  404. if (this.m_Pair.IsGrabTablet())
  405. {
  406. if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.TRIGGER))
  407. {
  408. this.m_fOtherDistanceOne = Vector3.Distance(this.m_Pair.transform.position, base.transform.position);
  409. this.m_fTabletScaleBef = GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.Size;
  410. this.m_bTabletScaleGrab = true;
  411. }
  412. else if (this.m_buttons.GetPress(AVRControllerButtons.BTN.TRIGGER))
  413. {
  414. if (this.m_bTabletScaleGrab)
  415. {
  416. float num = Vector3.Distance(this.m_Pair.transform.position, base.transform.position) / this.m_fOtherDistanceOne;
  417. GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.Size = this.m_fTabletScaleBef * num;
  418. }
  419. }
  420. else
  421. {
  422. this.m_bTabletScaleGrab = false;
  423. }
  424. }
  425. else
  426. {
  427. this.m_bTabletScaleGrab = false;
  428. }
  429. }
  430. else
  431. {
  432. this.m_bTabletScaleGrab = false;
  433. }
  434. }
  435. protected override void Update()
  436. {
  437. GameMain.Instance.OvrMgr.OvrCamera.m_bRightClickUIToggle = true;
  438. if (OvrIK.IsModeVRIK)
  439. {
  440. if (this.m_goModeCanvas.layer != 17)
  441. {
  442. this.m_goModeCanvas.layer = 17;
  443. }
  444. }
  445. else if (this.m_goModeCanvas.layer != 0)
  446. {
  447. this.m_goModeCanvas.layer = 0;
  448. }
  449. this.m_device = SteamVR_Controller.Input((int)this.m_trackedObject.index);
  450. this.m_vMoveCam.x = (this.m_vMoveCam.y = (this.m_vMoveCam.z = (this.m_fRotCam = 0f)));
  451. this.m_vMoveVelocity.x = (this.m_vMoveVelocity.y = (this.m_vMoveVelocity.z = 0f));
  452. this.m_fCamRotNow = 0f;
  453. if (this.m_device.GetPressDown(2UL))
  454. {
  455. this.m_bPressMenuBtnLong = false;
  456. this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
  457. }
  458. else if (this.m_device.GetPress(2UL))
  459. {
  460. if (!this.m_bPressMenuBtnLong && Time.realtimeSinceStartup - this.m_fMenuPressBeforeTime > 1f)
  461. {
  462. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.HAND)
  463. {
  464. ViveControllerBehavior2.HandSubMode handSubMode = this.m_eHandSubMode + 1;
  465. if (handSubMode >= ViveControllerBehavior2.HandSubMode.MAX)
  466. {
  467. handSubMode = ViveControllerBehavior2.HandSubMode.CONTROLLER;
  468. }
  469. this.ChangeHandMode(handSubMode);
  470. }
  471. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.CAMERA)
  472. {
  473. }
  474. this.m_bPressMenuBtnLong = true;
  475. }
  476. }
  477. else if (this.m_device.GetPressUp(2UL) && !this.m_bPressMenuBtnLong)
  478. {
  479. if (this.m_device.GetPress(4UL))
  480. {
  481. GameMain.Instance.OvrMgr.OvrCamera.ReCallcOffset();
  482. GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true);
  483. GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f);
  484. }
  485. else if (this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY)
  486. {
  487. int num = (int)this.m_eMode;
  488. do
  489. {
  490. num++;
  491. if (num == 3 && !this.m_bHandDanceMode)
  492. {
  493. num++;
  494. }
  495. if (9 <= num)
  496. {
  497. num = 0;
  498. }
  499. }
  500. while (this.m_bModeHide[num]);
  501. this.ChangeMode((ViveControllerBehavior2.OvrControllerMode)num);
  502. this.m_eModeBack = this.m_eMode;
  503. }
  504. }
  505. this.m_bTabletArea = GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.IsHitPointerArea(base.transform.position);
  506. if (this.m_bTabletArea && !this.m_ArcTeleport.IsWarpSelecting() && !this.m_bMoveDrawMode && GameMain.Instance.OvrMgr.OvrCamera.IsUIShow)
  507. {
  508. if (this.m_eMode != ViveControllerBehavior2.OvrControllerMode.PEN)
  509. {
  510. this.m_eModeBack = this.m_eMode;
  511. this.ChangeMode(ViveControllerBehavior2.OvrControllerMode.PEN);
  512. }
  513. }
  514. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  515. {
  516. this.ChangeMode(this.m_eModeBack);
  517. }
  518. this.TabletSizeChange();
  519. if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.PEN)
  520. {
  521. RaycastHit raycastHit;
  522. if (Physics.Raycast(this.m_controller.UIRayTrans.position, this.m_controller.UIRayTrans.rotation * Vector3.forward, out raycastHit, float.PositiveInfinity, 33554432))
  523. {
  524. if (this.m_bCursorMoveEnable)
  525. {
  526. Vector2 textureCoord = raycastHit.textureCoord;
  527. Vector2 a = new Vector2(1280f * (textureCoord.x / 1f), 720f * (textureCoord.y / 1f));
  528. Vector2 vector = GameMain.Instance.OvrMgr.SystemUICamera.GetOvrVirtualMousePos(this.m_bHandL);
  529. Vector2 a2 = a - vector;
  530. Vector2 b = a2 * this.m_fCursorLaserEasing;
  531. Vector2 v = vector + b;
  532. GameMain.Instance.OvrMgr.SystemUICamera.SetOvrVirtualMousePos(this.m_bHandL, v);
  533. }
  534. this.TouchPadToClick();
  535. this.TouchPadWheel();
  536. }
  537. }
  538. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.HAND)
  539. {
  540. if (GameMain.Instance.CMSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT)
  541. {
  542. if (GameMain.Instance.CMSystem.OvrUseSnapRotate)
  543. {
  544. bool pressDown = this.m_device.GetPressDown(4294967296UL);
  545. Vector2 axis = this.m_buttons.GetAxis();
  546. if (pressDown && axis.x < -(1f - (float)GameMain.Instance.CMSystem.OvrUseSnapRotateRate * 0.01f))
  547. {
  548. if (!this.m_bSnapRot)
  549. {
  550. this.m_fCamRotNow = -30f;
  551. this.m_bSnapRot = true;
  552. }
  553. }
  554. else if (pressDown && 1f - (float)GameMain.Instance.CMSystem.OvrUseSnapRotateRate * 0.01f < axis.x)
  555. {
  556. if (!this.m_bSnapRot)
  557. {
  558. this.m_fCamRotNow = 30f;
  559. this.m_bSnapRot = true;
  560. }
  561. }
  562. else if (!this.m_device.GetPress(4294967296UL))
  563. {
  564. this.m_bSnapRot = false;
  565. }
  566. }
  567. else
  568. {
  569. this.m_bSnapRot = false;
  570. }
  571. if (this.HandLimitMode == AVRControllerBehavior.LIMIT_MODE.HAND_ONLY)
  572. {
  573. this.m_ArcTeleport.WarpCancel();
  574. this.m_bMoveDrawMode = false;
  575. }
  576. else
  577. {
  578. bool flag = false;
  579. if (this.HandLimitMode == AVRControllerBehavior.LIMIT_MODE.NO_WARP)
  580. {
  581. this.m_ArcTeleport.WarpCancel();
  582. flag = true;
  583. }
  584. if (this.m_device.GetPress(4294967296UL))
  585. {
  586. if (!this.m_bMoveDrawMode && !this.m_bSnapRot && !flag)
  587. {
  588. this.m_ArcTeleport.WarpSelecting();
  589. }
  590. if (this.m_device.GetPressDown(8589934592UL))
  591. {
  592. this.m_ArcTeleport.WarpCancel();
  593. this.m_bMoveDrawMode = true;
  594. }
  595. }
  596. else
  597. {
  598. if (!this.m_bMoveDrawMode && !this.m_bSnapRot && !flag)
  599. {
  600. this.m_ArcTeleport.WarpDicide();
  601. }
  602. this.m_bMoveDrawMode = false;
  603. }
  604. }
  605. }
  606. else if (GameMain.Instance.CMSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION && this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY)
  607. {
  608. Vector2 vector2 = this.m_buttons.GetAxis() * GameMain.Instance.CMSystem.SConfig.OvrMoveDirSpeed;
  609. if (this.m_device.GetPressDown(4294967296UL))
  610. {
  611. Vector2 axis2 = this.m_buttons.GetAxis();
  612. if (GameMain.Instance.CMSystem.SConfig.OvrViveSmoothRotatePadAreaUse)
  613. {
  614. if (axis2.x < -(1f - GameMain.Instance.CMSystem.SConfig.OvrViveSmoothRotatePadAriaRate * 0.01f))
  615. {
  616. this.m_bSmoothRot = true;
  617. }
  618. else if (1f - GameMain.Instance.CMSystem.SConfig.OvrViveSmoothRotatePadAriaRate * 0.01f < axis2.x)
  619. {
  620. this.m_bSmoothRot = true;
  621. }
  622. else
  623. {
  624. this.m_bSmoothRot = false;
  625. }
  626. }
  627. else
  628. {
  629. this.m_bSmoothRot = false;
  630. }
  631. if (GameMain.Instance.CMSystem.SConfig.OvrViveSmoothupDownPadAreaUse)
  632. {
  633. if (axis2.y < -(1f - GameMain.Instance.CMSystem.SConfig.OvrViveSmoothUpDownPadAriaRate * 0.01f))
  634. {
  635. this.m_bSmoothUpDown = true;
  636. }
  637. else if (1f - GameMain.Instance.CMSystem.SConfig.OvrViveSmoothUpDownPadAriaRate * 0.01f < axis2.y)
  638. {
  639. this.m_bSmoothUpDown = true;
  640. }
  641. else
  642. {
  643. this.m_bSmoothUpDown = false;
  644. }
  645. }
  646. else
  647. {
  648. this.m_bSmoothUpDown = false;
  649. }
  650. }
  651. if (this.m_device.GetPress(4294967296UL))
  652. {
  653. if (this.m_device.GetTouch(8589934592UL) || this.m_bSmoothUpDown)
  654. {
  655. this.m_vMoveCam.y = vector2.y;
  656. }
  657. else if (this.m_bSmoothRot)
  658. {
  659. this.m_fRotCam = vector2.x;
  660. }
  661. else
  662. {
  663. this.m_vMoveCam.x = -vector2.x;
  664. this.m_vMoveCam.z = vector2.y;
  665. }
  666. }
  667. }
  668. }
  669. else if (this.m_eMode == ViveControllerBehavior2.OvrControllerMode.CAMERA && this.m_device.GetTouchDown(8589934592UL))
  670. {
  671. this.m_HandCamera.Snap();
  672. }
  673. if (this.m_eMode != ViveControllerBehavior2.OvrControllerMode.HAND)
  674. {
  675. this.m_bSnapRot = false;
  676. this.m_bSmoothRot = false;
  677. this.m_bSmoothUpDown = false;
  678. }
  679. if (this.m_device.GetPress(4UL))
  680. {
  681. this.m_fGripTime += Time.deltaTime;
  682. if (this.m_fGripTime >= 1f && !this.m_bGripDown)
  683. {
  684. GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true);
  685. GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f);
  686. this.m_bGripDown = true;
  687. }
  688. }
  689. else if (this.m_device.GetPressUp(4UL))
  690. {
  691. if (!this.m_bGripDown && this.m_eMode != ViveControllerBehavior2.OvrControllerMode.PEN)
  692. {
  693. GameMain.Instance.OvrMgr.OvrCamera.ToggleUI();
  694. }
  695. this.m_bGripDown = false;
  696. this.m_fGripTime = 0f;
  697. }
  698. }
  699. public override Vector3 GetVelocityHand()
  700. {
  701. Vector3 result = default(Vector3);
  702. if (this.m_device != null && this.m_eMode == ViveControllerBehavior2.OvrControllerMode.HAND && this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY && !GameMain.Instance.MainCamera.IsFadeOut())
  703. {
  704. if (!this.m_bPressTrigger && this.m_device.GetTouchDown(8589934592UL))
  705. {
  706. this.m_vMoveTugPosBack = base.transform.position;
  707. this.m_bPressTrigger = true;
  708. }
  709. else if (this.m_bPressTrigger && this.m_device.GetTouch(8589934592UL))
  710. {
  711. if (this.m_bMoveDrawMode)
  712. {
  713. if (this.m_goTestObj != null)
  714. {
  715. this.m_goTestObj.transform.position = base.transform.position;
  716. }
  717. Vector3 a = base.transform.position - this.m_vMoveTugPosBack;
  718. result = a * -1f;
  719. }
  720. }
  721. else
  722. {
  723. this.m_bPressTrigger = false;
  724. }
  725. }
  726. else
  727. {
  728. this.m_bPressTrigger = false;
  729. }
  730. return result;
  731. }
  732. public override float GetRotHandY()
  733. {
  734. return this.m_fCamRotNow;
  735. }
  736. protected override void LateUpdate()
  737. {
  738. }
  739. public ViveControllerBehavior2 m_Pair;
  740. private readonly string[] m_strMode = new string[]
  741. {
  742. "HAND",
  743. "CAMERA",
  744. "PEN",
  745. "DANCE",
  746. string.Empty,
  747. string.Empty,
  748. string.Empty,
  749. string.Empty,
  750. "COMMAND"
  751. };
  752. private bool[] m_bModeHide = new bool[]
  753. {
  754. false,
  755. false,
  756. true,
  757. false,
  758. false,
  759. true,
  760. true,
  761. true,
  762. true
  763. };
  764. private readonly string[] m_strPointerMode = new string[]
  765. {
  766. "-LASER"
  767. };
  768. private readonly string[] m_strMoveMode = new string[]
  769. {
  770. "-DIR",
  771. "-DRAW",
  772. "-ARC"
  773. };
  774. private ViveControllerBehavior2.OvrControllerMode[][] m_aryModeLimit = new ViveControllerBehavior2.OvrControllerMode[][]
  775. {
  776. new ViveControllerBehavior2.OvrControllerMode[]
  777. {
  778. ViveControllerBehavior2.OvrControllerMode.HAND,
  779. ViveControllerBehavior2.OvrControllerMode.CAMERA,
  780. ViveControllerBehavior2.OvrControllerMode.ITEM
  781. },
  782. new ViveControllerBehavior2.OvrControllerMode[]
  783. {
  784. ViveControllerBehavior2.OvrControllerMode.DANCE
  785. },
  786. new ViveControllerBehavior2.OvrControllerMode[]
  787. {
  788. ViveControllerBehavior2.OvrControllerMode.HAND,
  789. ViveControllerBehavior2.OvrControllerMode.CAMERA,
  790. ViveControllerBehavior2.OvrControllerMode.ITEM,
  791. ViveControllerBehavior2.OvrControllerMode.VRIK_FACE,
  792. ViveControllerBehavior2.OvrControllerMode.VRIK_HAND
  793. }
  794. };
  795. [NonSerialized]
  796. private ViveControllerBehavior2.OvrControllerMode m_eMode;
  797. private ViveControllerBehavior2.OvrControllerMode m_eModeBack;
  798. private ViveControllerBehavior2.HandSubMode m_eHandSubMode = ViveControllerBehavior2.HandSubMode.MAN_HAND;
  799. private bool m_bWheelFirst;
  800. private float m_fWheel;
  801. private bool m_bArcNow;
  802. private float m_fGripTime;
  803. private bool m_bGripDown;
  804. private bool m_bMoveDrawMode;
  805. private bool m_bTabletArea;
  806. private float m_fTabletScaleBef;
  807. private float m_fOtherDistanceOne;
  808. private bool m_bTabletScaleGrab;
  809. private bool m_bIsInit;
  810. private bool m_bPressTrigger;
  811. private bool m_bSnapRot;
  812. private float m_fCamRotNow;
  813. private bool m_bSmoothRot;
  814. private bool m_bSmoothUpDown;
  815. private enum OvrControllerMode
  816. {
  817. HAND,
  818. CAMERA,
  819. PEN,
  820. DANCE,
  821. ITEM,
  822. VRIK_FACE,
  823. VRIK_HAND,
  824. VRIK_OTHER,
  825. YOTOGI,
  826. MAX
  827. }
  828. private enum PointerSubMode
  829. {
  830. LASER,
  831. MAX
  832. }
  833. private enum MoveSubMode
  834. {
  835. DIRECTIONAL,
  836. DRAW,
  837. ARC,
  838. MAX
  839. }
  840. private enum TouchSubMode
  841. {
  842. MAN,
  843. WOMAN
  844. }
  845. private enum HandSubMode
  846. {
  847. CONTROLLER,
  848. MAN_HAND,
  849. MAX
  850. }
  851. }