using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Trophy_UI : MonoBehaviour { public static void Trophy_Start(string para) { if (Trophy_UI.m_Trophy_Text == null) { Trophy_UI.m_Trophy_Text = new List(); } if (!Trophy_UI.m_Now_DisplayUI) { GameObject now_DisplayUI = Resources.Load("Prefab/TrophyGet_UI"); Trophy_UI.m_Now_DisplayUI = now_DisplayUI; Trophy_UI.m_Now_DisplayUI = UnityEngine.Object.Instantiate(Trophy_UI.m_Now_DisplayUI); Trophy_UI.m_Now_DisplayUI.GetComponent().Initialize(para); } Trophy_UI.m_Trophy_Text.Add(para); } private void Initialize(string val) { this.m_All_Text_Rect = new Dictionary(); this.m_Use_String = val; this.m_All_LineCount = this.m_Use_String.Length / this.m_Line_Count; base.StartCoroutine(this.UI_Animation()); } private void Set_Camera_Forward(RectTransform rect) { Vector3 position = GameMain.Instance.MainCamera.GetRealHeadTransform().position; Vector3 a = GameMain.Instance.MainCamera.GetRealHeadTransform().TransformDirection(Vector3.forward); Vector3 vector = GameMain.Instance.MainCamera.GetRealHeadTransform().TransformDirection(Vector3.down); vector.x = 0f; rect.position = position + a * this.m_Forward_Length + vector.normalized * this.m_Down_Length; Vector3 eulerAngles = GameMain.Instance.MainCamera.GetRealHeadTransform().eulerAngles; rect.eulerAngles = new Vector3(eulerAngles.x, eulerAngles.y, 0f); rect.localScale = Vector3.one; Vector2 vector2 = Vector2.one * 0.5f; rect.pivot = vector2; vector2 = vector2; rect.anchorMax = vector2; rect.anchorMin = vector2; rect.sizeDelta = Vector2.one * 100f; base.GetComponent().dynamicPixelsPerUnit = 5f; } private void Set_Text_Pos(ref List first_pos, ref List end_pos, RectTransform bace) { int num = 0; foreach (char c in this.m_Use_String) { int num2 = num / this.m_Line_Count; Vector3 zero = Vector3.zero; GameObject gameObject = new GameObject("Text", new Type[] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Text) }); gameObject.layer = base.gameObject.layer; RectTransform component = gameObject.GetComponent(); component.SetParent(base.transform); Text component2 = gameObject.GetComponent(); component2.text = c.ToString(); component2.font = Resources.Load("Font/Day_Display_UI_Font"); component2.color = this.m_Text_Col; component2.alignment = TextAnchor.MiddleCenter; component.sizeDelta = Vector2.one * 100f; component.localEulerAngles = Vector3.zero; gameObject.AddComponent(); Color outline_Col = this.m_Outline_Col; outline_Col.a = this.m_Outline_Alpha; gameObject.GetComponent().effectColor = outline_Col; if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON) { gameObject.GetComponent().effectDistance = Vector2.one * this.m_2D_Outline_Size; component2.fontSize = this.m_2D_Text_Size; RectTransform rectTransform = component; Vector2 vector = Vector2.up; component.anchorMax = vector; rectTransform.anchorMin = vector; component.pivot = Vector2.zero; component.localScale = Vector3.one; float x = (float)(num % this.m_Line_Count) * this.m_2D_Delta_Size.y - bace.localPosition.x; float y = bace.localPosition.y + (float)(num % this.m_Line_Count + this.m_All_LineCount - num2) * this.m_2D_Delta_Size.y; component.localPosition = new Vector3(x, y, 0f); zero = new Vector3(x, -this.m_2D_Down_Length + bace.localPosition.y, 0f); zero.y -= (float)num2 * this.m_2D_Delta_Size.y; } else { gameObject.GetComponent().effectDistance = Vector2.one * this.m_Outline_Size; component.localScale = Vector3.one * 0.01f; component2.fontSize = this.m_Text_Size; component2.alignment = TextAnchor.MiddleCenter; RectTransform rectTransform2 = component; Vector2 vector = Vector2.one * 0.5f; component.pivot = vector; vector = vector; component.anchorMax = vector; rectTransform2.anchorMin = vector; float x = (float)(num % this.m_Line_Count) * this.m_Delta_Size.x * 0.01f + this.m_Width_Length; float y = (float)(-(float)num2) * this.m_Delta_Size.y * 0.01f; component.localPosition = new Vector3(x, y, 0f); zero = new Vector3(-(this.m_Width_Length + (float)Mathf.Abs(this.m_Line_Count - (num % this.m_Line_Count + 1)) * this.m_Delta_Size.x * 0.01f), y, 0f); } first_pos.Add(component.localPosition); end_pos.Add(zero); this.m_All_Text_Rect.Add(component2, component); if (c == '\n') { num += this.m_Line_Count - num % this.m_Line_Count; } else { num++; } } } private void Set_Next_UI() { Trophy_UI.m_Trophy_Text.RemoveAt(0); if (Trophy_UI.m_Trophy_Text.Count != 0) { GameObject gameObject = Resources.Load("Prefab/TrophyGet_UI"); gameObject = UnityEngine.Object.Instantiate(gameObject); gameObject.GetComponent().Initialize(Trophy_UI.m_Trophy_Text[0]); Trophy_UI.m_Now_DisplayUI = gameObject; } else { Trophy_UI.m_Now_DisplayUI = null; } UnityEngine.Object.Destroy(base.gameObject); } private IEnumerator UI_Animation() { RectTransform my_rect = null; if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON) { yield return null; my_rect = base.GetComponent(); } else { my_rect = base.GetComponent(); this.Set_Camera_Forward(my_rect); base.GetComponent().renderMode = RenderMode.WorldSpace; base.GetComponent().sortingOrder = 4; } List start_pos = new List(); List end_pos = new List(); this.Set_Text_Pos(ref start_pos, ref end_pos, my_rect); float timer = 0f; GameMain.Instance.SoundMgr.PlaySe("SE015.ogg", false); for (;;) { timer += Time.deltaTime; int count = 0; int text_no = 0; float all_anime_time = 0f; if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON) { all_anime_time = this.m_Anime_Bace + this.m_Anime_Lag * (float)(this.m_All_Text_Rect.Count - 1); } else { all_anime_time = this.m_VR_AnimeTime; } foreach (KeyValuePair keyValuePair in this.m_All_Text_Rect) { int num = count / this.m_Line_Count; float num2; if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON) { num2 = this.m_Anime_Bace + (float)(count % this.m_Line_Count + this.m_All_LineCount - num) * this.m_Anime_Lag; } else { num2 = this.m_VR_AnimeTime; } if (timer <= num2) { float num3 = 90f * (timer / num2); float num4 = Mathf.Sin(0.0174532924f * num3); keyValuePair.Value.localPosition = start_pos[text_no] * (1f - num4) + end_pos[text_no] * num4; } if (keyValuePair.Key.text == "\n") { count += this.m_Line_Count - count % this.m_Line_Count; } else { count++; } text_no++; } if (timer >= all_anime_time) { break; } yield return null; } yield return new WaitForSeconds(this.m_Wait_Time); base.StartCoroutine(this.Fade_Out()); yield break; yield break; } private IEnumerator Fade_Out() { Color set_color = this.m_Text_Col; float timer = 0f; for (;;) { timer += Time.deltaTime; set_color.a = 1f - timer / this.m_Fade_Time; foreach (Text text in this.m_All_Text_Rect.Keys) { text.color = set_color; } if (timer >= this.m_Fade_Time) { break; } yield return null; } yield return new WaitForSeconds(this.m_Next_Time); this.Set_Next_UI(); yield break; yield break; } private const string m_TrophyGet_UI_Path = "Prefab/TrophyGet_UI"; private const string m_Font_Path = "Font/Day_Display_UI_Font"; private const string m_SE_Name = "SE015.ogg"; private static GameObject m_Now_DisplayUI; private static List m_Trophy_Text; [SerializeField] [Header("この文字数で改行")] private int m_Line_Count = 15; [SerializeField] private Color m_Text_Col = Color.white; [SerializeField] [Header("外枠色")] private Color m_Outline_Col = Color.black; [SerializeField] [Header("外枠透明度")] [Range(0f, 1f)] private float m_Outline_Alpha = 0.5f; [SerializeField] [Header("2D用")] [Header("文字サイズ")] private int m_2D_Text_Size = 25; [SerializeField] [Header("文字設置間隔(X:横、Y:縦)")] private Vector2 m_2D_Delta_Size = new Vector2(25f, 25f); [SerializeField] [Header("どの位置まで下げるか")] private float m_2D_Down_Length = 75f; [SerializeField] [Header("外枠サイズ")] private float m_2D_Outline_Size = 2f; [SerializeField] [Header("VR用")] [Header("前方距離")] private float m_Forward_Length = 1f; [SerializeField] [Header("横距離")] private float m_Width_Length = 0.75f; [SerializeField] [Header("下位置")] private float m_Down_Length = 0.35f; [SerializeField] [Header("文字設置間隔(X:横、Y:縦)")] private Vector2 m_Delta_Size = new Vector2(15f, 15f); [SerializeField] [Header("文字サイズ")] private int m_Text_Size = 15; [SerializeField] [Header("外枠サイズ")] private float m_Outline_Size = 1f; [SerializeField] [Header("アニメーション関連(全般)")] private float m_Wait_Time = 2f; [SerializeField] private float m_Fade_Time = 0.5f; [SerializeField] [Header("アニメーション関連(2D)")] private float m_Anime_Bace = 1f; [SerializeField] private float m_Anime_Lag = 0.1f; [SerializeField] [Header("アニメーション関連(VR)")] private float m_VR_AnimeTime = 7f; [SerializeField] [Header("連続して呼ばれた場合次のトロフィー用UIを出すまでの待機時間")] private float m_Next_Time = 0.5f; private string m_Use_String = string.Empty; private int m_All_LineCount; private Dictionary m_All_Text_Rect; private GameObject m_Text_Plate; }