using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.VR; public class OvrCamera : CameraMain { public float MoveSpeedAccel { get { return (0.05f + 0.9f * GameMain.Instance.CMSystem.VRCameraMoveSpeedKey) / 0.5f * 1.5f; } } public float RotSpeedAccel { get { return (0.05f + 0.9f * GameMain.Instance.CMSystem.VRCameraRotSpeedKey) / 0.5f; } } public float RotMouseSpeedAccel { get { return (0.05f + 0.9f * GameMain.Instance.CMSystem.VRCameraRotSpeedMouse) / 0.5f; } } public override bool IsBloomEnabled { get { return this.m_BloomOVR.enabled; } } public AVRControllerButtons GetVRControllerButtons(bool f_bLeft) { return (!f_bLeft) ? this.m_VRCtrlRight.VRControllerButtons : this.m_VRCtrlLeft.VRControllerButtons; } public OvrTablet OvrTablet { get { return this.m_OvrTablet; } } public bool IsUIShow { get { return this.m_bUiToggle; } } public VREventText OvrEventText { get { return this.m_VREvnetText; } } public OvrEyeRay EyeRay { get { return this.m_EyeRay; } } public bool IsHandCameraMode { get { return this.m_VRCtrlLeft.IsHandCameraMode || this.m_VRCtrlRight.IsHandCameraMode; } } public bool IsHandPenMode { get { return this.m_VRCtrlLeft.IsHandPenMode || this.m_VRCtrlRight.IsHandPenMode; } } public virtual bool IsNoHandController { get { return GameMain.Instance.VRDeviceTypeID != GameMain.VRDeviceType.RIFT_TOUCH && GameMain.Instance.VRDeviceTypeID != GameMain.VRDeviceType.VIVE; } } public virtual AVRControllerBehavior.LIMIT_MODE HandLimitMode { get { return this.m_eHandLimitMode; } set { AVRController vrctrlLeft = this.m_VRCtrlLeft; this.m_eHandLimitMode = value; this.m_VRCtrlRight.HandLimitMode = value; vrctrlLeft.HandLimitMode = value; } } public virtual bool HandDanceMode { get { return this.m_VRCtrlLeft.HandDanceMode && this.m_VRCtrlRight.HandDanceMode; } set { AVRController vrctrlLeft = this.m_VRCtrlLeft; this.m_VRCtrlRight.HandDanceMode = value; vrctrlLeft.HandDanceMode = value; } } public virtual bool HandVRIKMode { get { return this.m_VRCtrlLeft.HandVRIKMode && this.m_VRCtrlRight.HandVRIKMode; } set { AVRController vrctrlLeft = this.m_VRCtrlLeft; this.m_VRCtrlRight.HandVRIKMode = value; vrctrlLeft.HandVRIKMode = value; } } public virtual bool HandYotogiMode { get { return this.m_VRCtrlLeft.HandYotogiMode && this.m_VRCtrlRight.HandYotogiMode; } set { AVRController vrctrlLeft = this.m_VRCtrlLeft; this.m_VRCtrlRight.HandYotogiMode = value; vrctrlLeft.HandYotogiMode = value; } } public bool IsForceRightClickUiToggle { get { return this.m_bIsForceRightClickUiToggle; } set { this.m_bIsForceRightClickUiToggle = value; } } public bool HandModelVisible { set { AVRController vrctrlLeft = this.m_VRCtrlLeft; this.m_VRCtrlRight.HandModelVisible = value; vrctrlLeft.HandModelVisible = value; } } public bool IsControllerModeNew { get { return this.m_bControllerModeNew; } } protected override void Awake() { this.m_goCenterEye = UTY.GetChildObject(base.gameObject, "TrackingSpace/CenterEyeAnchor", false); this.m_trCenterEye = this.m_goCenterEye.transform; this.m_trRealHead = this.m_trCenterEye; this.m_nBackCullingMask = this.m_goCenterEye.GetComponent().cullingMask; 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_goCenterEye, "UI", false); this.m_goOvrUiTablet = UTY.GetChildObject(base.gameObject, "TrackingSpace/Odogu_TabletPC", false); this.m_trOvrUiTablet = this.m_goOvrUiTablet.transform; 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("OvrCamBaseHead").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_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_trCenterEye.Find("VREventText").GetComponent(); Transform transform = base.transform.Find("TrackingSpace/LeftHandAnchor"); Transform transform2 = base.transform.Find("TrackingSpace/RightHandAnchor"); this.m_VRCtrlLeft = transform.GetComponent(); this.m_VRCtrlLeft.Init(); this.m_VRCtrlRight = transform2.GetComponent(); this.m_VRCtrlRight.Init(); Transform transform3 = this.m_trCenterEye.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(); } public override void Start() { this.ChangeControllerNew(GameMain.Instance.CMSystem.OvrUseNewControllerType); this.ReCallcOffset(); } public virtual void Uninit() { if (this.m_labelHeadScale != null) { UnityEngine.Object.DestroyImmediate(this.m_labelHeadScale.gameObject); } if (this.m_trTarget != null) { UnityEngine.Object.DestroyImmediate(this.m_trTarget.gameObject); } if (this.m_trVirtualMy != null) { UnityEngine.Object.DestroyImmediate(this.m_trVirtualMy.gameObject); } if (this.m_trBaseHead != null) { UnityEngine.Object.DestroyImmediate(this.m_trBaseHead.gameObject); } } public virtual void ChangeControllerNew(bool f_bNew) { if (f_bNew) { this.m_VRCtrlLeft.ChangeControllerNew(true); this.m_VRCtrlRight.ChangeControllerNew(true); this.m_goOvrUiScreen.SetActive(false); this.m_goOvrUiTablet.SetActive(true); this.m_goOvrUiNow = this.m_goOvrUiTablet; } else { this.m_VRCtrlLeft.ChangeControllerNew(false); this.m_VRCtrlRight.ChangeControllerNew(false); this.m_goOvrUiScreen.SetActive(true); this.m_goOvrUiTablet.SetActive(false); this.m_goOvrUiNow = this.m_goOvrUiScreen; } this.m_bControllerModeNew = f_bNew; } public virtual void DefaultControllerMode(bool f_bEnable) { if (f_bEnable) { this.ChangeControllerNew(this.m_bControllerModeNew); } else { this.m_VRCtrlLeft.DefaultControllerMode(false); this.m_VRCtrlRight.DefaultControllerMode(false); this.m_goOvrUiScreen.SetActive(false); this.m_goOvrUiTablet.SetActive(false); } } public void ChangeToCameraMode(bool f_bStart) { if (!this.m_VRCtrlLeft.HandCameraMode && !this.m_VRCtrlRight.HandCameraMode) { this.m_VRCtrlRight.HandCameraMode = true; } } public void ChangeTouchUse(bool f_bTouchUse) { if (f_bTouchUse) { GameMain.Instance.VRDeviceTypeID = GameMain.VRDeviceType.RIFT_TOUCH; if (this.m_OvrTablet != null) { this.m_OvrTablet.UIStickyHead = false; } } else { GameMain.Instance.VRDeviceTypeID = GameMain.VRDeviceType.RIFT; if (this.m_OvrTablet != null) { this.m_OvrTablet.UIStickyHead = true; } } } public virtual void ReCallcOffset() { OVRManager.display.RecenterPose(); } public override void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible) { Camera component = this.m_goCenterEye.GetComponent(); if (f_bVisible) { component.cullingMask |= 1 << (int)f_eMask; } else { component.cullingMask &= ~(1 << (int)f_eMask); } } public override void CameraMaskReset() { Camera component = this.m_goCenterEye.GetComponent(); component.cullingMask = this.m_nBackCullingMask; } 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; this.UpdateRealPosRot(); } public override Vector3 GetPos() { return this.m_trBaseHead.position; } public override void SetRotation(Vector3 f_vecWorldRot) { this.m_trBaseHead.rotation = Quaternion.Euler(0f, f_vecWorldRot.y, 0f); this.UpdateRealPosRot(); } 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; 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); } 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.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); 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; this.UpdateRealPosRot(); } public override void StartAnimationTo(bool f_bStart, Vector3 f_vSCenter, float f_fSRadius, Vector2 f_vSRotate, Vector3 f_vCenter, float f_fRadius, Vector2 f_vRotate, float f_fTime, string f_strEaseType, bool f_bSkip, float f_fDelay) { iTween.EaseType easeType; if (string.IsNullOrEmpty(f_strEaseType)) { easeType = iTween.EaseType.linear; } else { easeType = (iTween.EaseType)Enum.Parse(typeof(iTween.EaseType), f_strEaseType); } Vector3 vector; float num; Vector2 vector2; if (!f_bStart) { vector = this.GetTargetPos(); num = this.GetDistance(); vector2 = this.GetAroundAngle(); } else { vector = f_vSCenter; num = f_fSRadius; vector2 = f_vSRotate; } this.m_bMoveSkip = f_bSkip; if (this.m_bMoveSkip && GameMain.Instance.IsForceSkip()) { this.SetTargetPos(f_vCenter, true); this.SetDistance(f_fRadius, true); this.SetAroundAngle(f_vRotate, true); this.m_vCenter = f_vCenter; this.m_fRadius = f_fRadius; this.m_vRotate = f_vRotate; } else { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", easeType, "from", vector, "to", f_vCenter, "time", f_fTime, "delay", f_fDelay, "onUpdate", "UpdateCamTgt", "onComplete", "CompleteCam" })); iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", easeType, "from", num, "to", f_fRadius, "time", f_fTime, "delay", f_fDelay, "onUpdate", "UpdateCamDistance", "onComplete", "CompleteCam" })); iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "easetype", easeType, "from", vector2, "to", f_vRotate, "time", f_fTime, "delay", f_fDelay, "onUpdate", "UpdateCamAngle", "onComplete", "CompleteCam" })); } } public override void UpdateCamTgt(Vector3 f_vValue) { this.m_vCenter = f_vValue; } public override void UpdateCamDistance(float f_vValue) { this.m_fRadius = f_vValue; } public override void UpdateCamAngle(Vector2 f_vAngle) { this.m_vRotate = f_vAngle; } public override void CompleteCam() { this.SetTargetPos(this.m_vCenter, false); this.SetDistance(this.m_fRadius, false); this.SetAroundAngle(this.m_vRotate, false); } 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 OnStartFadeIn() { if (this.m_bIsSceneYotogi) { this.PosToManHead(1f); this.m_OvrTablet.AvoidFloorAndChara(); } } protected override void OnOverlayState(bool f_bEnable) { this.m_FadeTargetCameraOVR.enabled = f_bEnable; } public virtual Ray GetForwardRay() { return new Ray(this.m_trCenterEye.position, this.m_trCenterEye.rotation * Vector3.forward); } public virtual void UpdateHeadScale() { float ovrHeadScale = GameMain.Instance.CMSystem.OvrHeadScale; base.gameObject.transform.localScale = new Vector3(ovrHeadScale, ovrHeadScale, ovrHeadScale); } protected virtual void UpdateRealPosRot() { base.transform.position = this.m_trBaseRoomBase.position; base.transform.rotation = this.m_trBaseRoomBase.rotation; } public virtual void ToggleUI() { this.ShowUI(!this.m_bUiToggle); } public virtual void ShowUI(bool f_bShow) { if (this.m_bUIForceHide) { f_bShow = false; } this.m_bUiToggle = f_bShow; if (this.m_goOvrUiNow != null) { OvrTablet component = this.m_goOvrUiNow.GetComponent(); if (component != null) { component.SetVisible(this.m_bUiToggle); } else { this.m_goOvrUiNow.SetActive(f_bShow); } } UICamera.InputEnable = f_bShow; } public virtual void ForceHideUI(bool f_bForceHide) { this.m_bUIForceHide = f_bForceHide; this.ShowUI(!f_bForceHide); } public virtual void UIPosReset(float f_fOffsetRotY = 0f) { if ((GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH || GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.VIVE) && this.m_OvrTablet != null) { this.m_OvrTablet.UIPosReset(f_fOffsetRotY); } } public virtual void PosToManHead(float f_fTime = 1f) { if (this.m_coToManHeadWait != null) { base.StopCoroutine(this.m_coToManHeadWait); this.m_coToManHeadWait = null; } this.m_coToManHeadWait = base.StartCoroutine(this.CoPosToManHead(f_fTime)); } private IEnumerator CoPosToManHead(float f_fTime) { float fTimeBef = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - fTimeBef < f_fTime) { Maid man = GameMain.Instance.CharacterMgr.GetMan(0); if (man == null) { yield return null; } if (man.body0 == null) { yield return null; } if (!man.Visible) { break; } Transform trAttach = man.body0.trsHead.Find("OvrCamAttach"); if (trAttach == null) { trAttach = new GameObject("OvrCamAttach").transform; trAttach.SetParent(man.body0.trsHead, false); trAttach.localPosition = new Vector3(-0.077f, 0.037f, 0f); } this.SetPos(trAttach.position); this.SetRotation(new Vector3(0f, man.body0.trsHead.rotation.eulerAngles.y + 90f, 0f)); yield return null; } this.m_coToManHeadWait = null; yield break; } public override void OnLevelWasLoaded(int level) { if (!(GameMain.Instance.GetNowSceneName() == "SceneYotogi") && !(GameMain.Instance.GetNowSceneName() == "SceneYotogiWithChubLip")) { if (string.IsNullOrEmpty(GameMain.Instance.GetAddSceneName().Find((string a) => a == "SceneYotogi"))) { if (string.IsNullOrEmpty(GameMain.Instance.GetAddSceneName().Find((string a) => a == "SceneYotogiWithChubLip"))) { this.m_bIsSceneYotogi = false; goto IL_B1; } } } this.m_bIsSceneYotogi = true; IL_B1: base.OnLevelWasLoaded(level); } public virtual 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 && !man.body0.IsManHide()) { 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; } } } } } public virtual void MirrorSwitch() { VRSettings.showDeviceView = !VRSettings.showDeviceView; } public virtual void ShowDummyHand(OvrCamera.DUMMY_HAND f_hand, Vector3 f_vWorldPos = default(Vector3), bool f_bGrab = false) { this.m_unDummyHandVisibleFlag |= (uint)f_hand; if (this.m_DummyHand != null) { this.m_DummyHand.Show = (this.m_unDummyHandVisibleFlag != 0u); this.m_DummyHand.Grab = f_bGrab; this.m_DummyHand.transform.position = f_vWorldPos; } } public virtual void HideDummyHand(OvrCamera.DUMMY_HAND f_hand) { this.m_unDummyHandVisibleFlag &= (uint)(~(uint)f_hand); if (this.m_DummyHand != null) { this.m_DummyHand.Show = (this.m_unDummyHandVisibleFlag != 0u); } } protected virtual void SnapShotOVR(bool f_bNoUI) { if (f_bNoUI) { if (!this.screen_shot_noui_) { this.screen_shot_noui_ = true; base.StartCoroutine(base.SaveScreenShotNoUI()); GameMain.Instance.SoundMgr.PlaySe("SE022.ogg", false); } } else if (!this.screen_shot_normal_) { this.screen_shot_normal_ = true; base.StartCoroutine(base.SaveScreenShotNormal()); GameMain.Instance.SoundMgr.PlaySe("SE022.ogg", false); } } protected virtual float MoveDashRate(KeyCode f_key) { float result = 1f; OvrCamera.PairKeyTime pairKeyTime; if (!this.m_dicKeyBack.TryGetValue(f_key, out pairKeyTime)) { OvrCamera.PairKeyTime pairKeyTime2 = new OvrCamera.PairKeyTime(); this.m_dicKeyBack[f_key] = pairKeyTime2; pairKeyTime = pairKeyTime2; } if (Input.GetKeyDown(f_key)) { if (Time.realtimeSinceStartup - pairKeyTime.fBackTime < 0.2f) { pairKeyTime.bDown = true; } else { pairKeyTime.bDown = false; } pairKeyTime.fBackTime = Time.realtimeSinceStartup; } if (Input.GetKey(f_key) && pairKeyTime.bDown) { result = 2.3f; } else { pairKeyTime.bDown = false; } return result; } protected override void Update() { if (GameMain.Instance == null) { return; } if (!this.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 (this.m_BloomOVR.enabled != enabled) { GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver); } } 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 (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 && !this.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); this.m_bSlideMoving = true; } 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; } Vector3 camMoveVelocity = this.m_VRCtrlLeft.GetCamMoveVelocity(); Vector3 camMoveVelocity2 = this.m_VRCtrlRight.GetCamMoveVelocity(); this.v += this.vLeft * (this.m_MoveSpeed * Time.deltaTime) * (camMoveVelocity.x + camMoveVelocity2.x); this.v += this.vFowerd * (this.m_MoveSpeed * Time.deltaTime) * (camMoveVelocity.z + camMoveVelocity2.z); this.v += this.vUp * (this.m_MoveSpeed * Time.deltaTime) * (camMoveVelocity.y + camMoveVelocity2.y); Vector3 vector2 = this.m_VRCtrlLeft.GetHandMoveVelocity() + this.m_VRCtrlRight.GetHandMoveVelocity(); this.v += vector2; if (Input.GetKey(KeyCode.A)) { this.v += this.vLeft * (this.m_MoveSpeed * this.MoveSpeedAccel * this.MoveDashRate(KeyCode.A) * Time.deltaTime); } if (Input.GetKey(KeyCode.D)) { this.v -= this.vLeft * (this.m_MoveSpeed * this.MoveSpeedAccel * this.MoveDashRate(KeyCode.D) * Time.deltaTime); } if (Input.GetKey(KeyCode.W)) { this.v += this.vFowerd * (this.m_MoveSpeed * this.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 * this.MoveSpeedAccel * this.MoveDashRate(KeyCode.S) * Time.deltaTime); } if (Input.GetKey(KeyCode.Z)) { this.v -= this.vUp * (this.m_MoveSpeed * this.MoveSpeedAccel * Time.deltaTime); } if (Input.GetKey(KeyCode.X)) { this.v += this.vUp * (this.m_MoveSpeed * this.MoveSpeedAccel * Time.deltaTime); } if (this.HandLimitMode != AVRControllerBehavior.LIMIT_MODE.HAND_ONLY) { this.m_trBaseHead.position = this.v; this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 40f * Time.deltaTime * (this.m_VRCtrlLeft.GetCamRotVelocityY() + this.m_VRCtrlRight.GetCamRotVelocityY())); } if (Vector3.zero == vector2) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), this.m_VRCtrlLeft.GetHandRotVelocityY() + this.m_VRCtrlRight.GetHandRotVelocityY()); } if (Input.GetKey(KeyCode.Q)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), -40f * this.RotSpeedAccel * Time.deltaTime); } if (Input.GetKey(KeyCode.E)) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 40f * this.RotSpeedAccel * Time.deltaTime); } if (this.IsNoHandController && GameMain.Instance.CMSystem.OvrMouseRot && !this.IsUIShow && !this.m_bSlideMoving) { this.m_trBaseHead.Rotate(new Vector3(0f, 1f, 0f), 60f * NInput.GetAxis("Mouse X") * this.RotMouseSpeedAccel * Time.deltaTime); } if (Input.GetKeyUp(KeyCode.R)) { this.ReCallcOffset(); GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true); GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f); } if (Input.GetKeyUp(KeyCode.M)) { this.MirrorSwitch(); } if (Input.GetKeyUp(KeyCode.U)) { GameMain.Instance.OvrMgr.OvrCamera.ShowUI(true); GameMain.Instance.OvrMgr.OvrCamera.UIPosReset(0f); } 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 (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 (this.IsNoHandController && Input.GetKeyUp(KeyCode.Space)) { this.ToggleUI(); } if (GameMain.Instance.IsForceSkip() && this.m_bMoveSkip) { iTween.StopAndSkipToEnd(base.gameObject); } this.UpdateRealPosRot(); 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); } } } public float m_MoveSpeed = 0.5f; public float m_RotSpeed = 30f; public string mouseAxisX = "Mouse X"; public string mouseAxisY = "Mouse Y"; public string mouseAxisZoom = "Mouse ScrollWheel"; public bool m_bWheelToZoom = true; public bool m_bRightClickUIToggle = true; public GameObject m_goOvrUiNow; public GameObject m_goOvrUiScreen; public GameObject m_goOvrUiTablet; public Transform m_trOvrUiTablet; public GameObject m_goCenterEye; public Transform m_trCenterEye; protected AVRControllerBehavior.LIMIT_MODE m_eHandLimitMode; protected ScreenOverlay m_FadeTargetCameraOVR; protected Bloom m_BloomOVR; protected bool m_bUiToggle = true; protected bool m_bUiShowBack; protected Vector2 m_vRot = default(Vector2); protected UILabel m_labelHeadScale; protected bool m_bIsSceneYotogi; protected bool m_bIsForceRightClickUiToggle; protected Transform m_trCursorLaserHit; protected Transform m_trTarget; protected Transform m_trVirtualMy; protected float m_fDistance = 10f; protected Vector3 vFowerd; protected Vector3 vLeft; protected Vector3 vUp; protected Vector3 v; protected Vector2 vMouseMoving = Vector2.zero; protected bool bTab; protected bool m_bBefManHeadEnable = true; protected Transform m_trRealHead; protected Transform m_trBaseHead; protected Transform m_trBaseRoomBase; protected AVRController m_VRCtrlLeft; protected AVRController m_VRCtrlRight; protected bool m_bControllerModeNew; protected OvrTablet m_OvrTablet; protected VREventText m_VREvnetText; protected OvrEyeRay m_EyeRay; protected bool m_bUIForceHide; protected DummyVRHandAnimator m_DummyHand; protected uint m_unDummyHandVisibleFlag; protected bool m_bSlideMoving; protected Coroutine m_coToManHeadWait; private Dictionary m_dicKeyBack = new Dictionary(); public enum DUMMY_HAND { CHOICES_TOUCH = 1, EVENT_GRAB } private enum MouseButtonDown { MBD_LEFT, MBD_RIGHT, MBD_MIDDLE } private class PairKeyTime { public float fBackTime; public bool bDown; } }