123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206 |
- 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<Camera>().cullingMask;
- this.m_FadeTargetCameraOVR = this.m_goCenterEye.GetComponent<ScreenOverlay>();
- this.m_BloomOVR = this.m_goCenterEye.GetComponent<Bloom>();
- 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<UILabel>();
- 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<OvrTablet>();
- this.m_OvrTablet.Init(this.m_goCenterEye);
- Vignetting vignetting = base.gameObject.AddComponent<Vignetting>();
- vignetting.enabled = false;
- Camera component = base.gameObject.GetComponent<Camera>();
- 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<VREventText>();
- Transform transform = base.transform.Find("TrackingSpace/LeftHandAnchor");
- Transform transform2 = base.transform.Find("TrackingSpace/RightHandAnchor");
- this.m_VRCtrlLeft = transform.GetComponent<OvrController>();
- this.m_VRCtrlLeft.Init();
- this.m_VRCtrlRight = transform2.GetComponent<OvrController>();
- this.m_VRCtrlRight.Init();
- Transform transform3 = this.m_trCenterEye.Find("EyeRayCaster");
- this.m_EyeRay = transform3.GetComponent<OvrEyeRay>();
- NDebug.Assert(this.m_EyeRay != null, "視線検出機構がみつかりません。");
- this.m_DummyHand = base.transform.Find("HandPlayer").GetComponent<DummyVRHandAnimator>();
- 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<Camera>();
- 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<Camera>();
- 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<OvrTablet>();
- 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<SkinnedMeshRenderer>(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<SkinnedMeshRenderer>(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<KeyCode, OvrCamera.PairKeyTime> m_dicKeyBack = new Dictionary<KeyCode, OvrCamera.PairKeyTime>();
- 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;
- }
- }
|