using System; using UnityEngine; public class FoveCamera : OvrCamera { public override bool IsBloomEnabled { get { return this.m_BloomOVR.enabled; } } public override bool IsNoHandController { get { return true; } } public override AVRControllerBehavior.LIMIT_MODE HandLimitMode { get { return AVRControllerBehavior.LIMIT_MODE.NORMAL; } set { } } protected override void Awake() { this.m_goCenterEye = UTY.GetChildObject(base.gameObject, "Fove Interface", false); this.m_trCenterEye = this.m_goCenterEye.transform; this.m_trRealHead = this.m_trCenterEye; this.m_camMonitor = UTY.GetChildObject(base.gameObject, "Fove Interface/MonitorCamera", false).GetComponent(); this.m_FadeTargetCameraOVR = this.m_camMonitor.GetComponent(); this.m_BloomOVR = this.m_camMonitor.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_goCenterEye, "UI", false); this.m_goOvrUiTablet = UTY.GetChildObject(base.gameObject, "Odogu_TabletPC", false); this.m_OvrTablet = this.m_goOvrUiTablet.GetComponent(); this.m_OvrTablet.Init(this.m_goCenterEye); Vignetting vignetting = base.gameObject.AddComponent(); vignetting.enabled = false; Camera component = base.gameObject.GetComponent(); component.enabled = false; this.m_trBaseHead = new GameObject("FoveCamBaseHead").transform; this.m_trBaseHead.SetParent(GameMain.Instance.transform, false); this.m_trBaseRoomBase = new GameObject("BaseRoomBase").transform; this.m_trBaseRoomBase.SetParent(this.m_trBaseHead, false); this.m_goEyeTargetMgr = UTY.GetChildObject(base.gameObject, "EyeTargetMgr", false); this.m_VREvnetText = this.m_trCenterEye.Find("VREventText").GetComponent(); Transform transform = this.m_trCenterEye.Find("EyeRayCaster"); this.m_EyeRay = transform.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); Transform transform2 = base.transform.Find("Controller (left)"); Transform transform3 = base.transform.Find("Controller (right)"); this.m_VRCtrlLeft = transform2.GetComponent(); this.m_VRCtrlLeft.Init(); this.m_VRCtrlRight = transform3.GetComponent(); this.m_VRCtrlRight.Init(); } public override void Start() { this.m_camLeftEye = UTY.GetChildObject(base.gameObject, "Fove Interface/FOVE Eye (Left)", false).GetComponent(); this.m_camRightEye = UTY.GetChildObject(base.gameObject, "Fove Interface/FOVE Eye (Right)", false).GetComponent(); this.m_FadeLeft = this.m_camLeftEye.GetComponent(); this.m_FadeRight = this.m_camRightEye.GetComponent(); this.m_BloomLeft = this.m_camLeftEye.GetComponent(); this.m_BloomRight = this.m_camRightEye.GetComponent(); this.m_BloomLeft.bloomIntensity = this.m_fBloomDefIntensity; this.m_BloomRight.bloomIntensity = this.m_fBloomDefIntensity; this.m_camMonitor.gameObject.SetActive(true); this.ChangeControllerNew(GameMain.Instance.CMSystem.OvrUseNewControllerType); this.m_OvrTablet.UIStickyHead = true; this.UpdateHeadScale(); } public override void ChangeControllerNew(bool f_bNew) { if (f_bNew) { this.m_goOvrUiScreen.SetActive(false); this.m_goOvrUiTablet.SetActive(true); this.m_goOvrUiNow = this.m_goOvrUiTablet; } else { this.m_goOvrUiScreen.SetActive(true); this.m_goOvrUiTablet.SetActive(false); this.m_goOvrUiNow = this.m_goOvrUiScreen; } this.m_bControllerModeNew = f_bNew; } public override void DefaultControllerMode(bool f_bEnable) { } public override void ReCallcOffset() { Vector3 position = this.m_trBaseHead.position; Quaternion rotation = this.m_trBaseHead.rotation; this.m_trBaseHead.position = this.m_trRealHead.position; Vector3 eulerAngles = this.m_trRealHead.rotation.eulerAngles; this.m_trBaseHead.rotation = Quaternion.Euler(0f, eulerAngles.y, 0f); this.m_trBaseRoomBase.position = base.transform.position; this.m_trBaseRoomBase.rotation = base.transform.rotation; this.m_trBaseHead.position = position; Vector3 eulerAngles2 = rotation.eulerAngles; this.m_trBaseHead.rotation = Quaternion.Euler(0f, eulerAngles2.y, 0f); } 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 void SetPos(Vector3 f_vecWorldPos) { this.m_trBaseHead.position = f_vecWorldPos; } public override Vector3 GetPos() { return this.m_trBaseHead.position; } public override void SetRotation(Vector3 f_vecWorldRot) { this.m_trBaseHead.rotation = Quaternion.Euler(f_vecWorldRot); } public override void SetRealHeadPos(Vector3 f_vecWorldPos, bool f_bYFromFloor = false) { if (f_bYFromFloor) { f_vecWorldPos.y = this.GetYfromFloor(f_vecWorldPos); } Vector3 position = this.m_trBaseRoomBase.position; this.m_trBaseHead.position = f_vecWorldPos; Vector3 b = f_vecWorldPos - this.GetRealHeadTransform().position; this.m_trBaseRoomBase.position = position + b; } 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); } this.m_trBaseRoomBase.position = base.transform.position; this.m_trBaseRoomBase.rotation = base.transform.rotation; float num = f_vecWorldRot.y - realHeadTransform.rotation.eulerAngles.y; f_vecWorldRot.y = realHeadTransform.rotation.eulerAngles.y + num; this.SetRotation(f_vecWorldRot); } 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); 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; Quaternion rotation = Quaternion.LookRotation(new Vector3(this.m_trTarget.position.x, 0f, this.m_trTarget.position.z) - new Vector3(this.m_trVirtualMy.position.x, 0f, this.m_trVirtualMy.position.z)); this.m_trBaseHead.rotation = rotation; } 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; this.m_FadeLeft.intensity = f_fIntensity; this.m_FadeRight.intensity = f_fIntensity; } protected override void OnOverlayState(bool f_bEnable) { this.m_FadeTargetCameraOVR.enabled = f_bEnable; this.m_FadeLeft.enabled = f_bEnable; this.m_FadeRight.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); } public override void CheckSwitchManHeadEnable(Vector3 f_vMyGlovalPos) { if (this.m_bIsSceneYotogi) { Maid man = GameMain.Instance.CharacterMgr.GetMan(0); if (man != null && man.body0 != null && man.body0.trsHead != null && man.Visible) { if (this.m_bBefManHeadEnable) { if ((man.body0.trsHead.position - f_vMyGlovalPos).sqrMagnitude < 0.2f) { SkinnedMeshRenderer componentInChildren = man.body0.trsHead.GetComponentInChildren(true); if (componentInChildren != null) { componentInChildren.enabled = false; this.m_bBefManHeadEnable = false; } } } else if ((man.body0.trsHead.position - f_vMyGlovalPos).sqrMagnitude >= 0.2f) { SkinnedMeshRenderer componentInChildren2 = man.body0.trsHead.GetComponentInChildren(true); if (componentInChildren2 != null) { componentInChildren2.enabled = true; this.m_bBefManHeadEnable = true; } } } } } protected override void Update() { if (GameMain.Instance == null) { return; } if (!base.IsUIShow) { UICamera.InputEnable = false; } 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 (this.m_BloomOVR.enabled != enabled) { GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver); } if (this.m_BloomLeft != null) { this.m_BloomLeft.enabled = this.m_BloomOVR.enabled; this.m_BloomLeft.bloomIntensity = this.m_BloomOVR.bloomIntensity; } if (this.m_BloomRight != null) { this.m_BloomRight.enabled = this.m_BloomOVR.enabled; this.m_BloomRight.bloomIntensity = this.m_BloomOVR.bloomIntensity; } } 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 (this.IsNoHandController && 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 * -1f * vector.x + this.vUp * vector.y) * (this.m_MoveSpeed * Time.deltaTime); } if (NInput.GetMouseButton(1)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), NInput.GetAxis(this.mouseAxisX) * -1f * this.m_RotSpeed * Time.deltaTime); } } 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 (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), -40f * base.RotSpeedAccel * Time.deltaTime); } if (Input.GetKey(KeyCode.E)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 40f * base.RotSpeedAccel * Time.deltaTime); } if (this.IsNoHandController && !base.IsUIShow && GameMain.Instance.CMSystem.OvrMouseRot) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 60f * NInput.GetAxis("Mouse X") * base.RotMouseSpeedAccel * Time.deltaTime); } if (Input.GetKeyUp(KeyCode.R)) { this.ReCallcOffset(); } if (Input.GetKeyUp(KeyCode.M)) { this.m_camMonitor.gameObject.SetActive(!this.m_camMonitor.gameObject.activeSelf); Debug.Log("モニター表示切替=" + this.m_camMonitor.gameObject.activeSelf); } if (Input.GetKeyUp(KeyCode.T)) { this.m_goEyeTargetMgr.SetActive(!this.m_goEyeTargetMgr.activeSelf); Debug.Log("視線ターゲット表示切替=" + this.m_goEyeTargetMgr.activeSelf); } if (Input.GetKeyUp(KeyCode.U)) { GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true); GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f); } 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.GetKey(KeyCode.Tab)) { this.m_labelHeadScale.enabled = true; if (Input.GetKey(KeyCode.C)) { GameMain.Instance.CMSystem.OvrHeadScale += 0.1f * Time.deltaTime; this.UpdateHeadScale(); } if (Input.GetKey(KeyCode.V)) { GameMain.Instance.CMSystem.OvrHeadScale -= 0.1f * Time.deltaTime; this.UpdateHeadScale(); } this.m_labelHeadScale.text = "Head Scale " + GameMain.Instance.CMSystem.OvrHeadScale; this.bTab = true; } else if (this.bTab) { this.m_labelHeadScale.enabled = false; this.bTab = false; } if (this.IsNoHandController && Input.GetKeyUp(KeyCode.Space)) { this.ToggleUI(); } base.transform.position = this.m_trBaseRoomBase.position; base.transform.rotation = this.m_trBaseRoomBase.rotation; this.CheckSwitchManHeadEnable(this.m_trRealHead.position); } 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 Camera m_camMonitor; private Camera m_camLeftEye; private Camera m_camRightEye; private ScreenOverlay m_FadeLeft; private ScreenOverlay m_FadeRight; private Bloom m_BloomLeft; private Bloom m_BloomRight; private GameObject m_goEyeTargetMgr; private enum MouseButtonDown { MBD_LEFT, MBD_RIGHT, MBD_MIDDLE } }