using System; using UnityEngine; public class DummyVRCamera : OvrCamera { public override bool IsNoHandController { get { return true; } } protected override void Awake() { this.m_fDistanceRate = 1.4f; this.m_trRealHead = UTY.GetChildObject(base.gameObject, "Main Camera (head)", false).transform; this.m_goCenterEye = UTY.GetChildObject(base.gameObject, "Main Camera (head)/Main Camera (eye)", false); this.m_trCenterEye = this.m_goCenterEye.transform; this.m_camMain = this.m_goCenterEye.GetComponent(); this.m_FadeTargetCameraOVR = this.m_goCenterEye.GetComponent(); this.m_BloomOVR = this.m_goCenterEye.GetComponent(); this.m_fBloomDefIntensity = this.m_BloomOVR.bloomIntensity; this.m_trTarget = new GameObject("OVRCamTarget").transform; this.m_trTarget.SetParent(GameMain.Instance.transform, false); this.m_trVirtualMy = new GameObject("OVRCamMy").transform; this.m_trVirtualMy.SetParent(GameMain.Instance.transform, false); GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("OVR/OvrHeadScale")) as GameObject; gameObject.SetActive(true); GameObject gameObject2 = GameObject.Find("SystemUI Root"); gameObject.transform.SetParent(gameObject2.transform, false); this.m_labelHeadScale = gameObject.GetComponentInChildren(); this.m_labelHeadScale.enabled = false; this.m_goOvrUiScreen = UTY.GetChildObject(this.m_trRealHead.gameObject, "UI", false); this.m_goOvrUiTablet = UTY.GetChildObject(base.gameObject, "Odogu_TabletPC", false); this.m_trOvrUiTablet = this.m_goOvrUiTablet.transform; this.m_OvrTablet = this.m_goOvrUiTablet.GetComponent(); this.m_OvrTablet.Init(this.m_trRealHead.gameObject); Vignetting vignetting = base.gameObject.AddComponent(); vignetting.enabled = false; Camera component = base.gameObject.GetComponent(); component.enabled = false; this.m_trBaseHead = new GameObject("DummyVRCamBaseHead").transform; this.m_trBaseHead.SetParent(GameMain.Instance.transform, false); this.m_trCursorLaserHit = this.m_goOvrUiScreen.transform.Find("ovr_screen/hit"); NDebug.Assert(this.m_trCursorLaserHit != null, "UI Cursor Hit オブジェクトが見つかりません。"); float ovrViveCursorLaserHitScale = GameMain.Instance.CMSystem.OvrViveCursorLaserHitScale; this.m_trCursorLaserHit.localScale = new Vector3(ovrViveCursorLaserHitScale, ovrViveCursorLaserHitScale, ovrViveCursorLaserHitScale); this.m_VREvnetText = this.m_trRealHead.Find("VREventText").GetComponent(); Texture2D texture2D = Resources.Load("System/Texture/black"); SteamVR_Skybox.SetOverride(texture2D, texture2D, texture2D, texture2D, texture2D, texture2D); Transform transform = base.transform.Find("Controller (left)"); Transform transform2 = base.transform.Find("Controller (right)"); this.m_VRCtrlLeft = transform.GetComponent(); this.m_VRCtrlLeft.Init(); this.m_VRCtrlRight = transform2.GetComponent(); this.m_VRCtrlRight.Init(); Transform transform3 = this.m_trRealHead.Find("EyeRayCaster"); this.m_EyeRay = transform3.GetComponent(); NDebug.Assert(this.m_EyeRay != null, "視線検出機構がみつかりません。"); this.m_DummyHand = base.transform.Find("HandPlayer").GetComponent(); NDebug.Assert(this.m_DummyHand != null, "HandPlayer が見つかりません。"); this.m_DummyHand.gameObject.SetActive(false); this.UpdateHeadScale(); this.m_bWheelToZoom = true; } public override void Start() { this.m_goOvrUiScreen.SetActive(false); this.m_goOvrUiTablet.SetActive(true); this.m_goOvrUiNow = this.m_goOvrUiTablet; this.ReCallcOffset(); } public override void ChangeControllerNew(bool f_bNew) { } public override void DefaultControllerMode(bool f_bEnable) { } public override void ReCallcOffset() { } public override void OnLevelWasLoaded(int level) { base.OnLevelWasLoaded(level); this.m_bDummyYotogiCamera = this.m_bIsSceneYotogi; this.m_bIsSceneYotogi = false; } public override void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible) { if (f_bVisible) { } } public override void CameraMaskReset() { } public override void SetCameraType(CameraMain.CameraType f_eType) { } public override CameraMain.CameraType GetCameraType() { return CameraMain.CameraType.Free; } public override void SetControl(bool f_bEnable) { } public override bool GetControl() { return true; } public override void SetTargetPos(Vector3 f_vecWorldPos, bool f_bSelf = true) { if (f_bSelf) { iTween.StopAndSkipToEnd(base.gameObject); } this.m_trTarget.position = f_vecWorldPos; this.SetTransform(this.m_trTarget.position, this.m_vRot, this.m_fDistance); } public override Vector3 GetTargetPos() { return this.m_trTarget.position; } public override void SetDistance(float f_fDistance, bool f_bSelf = true) { if (f_bSelf) { iTween.StopAndSkipToEnd(base.gameObject); } this.m_fDistance = f_fDistance; this.SetTransform(this.m_trTarget.position, this.m_vRot, this.m_fDistance); } public override float GetDistance() { return this.m_fDistance; } public override void SetAroundAngle(Vector2 f_vecAngle, bool f_bSelf = true) { if (f_bSelf) { iTween.StopAndSkipToEnd(base.gameObject); } this.SetTransform(this.m_trTarget.position, f_vecAngle, this.m_fDistance); } public override Vector2 GetAroundAngle() { return this.m_vRot; } public override void SetTargetOffset(Vector3 f_vOffs, bool f_bSelf = true) { } public override Vector3 GetPos() { return this.m_trBaseHead.position; } public override void SetRealHeadPos(Vector3 f_vecWorldPos, bool f_bYFromFloor = false) { if (f_bYFromFloor) { f_vecWorldPos.y = this.GetYfromFloor(f_vecWorldPos); } this.m_trBaseHead.position = f_vecWorldPos; this.UpdateRealPosRot(); } public override void SetRealHeadRot(Vector3 f_vecWorldRot, bool f_bRotYOnly = true) { Transform realHeadTransform = this.GetRealHeadTransform(); this.m_trBaseHead.position = realHeadTransform.position; if (f_bRotYOnly) { this.m_trBaseHead.rotation = Quaternion.Euler(0f, realHeadTransform.rotation.eulerAngles.y, 0f); } else { this.m_trBaseHead.rotation = Quaternion.Euler(f_vecWorldRot); } float num = f_vecWorldRot.y - realHeadTransform.rotation.eulerAngles.y; f_vecWorldRot.y = realHeadTransform.rotation.eulerAngles.y + num; this.m_trBaseHead.rotation = Quaternion.Euler(f_vecWorldRot); this.UpdateRealPosRot(); } public override void SetFootPos(Vector3 f_vecFootPos, CameraMain.STAND_SIT f_eState) { if (f_eState == CameraMain.STAND_SIT.STAND) { f_vecFootPos.y += GameMain.Instance.CMSystem.VRCameraHeightStandOffs; } else if (f_eState == CameraMain.STAND_SIT.SIT) { f_vecFootPos.y += GameMain.Instance.CMSystem.VRCameraHeightSitOffs; } else { f_vecFootPos.y += this.GetYfromFloor(this.GetRealHeadTransform().position); } this.SetRealHeadPos(f_vecFootPos, false); } public override Transform GetBaseHeadTransform() { return this.m_trBaseHead; } public override Transform GetRealHeadTransform() { return this.m_trRealHead; } private void SetTransform(Vector3 f_vecTargetPosWorld, Vector2 f_vecRot, float f_fDistance) { this.m_trTarget.position = f_vecTargetPosWorld; this.m_vRot = f_vecRot; this.m_trVirtualMy.rotation = Quaternion.identity; this.m_trVirtualMy.Rotate(new Vector3(0f, f_vecRot.x, 0f), Space.World); this.m_trVirtualMy.Rotate(new Vector3(f_vecRot.y, 0f, 0f), Space.Self); if (this.m_bDummyYotogiCamera) { f_fDistance *= this.m_fDistanceRate; } this.m_trVirtualMy.position = this.m_trVirtualMy.rotation * new Vector3(0f, 0f, -f_fDistance) + this.m_trTarget.position; this.m_trBaseHead.position = this.m_trVirtualMy.position + (this.m_trTarget.position - this.m_trVirtualMy.position) * 0.5f; this.m_trBaseHead.rotation = this.m_trVirtualMy.rotation; this.UpdateRealPosRot(); } public override void Reset(CameraMain.CameraType f_eType, bool f_bControl) { iTween.StopAndSkipToEnd(base.gameObject); base.RemoveChaseCameraAll(); this.SetTargetPos(new Vector3(0f, 1.5f, 0f), true); } public override void FadeOutNoUI(float f_fTime = 0.5f, bool f_bSkipable = true) { } public override void FadeInNoUI(float f_fTime = 0.5f, bool f_bSkipable = true) { } protected override float GetFadeIntensity() { return this.m_FadeTargetCameraOVR.intensity; } protected override void OnProcessFade(float f_fIntensity) { this.m_FadeTargetCameraOVR.intensity = f_fIntensity; } protected override void OnOverlayState(bool f_bEnable) { this.m_FadeTargetCameraOVR.enabled = f_bEnable; } public override Ray GetForwardRay() { return new Ray(this.m_trCenterEye.position, this.m_trCenterEye.rotation * Vector3.forward); } public override void UpdateHeadScale() { float ovrHeadScale = GameMain.Instance.CMSystem.OvrHeadScale; base.gameObject.transform.localScale = new Vector3(ovrHeadScale, ovrHeadScale, ovrHeadScale); this.m_trBaseHead.localScale = base.gameObject.transform.localScale; } protected override void UpdateRealPosRot() { base.transform.position = this.m_trBaseHead.position; base.transform.rotation = this.m_trBaseHead.rotation; this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero)); } public override void MirrorSwitch() { } public override void UIPosReset(float f_fOffsetRotY = 0f) { } protected override void Update() { if (GameMain.Instance == null) { return; } if (!base.IsUIShow) { UICamera.InputEnable = false; } if (this.m_DummyHand != null) { this.m_DummyHand.Show = (this.m_unDummyHandVisibleFlag != 0u); } if (this.m_BloomOVR != null) { bool enabled = this.m_BloomOVR.enabled; this.m_BloomOVR.enabled = GameMain.Instance.CMSystem.Bloom; this.m_BloomOVR.bloomIntensity = this.m_fBloomDefIntensity * (float)GameMain.Instance.CMSystem.BloomValue * 0.01f; if (this.m_BloomOVR.bloomIntensity <= 0.01f) { this.m_BloomOVR.enabled = false; } else { this.m_BloomOVR.enabled = true; } if (base.IsUIShow) { this.m_BloomOVR.enabled = false; } if (this.m_BloomOVR.enabled != enabled) { GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver); } } float vrcameraFov = GameMain.Instance.CMSystem.VRCameraFov; if (this.m_fBackFOV != vrcameraFov) { this.m_camMain.fieldOfView = vrcameraFov; float num = (vrcameraFov - 30f) / 30f; float num2 = 0.23f + 0.17f * num; this.m_VREvnetText.gameObject.transform.localScale = new Vector3(num2, num2, num2); this.m_fBackFOV = vrcameraFov; } RaycastHit raycastHit; if (Physics.Raycast(this.m_camMain.ScreenPointToRay(Input.mousePosition), out raycastHit, float.PositiveInfinity, 33554432)) { Vector2 textureCoord = raycastHit.textureCoord; Vector2 v = new Vector2(1280f * (textureCoord.x / 1f), 720f * (textureCoord.y / 1f)); GameMain.Instance.OvrMgr.SystemUICamera.SetOvrVirtualMousePos(false, v); } this.m_bSlideMoving = false; this.vFowerd = this.m_trCenterEye.rotation * Vector3.forward; this.vLeft = this.m_trCenterEye.rotation * Vector3.left; this.vUp = this.m_trCenterEye.rotation * Vector3.up; if (GameMain.Instance.CMSystem.VRCameraPlaneMove) { this.vLeft.y = (this.vFowerd.y = 0f); this.vLeft.Normalize(); this.vFowerd.Normalize(); this.vUp = Vector3.up; } this.v = this.m_trBaseHead.position; if (this.m_bFallThrough || !this.m_bUiToggle) { if (this.m_bWheelToZoom && !base.IsUIShow) { this.v += this.vFowerd * (NInput.GetAxis(this.mouseAxisZoom) * (this.m_MoveSpeed * 10f * Time.deltaTime)); } if (NInput.GetMouseButton(2)) { Vector3 vector = new Vector3(-NInput.GetAxis(this.mouseAxisX), -NInput.GetAxis(this.mouseAxisY), 0f); this.v += this.vLeft * (vector.x * this.m_MoveSpeed * Time.deltaTime); this.v -= this.vUp * (vector.y * this.m_MoveSpeed * Time.deltaTime); this.m_bSlideMoving = true; } if (NInput.GetMouseButton(1)) { } } if (NInput.GetMouseButton(1)) { this.vMouseMoving += new Vector2(Math.Abs(NInput.GetAxis("Mouse X")), Math.Abs(NInput.GetAxis("Mouse Y"))); } else { if ((this.m_bFallThrough || this.m_bIsForceRightClickUiToggle) && NInput.GetMouseButtonUp(1) && this.vMouseMoving.magnitude < 3f && this.m_bRightClickUIToggle) { this.ToggleUI(); } this.vMouseMoving = Vector2.zero; } if (GameMain.Instance.MainCamera.GetFadeState() != CameraMain.FadeState.Out) { if (Input.GetKey(KeyCode.A)) { this.v += this.vLeft * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.A) * Time.deltaTime); } if (Input.GetKey(KeyCode.D)) { this.v -= this.vLeft * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.D) * Time.deltaTime); } if (Input.GetKey(KeyCode.W)) { this.v += this.vFowerd * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.W) * Time.deltaTime); } if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.S)) { this.v -= this.vFowerd * (this.m_MoveSpeed * base.MoveSpeedAccel * this.MoveDashRate(KeyCode.S) * Time.deltaTime); } if (Input.GetKey(KeyCode.Z)) { this.v -= this.vUp * (this.m_MoveSpeed * base.MoveSpeedAccel * Time.deltaTime); } if (Input.GetKey(KeyCode.X)) { this.v += this.vUp * (this.m_MoveSpeed * base.MoveSpeedAccel * Time.deltaTime); } if (this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY) { this.m_trBaseHead.position = this.v; } if (Input.GetKey(KeyCode.Q)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), -90f * base.RotSpeedAccel * Time.deltaTime, Space.World); } if (Input.GetKey(KeyCode.E)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 90f * base.RotSpeedAccel * Time.deltaTime, Space.World); } if (!base.IsUIShow && !this.m_bSlideMoving && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height && Cursor.lockState == CursorLockMode.Locked && !Cursor.visible && !base.IsFadeOut()) { this.m_vHeadRotTarget.x = this.m_vHeadRotTarget.x - NInput.GetAxis("Mouse Y") * this.m_fHeadRotSpeed * base.RotMouseSpeedAccel; this.m_vHeadRotTarget.y = this.m_vHeadRotTarget.y + NInput.GetAxis("Mouse X") * this.m_fHeadRotSpeed * base.RotMouseSpeedAccel; this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), this.m_vHeadRotTarget.y - this.m_vHeadRotEaseBef.y, Space.World); float d = 1f; if (GameMain.Instance.CMSystem.VRCamRotDownUp) { d = -1f; } this.m_trBaseHead.Rotate(this.m_trBaseHead.right * d, this.m_vHeadRotTarget.x - this.m_vHeadRotEaseBef.x, Space.World); this.m_vHeadRotEaseBef = this.m_vHeadRotTarget; } else { this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero)); } } else { this.m_vHeadRotEaseBef = (this.m_vHeadRotEaseNow = (this.m_vHeadRotTarget = Vector2.zero)); } if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { this.SnapShotOVR(false); } else if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) { this.SnapShotOVR(true); } } if (Input.GetKeyUp(KeyCode.R)) { this.ReCallcOffset(); } if (Input.GetKeyUp(KeyCode.Space)) { this.ToggleUI(); } if (base.IsUIShow) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } else if (this.m_bUiShowBack) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } else { if (Input.GetKeyUp(KeyCode.Escape)) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } if (NInput.GetMouseButtonUp(0) && 0f <= Input.mousePosition.x && Input.mousePosition.x < (float)Screen.width && 0f <= Input.mousePosition.y && Input.mousePosition.y < (float)Screen.height) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } } base.transform.position = this.m_trBaseHead.position; base.transform.rotation = this.m_trBaseHead.rotation; this.CheckSwitchManHeadEnable(this.m_trRealHead.position); this.m_bUiShowBack = base.IsUIShow; } private void OnDrawGizmos() { if (this.m_trTarget != null) { Gizmos.DrawIcon(this.m_trTarget.position, "gizmo_eye.png", true); if (base.enabled) { Gizmos.color = Color.cyan; Gizmos.DrawRay(this.m_trVirtualMy.position, this.m_trTarget.position - this.m_trVirtualMy.position); Gizmos.DrawRay(this.m_trCenterEye.position, this.m_trCenterEye.rotation * Vector3.forward * 10f); } } } private Vector2 m_vHeadRotEaseNow = Vector2.zero; private Vector2 m_vHeadRotEaseBef = Vector2.zero; public float m_fHeadRotSpeed = 1.5f; public float m_fHeadRotEase = 0.5f; private Vector2 m_vHeadRotTarget = Vector2.zero; public float m_fDistanceRate = 1.4f; private ScreenOverlay m_Fade; private Camera m_camMain; private float m_fBackFOV; private bool m_bDummyYotogiCamera; private enum MouseButtonDown { MBD_LEFT, MBD_RIGHT, MBD_MIDDLE } }