OvrUI.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using UnityEngine;
  3. public class OvrUI : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.m_qGui = Quaternion.Euler(0f, -180f, 0f);
  8. this.m_trOvrScr = UTY.GetChildObject(base.gameObject, "ovr_screen", false).transform;
  9. this.m_fDistanceLimitFar = (this.m_fDistanceNow = this.m_trOvrScr.localPosition.z);
  10. this.CalcAngleLimit();
  11. }
  12. private void CalcAngleLimit()
  13. {
  14. this.m_fDistanceParNow = this.m_fDistanceNow / this.m_fDistanceLimitFar;
  15. this.m_fAngleLimitNow = this.m_fAngleLimitNear + (this.m_fAngleLimitFar - this.m_fAngleLimitNear) * this.m_fDistanceParNow;
  16. }
  17. private void Update()
  18. {
  19. if (Input.GetKey(KeyCode.UpArrow))
  20. {
  21. this.m_fDistanceNow += 0.1f * Time.deltaTime;
  22. }
  23. if (Input.GetKey(KeyCode.DownArrow))
  24. {
  25. this.m_fDistanceNow -= 0.1f * Time.deltaTime;
  26. }
  27. if (this.m_fDistanceNow > this.m_fDistanceLimitFar)
  28. {
  29. this.m_fDistanceNow = this.m_fDistanceLimitFar;
  30. }
  31. else if (this.m_fDistanceNow < this.m_fDistanceLimitNear)
  32. {
  33. this.m_fDistanceNow = this.m_fDistanceLimitNear;
  34. }
  35. this.m_trOvrScr.localPosition = new Vector3(0f, 0f, this.m_fDistanceNow);
  36. this.CalcAngleLimit();
  37. Vector3 vector = Vector3.forward;
  38. Vector3 vector2 = Vector3.forward;
  39. vector = this.m_goCenter.transform.rotation * vector;
  40. vector2 = base.transform.rotation * vector2;
  41. float num = Vector3.Angle(vector2, vector);
  42. if (num > this.m_fAngleLimitNow)
  43. {
  44. this.m_qGui = Quaternion.Lerp(this.m_qGui, this.m_goCenter.transform.rotation, this.m_speed);
  45. }
  46. base.transform.rotation = this.m_qGui;
  47. CameraMain.FadeState fadeState = GameMain.Instance.MainCamera.GetFadeState();
  48. if (Input.GetKey(KeyCode.U) || (this.m_BefFadeState != fadeState && fadeState == CameraMain.FadeState.ProcIn))
  49. {
  50. base.transform.rotation = (this.m_qGui = this.m_goCenter.transform.rotation);
  51. }
  52. this.m_BefFadeState = fadeState;
  53. }
  54. public float m_speed = 0.05f;
  55. public float m_fAngleLimitFar = 40f;
  56. public float m_fAngleLimitNear = 90f;
  57. private float m_fAngleLimitNow = 40f;
  58. public float m_fDistanceLimitNear = 0.1f;
  59. private float m_fDistanceLimitFar = 0.4f;
  60. private float m_fDistanceNow = 0.4f;
  61. private float m_fDistanceParNow;
  62. public GameObject m_goCenter;
  63. private Quaternion m_qGui = Quaternion.identity;
  64. private Transform m_trOvrScr;
  65. private CameraMain.FadeState m_BefFadeState;
  66. }