VRMiniGameSetup.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using UnityEngine;
  5. public class VRMiniGameSetup : MonoBehaviour
  6. {
  7. public VRMiniGameGaugeeManager GaugeManager
  8. {
  9. get
  10. {
  11. return this.m_GaugeManager;
  12. }
  13. }
  14. public AVRControllerButtons VRController
  15. {
  16. get
  17. {
  18. return this.m_Controller;
  19. }
  20. }
  21. public bool Is2DMode
  22. {
  23. get
  24. {
  25. return this.m_Is2DMode;
  26. }
  27. }
  28. public OvrCamera UseCamera
  29. {
  30. get
  31. {
  32. return this.m_UseCamera;
  33. }
  34. }
  35. private IEnumerator Start()
  36. {
  37. while (SceneVRCommunication.Instance == null)
  38. {
  39. yield return null;
  40. }
  41. SceneVRCommunication.VR_TIME nowTime = SceneVRCommunication.Instance.GetNowTime();
  42. if (nowTime == SceneVRCommunication.VR_TIME.NIGHT)
  43. {
  44. if (this.m_MiniGameType == VRMiniGameManager.VRMiniGameType.Wanage)
  45. {
  46. GameMain.Instance.BgMgr.ChangeBg("Villa_Farm_Night");
  47. }
  48. else if (this.m_MiniGameType == VRMiniGameManager.VRMiniGameType.Darts)
  49. {
  50. GameMain.Instance.BgMgr.ChangeBg("Villa_BedRoom_Night");
  51. }
  52. }
  53. else if (this.m_MiniGameType == VRMiniGameManager.VRMiniGameType.Wanage)
  54. {
  55. GameMain.Instance.BgMgr.ChangeBg("Villa_Farm");
  56. }
  57. else if (this.m_MiniGameType == VRMiniGameManager.VRMiniGameType.Darts)
  58. {
  59. GameMain.Instance.BgMgr.ChangeBg("Villa_BedRoom");
  60. }
  61. while (GameMain.Instance.OvrMgr == null)
  62. {
  63. yield return null;
  64. }
  65. while (VRMiniGameManager.Instance == null)
  66. {
  67. yield return null;
  68. }
  69. GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
  70. while (GameMain.Instance.MainCamera.IsFadeProc())
  71. {
  72. yield return null;
  73. }
  74. this.m_BGMName = Path.ChangeExtension(this.m_BGMName, "ogg");
  75. GameMain.Instance.SoundMgr.PlayBGM(this.m_BGMName, 0.5f, true);
  76. this.m_UseCamera = GameMain.Instance.OvrMgr.OvrCamera;
  77. yield return null;
  78. this.m_UseCamera.ForceHideUI(true);
  79. if (this.m_PlayerPosition)
  80. {
  81. Vector3 position = this.m_PlayerPosition.position;
  82. Quaternion rotation = this.m_PlayerPosition.rotation;
  83. position = new Vector3(position.x, this.m_UseCamera.GetHeightStandAndSit(CameraMain.STAND_SIT.STAND), position.z);
  84. this.m_UseCamera.SetPos(position);
  85. this.m_UseCamera.SetRotation(rotation.eulerAngles);
  86. }
  87. if (this.m_MaidPosition)
  88. {
  89. Vector3 position2 = this.m_MaidPosition.position;
  90. GameMain.Instance.CharacterMgr.SetCharaAllPos(position2);
  91. Vector3 charaAllRot = new Vector3(0f, Quaternion.LookRotation(this.m_PlayerPosition.position - position2).eulerAngles.y, 0f);
  92. GameMain.Instance.CharacterMgr.SetCharaAllRot(charaAllRot);
  93. }
  94. this.m_Is2DMode = false;
  95. GameMain.VRDeviceType device = GameMain.Instance.VRDeviceTypeID;
  96. if (device == GameMain.VRDeviceType.NON || device == GameMain.VRDeviceType.RIFT || device == GameMain.VRDeviceType.FOVE)
  97. {
  98. this.m_Is2DMode = true;
  99. }
  100. VRMiniGameManager.Instance.Init(this.m_MiniGameType);
  101. if (this.m_DecideHandUIPosition && this.m_ScoreBoardUIPosition)
  102. {
  103. VRMiniGameManager.Instance.StartRightLeftHand(this.m_DecideHandUIPosition.position, this.m_DecideHandUIPosition.rotation, delegate(AVRController hand)
  104. {
  105. if (hand != null)
  106. {
  107. this.$this.m_Controller = hand.VRControllerButtons;
  108. }
  109. else
  110. {
  111. VRMiniGameManager.Instance.VRController = this.$this.m_Controller;
  112. }
  113. VRMiniGameManager.Instance.CreateScoreBoard(this.$this.m_ScoreBoardUIPosition.position, this.$this.m_ScoreBoardUIPosition.rotation);
  114. for (int i = 0; i < this.$this.m_GoEnableObjects.Length; i++)
  115. {
  116. if (this.$this.m_GoEnableObjects[i] != null)
  117. {
  118. this.$this.m_GoEnableObjects[i].SetActive(true);
  119. }
  120. }
  121. });
  122. }
  123. yield return null;
  124. this.m_GaugeManager.ChangeDeviceMode(device);
  125. this.m_GaugeManager.Stop();
  126. this.m_GaugeManager.enabledMouseClickEvent = true;
  127. yield break;
  128. }
  129. private void Update()
  130. {
  131. if (this.m_Is2DMode && this.m_Controller != null && this.m_UseCamera != null && this.m_UseCamera.m_goCenterEye != null)
  132. {
  133. this.m_Controller.transform.position = this.m_UseCamera.m_goCenterEye.transform.position + this.m_UseCamera.m_goCenterEye.transform.forward * 0.2f;
  134. this.m_Controller.transform.rotation = Quaternion.LookRotation(this.m_Controller.transform.position - this.m_UseCamera.m_goCenterEye.transform.position);
  135. }
  136. }
  137. [SerializeField]
  138. [Tooltip("主人公の位置")]
  139. private Transform m_PlayerPosition;
  140. [SerializeField]
  141. [Tooltip("メイドの位置")]
  142. private Transform m_MaidPosition;
  143. [SerializeField]
  144. [Tooltip("利き手を決めるUIの位置")]
  145. private Transform m_DecideHandUIPosition;
  146. [SerializeField]
  147. [Tooltip("スコアボードUIの位置")]
  148. private Transform m_ScoreBoardUIPosition;
  149. [SerializeField]
  150. [Tooltip("ミニゲーム種類")]
  151. private VRMiniGameManager.VRMiniGameType m_MiniGameType;
  152. [SerializeField]
  153. [Tooltip("2D用ゲージマネージャー")]
  154. private VRMiniGameGaugeeManager m_GaugeManager;
  155. [SerializeField]
  156. [Tooltip("利き手が決定した直後に有効化するゲームオブジェクト")]
  157. private GameObject[] m_GoEnableObjects;
  158. [SerializeField]
  159. [Tooltip("ミニゲームに使用するコントローラ")]
  160. private AVRControllerButtons m_Controller;
  161. private string m_BGMName = "BGM_vr0007";
  162. private bool m_Is2DMode;
  163. private OvrCamera m_UseCamera;
  164. }