123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- using System;
- using System.Collections;
- using UnityEngine;
- using UnityEngine.UI;
- public class Day_UI : MonoBehaviour
- {
- public static void Day_UI_Start(Action action = null)
- {
- if (action != null)
- {
- Day_UI.m_End_Action = action;
- }
- if (Day_UI.UI_Obj)
- {
- UnityEngine.Object.Destroy(Day_UI.UI_Obj);
- }
- Day_UI.UI_Obj = Resources.Load<GameObject>(Day_UI.UI_Obj_Path);
- Day_UI.UI_Obj = UnityEngine.Object.Instantiate<GameObject>(Day_UI.UI_Obj);
- Day_UI.UI_Obj.GetComponent<Day_UI>().Start_Set();
- }
- private void Start_Set()
- {
- this.m_My_Rect = base.GetComponent<RectTransform>();
- this.m_My_Child = this.m_My_Rect.GetChild(0);
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- this.m_My_Child.GetComponent<Text>().text = maid.status.GetFlag("VRイベント日数").ToString() + "日目";
- if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON)
- {
- base.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
- this.m_My_Rect = this.m_My_Child.gameObject.GetComponent<RectTransform>();
- this.m_My_Child.GetComponent<Text>().fontSize = this.m_2D_Text;
- this.m_My_Rect.localPosition = Vector3.up * (float)(Screen.height + this.m_2D_Text / 2);
- this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.localPosition);
- this.m_Goal_Pos.y = 0f;
- this.m_Down_Speed = (float)(Screen.height + this.m_2D_Text / 2);
- }
- else
- {
- Vector3 eulerAngles = GameMain.Instance.MainCamera.GetRealHeadTransform().eulerAngles;
- Vector3 a = GameMain.Instance.MainCamera.GetRealHeadTransform().TransformDirection(Vector3.forward);
- a.y = 0f;
- a.Normalize();
- Vector3 position = GameMain.Instance.MainCamera.GetRealHeadTransform().position;
- this.m_My_Rect.eulerAngles = Vector3.up * eulerAngles.y;
- this.m_My_Child.GetComponent<Text>().fontSize = this.m_Text_Size;
- this.m_My_Rect.position = position + a * this.m_Forwordlength + Vector3.up * this.m_First_High;
- this.m_My_Child.GetComponent<RectTransform>().localPosition = Vector3.down * this.m_Down_Length;
- this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.position);
- this.m_Goal_Pos.y = position.y;
- this.m_Down_Speed = this.m_First_High;
- }
- base.StartCoroutine("UI_Animation");
- }
- private IEnumerator UI_Animation()
- {
- float timer = 0f;
- for (;;)
- {
- timer += Time.deltaTime;
- float angle = 90f * (timer / this.m_Anime_Time);
- float rate = Mathf.Sin(0.0174532924f * angle);
- this.m_My_Rect.localPosition = this.m_Start_Pos * (1f - rate) + this.m_Goal_Pos * rate;
- if (timer >= this.m_Anime_Time)
- {
- break;
- }
- yield return null;
- }
- GameMain.Instance.SoundMgr.PlaySe(this.m_Sound_Name, false);
- yield return new WaitForSeconds(this.m_Wait_Time);
- base.StartCoroutine("UI_Fade");
- yield break;
- yield break;
- }
- private IEnumerator UI_Fade()
- {
- Text child_text = this.m_My_Child.GetComponent<Text>();
- Color text_color = child_text.color;
- float timer = 0f;
- for (;;)
- {
- timer += Time.deltaTime;
- text_color.a = 1f - timer / this.m_Fade_Time;
- child_text.color = text_color;
- if (timer >= this.m_Fade_Time)
- {
- break;
- }
- yield return null;
- }
- if (Day_UI.m_End_Action != null)
- {
- Day_UI.m_End_Action();
- }
- UnityEngine.Object.Destroy(base.gameObject);
- yield break;
- yield break;
- }
- private static string UI_Obj_Path = "Prefab/Day_Display_UI";
- private static GameObject UI_Obj;
- [SerializeField]
- [Header("アニメーション時間")]
- private float m_Anime_Time = 1f;
- [SerializeField]
- [Header("アニメーションとフェードの間時間")]
- private float m_Wait_Time = 2f;
- [SerializeField]
- [Header("フェード時間")]
- private float m_Fade_Time = 0.5f;
- [SerializeField]
- [Header("UIとカメラの距離(前方向)")]
- private float m_Forwordlength = 1.7f;
- [SerializeField]
- [Header("UIの最初の高さ")]
- private float m_First_High = 3f;
- [SerializeField]
- private int m_Text_Size = 100;
- [SerializeField]
- private float m_Down_Length = 40f;
- [SerializeField]
- [Header("2Dモード時の文字サイズ")]
- private int m_2D_Text = 75;
- [SerializeField]
- [Header("SEファイル")]
- private string m_Sound_Name = "SE021.ogg";
- private RectTransform m_My_Rect;
- private Transform m_My_Child;
- private float m_Down_Speed;
- private static Action m_End_Action;
- private Vector3 m_Start_Pos;
- private Vector3 m_Goal_Pos;
- }
|