Day_UI.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class Day_UI : MonoBehaviour
  6. {
  7. public static void Day_UI_Start(Action action = null)
  8. {
  9. if (action != null)
  10. {
  11. Day_UI.m_End_Action = action;
  12. }
  13. if (Day_UI.UI_Obj)
  14. {
  15. UnityEngine.Object.Destroy(Day_UI.UI_Obj);
  16. }
  17. Day_UI.UI_Obj = Resources.Load<GameObject>(Day_UI.UI_Obj_Path);
  18. Day_UI.UI_Obj = UnityEngine.Object.Instantiate<GameObject>(Day_UI.UI_Obj);
  19. Day_UI.UI_Obj.GetComponent<Day_UI>().Start_Set();
  20. }
  21. private void Start_Set()
  22. {
  23. this.m_My_Rect = base.GetComponent<RectTransform>();
  24. this.m_My_Child = this.m_My_Rect.GetChild(0);
  25. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  26. this.m_My_Child.GetComponent<Text>().text = maid.status.GetFlag("VRイベント日数").ToString() + "日目";
  27. if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON)
  28. {
  29. base.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
  30. this.m_My_Rect = this.m_My_Child.gameObject.GetComponent<RectTransform>();
  31. this.m_My_Child.GetComponent<Text>().fontSize = this.m_2D_Text;
  32. this.m_My_Rect.localPosition = Vector3.up * (float)(Screen.height + this.m_2D_Text / 2);
  33. this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.localPosition);
  34. this.m_Goal_Pos.y = 0f;
  35. this.m_Down_Speed = (float)(Screen.height + this.m_2D_Text / 2);
  36. }
  37. else
  38. {
  39. Vector3 eulerAngles = GameMain.Instance.MainCamera.GetRealHeadTransform().eulerAngles;
  40. Vector3 a = GameMain.Instance.MainCamera.GetRealHeadTransform().TransformDirection(Vector3.forward);
  41. a.y = 0f;
  42. a.Normalize();
  43. Vector3 position = GameMain.Instance.MainCamera.GetRealHeadTransform().position;
  44. this.m_My_Rect.eulerAngles = Vector3.up * eulerAngles.y;
  45. this.m_My_Child.GetComponent<Text>().fontSize = this.m_Text_Size;
  46. this.m_My_Rect.position = position + a * this.m_Forwordlength + Vector3.up * this.m_First_High;
  47. this.m_My_Child.GetComponent<RectTransform>().localPosition = Vector3.down * this.m_Down_Length;
  48. this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.position);
  49. this.m_Goal_Pos.y = position.y;
  50. this.m_Down_Speed = this.m_First_High;
  51. }
  52. base.StartCoroutine("UI_Animation");
  53. }
  54. private IEnumerator UI_Animation()
  55. {
  56. float timer = 0f;
  57. for (;;)
  58. {
  59. timer += Time.deltaTime;
  60. float angle = 90f * (timer / this.m_Anime_Time);
  61. float rate = Mathf.Sin(0.0174532924f * angle);
  62. this.m_My_Rect.localPosition = this.m_Start_Pos * (1f - rate) + this.m_Goal_Pos * rate;
  63. if (timer >= this.m_Anime_Time)
  64. {
  65. break;
  66. }
  67. yield return null;
  68. }
  69. GameMain.Instance.SoundMgr.PlaySe(this.m_Sound_Name, false);
  70. yield return new WaitForSeconds(this.m_Wait_Time);
  71. base.StartCoroutine("UI_Fade");
  72. yield break;
  73. yield break;
  74. }
  75. private IEnumerator UI_Fade()
  76. {
  77. Text child_text = this.m_My_Child.GetComponent<Text>();
  78. Color text_color = child_text.color;
  79. float timer = 0f;
  80. for (;;)
  81. {
  82. timer += Time.deltaTime;
  83. text_color.a = 1f - timer / this.m_Fade_Time;
  84. child_text.color = text_color;
  85. if (timer >= this.m_Fade_Time)
  86. {
  87. break;
  88. }
  89. yield return null;
  90. }
  91. if (Day_UI.m_End_Action != null)
  92. {
  93. Day_UI.m_End_Action();
  94. }
  95. UnityEngine.Object.Destroy(base.gameObject);
  96. yield break;
  97. yield break;
  98. }
  99. private static string UI_Obj_Path = "Prefab/Day_Display_UI";
  100. private static GameObject UI_Obj;
  101. [SerializeField]
  102. [Header("アニメーション時間")]
  103. private float m_Anime_Time = 1f;
  104. [SerializeField]
  105. [Header("アニメーションとフェードの間時間")]
  106. private float m_Wait_Time = 2f;
  107. [SerializeField]
  108. [Header("フェード時間")]
  109. private float m_Fade_Time = 0.5f;
  110. [SerializeField]
  111. [Header("UIとカメラの距離(前方向)")]
  112. private float m_Forwordlength = 1.7f;
  113. [SerializeField]
  114. [Header("UIの最初の高さ")]
  115. private float m_First_High = 3f;
  116. [SerializeField]
  117. private int m_Text_Size = 100;
  118. [SerializeField]
  119. private float m_Down_Length = 40f;
  120. [SerializeField]
  121. [Header("2Dモード時の文字サイズ")]
  122. private int m_2D_Text = 75;
  123. [SerializeField]
  124. [Header("SEファイル")]
  125. private string m_Sound_Name = "SE021.ogg";
  126. private RectTransform m_My_Rect;
  127. private Transform m_My_Child;
  128. private float m_Down_Speed;
  129. private static Action m_End_Action;
  130. private Vector3 m_Start_Pos;
  131. private Vector3 m_Goal_Pos;
  132. }