Result_Display.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.SceneManagement;
  6. public abstract class Result_Display : MonoBehaviour
  7. {
  8. protected float m_MydeltaTime
  9. {
  10. get
  11. {
  12. return Time.deltaTime * (float)this.m_TimeSpeed;
  13. }
  14. }
  15. protected void Initialize()
  16. {
  17. UIButton component = this.m_ButtonUI.GetComponent<UIButton>();
  18. EventDelegate.Remove(component.onClick, new EventDelegate.Callback(this.ClickButton));
  19. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.ClickButton));
  20. this.m_ButtonUI.SetActive(false);
  21. this.m_MyPanel = base.GetComponent<UIPanel>();
  22. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge && !Result_Display.IsNextDisplay)
  23. {
  24. Result_Display.IsNextDisplay = true;
  25. this.m_ButtonUI.GetComponent<UISprite>().spriteName = this.m_NextSpriteName;
  26. }
  27. else
  28. {
  29. Result_Display.IsNextDisplay = false;
  30. }
  31. IEnumerator enumerator = this.m_ResultGroup.GetEnumerator();
  32. try
  33. {
  34. while (enumerator.MoveNext())
  35. {
  36. object obj = enumerator.Current;
  37. Transform transform = (Transform)obj;
  38. this.UIInit(transform);
  39. foreach (KeyValuePair<string, Result_Display.DisplayInfo> keyValuePair in Result_Display.DisplayData)
  40. {
  41. if (transform.name == keyValuePair.Key)
  42. {
  43. Transform transform2 = transform.Find("Value");
  44. UILabel component2 = transform2.GetComponent<UILabel>();
  45. if (keyValuePair.Value.Type == Result_Display.ResultType.String)
  46. {
  47. component2.text = keyValuePair.Value.Value;
  48. }
  49. else
  50. {
  51. if (component2)
  52. {
  53. component2.enabled = false;
  54. }
  55. IEnumerator enumerator3 = transform2.GetEnumerator();
  56. try
  57. {
  58. while (enumerator3.MoveNext())
  59. {
  60. object obj2 = enumerator3.Current;
  61. Transform transform3 = (Transform)obj2;
  62. if (transform3.name == keyValuePair.Value.Value)
  63. {
  64. transform3.gameObject.SetActive(true);
  65. }
  66. else
  67. {
  68. transform3.gameObject.SetActive(false);
  69. }
  70. }
  71. }
  72. finally
  73. {
  74. IDisposable disposable;
  75. if ((disposable = (enumerator3 as IDisposable)) != null)
  76. {
  77. disposable.Dispose();
  78. }
  79. }
  80. }
  81. break;
  82. }
  83. }
  84. }
  85. }
  86. finally
  87. {
  88. IDisposable disposable2;
  89. if ((disposable2 = (enumerator as IDisposable)) != null)
  90. {
  91. disposable2.Dispose();
  92. }
  93. }
  94. this.m_NowSceneName = SceneManager.GetActiveScene().name;
  95. }
  96. protected virtual void Update()
  97. {
  98. if (this.m_NowSceneName != SceneManager.GetActiveScene().name)
  99. {
  100. UnityEngine.Object.Destroy(base.gameObject);
  101. Result_Display.IsNextDisplay = false;
  102. }
  103. this.m_TimeSpeed = ((!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl)) ? 1 : 2);
  104. }
  105. protected abstract void UIInit(Transform child);
  106. protected IEnumerator FadeOut()
  107. {
  108. float timer = 0f;
  109. for (;;)
  110. {
  111. timer += this.m_MydeltaTime;
  112. float rate = 1f - Mathf.Sin(timer / this.m_FadeTime * 90f * 0.0174532924f);
  113. this.m_MyPanel.alpha = rate;
  114. if (timer >= this.m_FadeTime)
  115. {
  116. break;
  117. }
  118. yield return null;
  119. }
  120. if (Result_Display.IsNextDisplay)
  121. {
  122. Result_Display.StartDisplay(this.m_EndLabel);
  123. }
  124. else
  125. {
  126. this.ResultEnd();
  127. }
  128. UnityEngine.Object.Destroy(base.gameObject);
  129. yield break;
  130. yield break;
  131. }
  132. protected virtual void ResultEnd()
  133. {
  134. GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_EndLabel);
  135. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  136. }
  137. protected float SinRate01(float time, float total)
  138. {
  139. return Mathf.Sin(Mathf.Clamp01(time / total) * 90f * 0.0174532924f);
  140. }
  141. public virtual void ClickButton()
  142. {
  143. base.StartCoroutine(this.FadeOut());
  144. }
  145. public static void StartDisplay(string label)
  146. {
  147. string path = string.Empty;
  148. switch (RhythmAction_Mgr.NowDance)
  149. {
  150. case RhythmAction_Mgr.DanceType.Free:
  151. case RhythmAction_Mgr.DanceType.Challenge:
  152. if (!Result_Display.IsNextDisplay)
  153. {
  154. path = "SceneDance/Rhythm_Action/Prefab/Result/FreeResult";
  155. }
  156. else
  157. {
  158. path = "SceneDance/Rhythm_Action/Prefab/Result/ChallengeResult";
  159. }
  160. break;
  161. case RhythmAction_Mgr.DanceType.VS:
  162. path = "SceneDance/Rhythm_Action/Prefab/Result/VSResult";
  163. break;
  164. case RhythmAction_Mgr.DanceType.BenchMark:
  165. path = "SceneDance/Rhythm_Action/Prefab/Result/BenchResult";
  166. break;
  167. }
  168. GameObject gameObject = Resources.Load<GameObject>(path);
  169. gameObject = UnityEngine.Object.Instantiate<GameObject>(gameObject);
  170. gameObject.transform.SetParent(GameObject.Find("SystemUI Root").transform, false);
  171. gameObject.GetComponent<Result_Display>().m_EndLabel = label;
  172. }
  173. public static void SetResultData(string key, string value, Result_Display.ResultType type = Result_Display.ResultType.String)
  174. {
  175. if (!Result_Display.DisplayData.ContainsKey(key))
  176. {
  177. Result_Display.DisplayData.Add(key, new Result_Display.DisplayInfo());
  178. }
  179. Result_Display.DisplayData[key].Type = type;
  180. Result_Display.DisplayData[key].Value = value;
  181. }
  182. public static string GetData(string key)
  183. {
  184. if (Result_Display.DisplayData.ContainsKey(key))
  185. {
  186. return Result_Display.DisplayData[key].Value;
  187. }
  188. return string.Empty;
  189. }
  190. private const string m_FreeResult_Path = "SceneDance/Rhythm_Action/Prefab/Result/FreeResult";
  191. private const string m_ChallengeResult_Path = "SceneDance/Rhythm_Action/Prefab/Result/ChallengeResult";
  192. private const string m_VSResult_Path = "SceneDance/Rhythm_Action/Prefab/Result/VSResult";
  193. private const string m_BenchResult_Path = "SceneDance/Rhythm_Action/Prefab/Result/BenchResult";
  194. private const string m_VrDanceResult_Path = "SceneDance/Rhythm_Action/Prefab/Result/VrDanceResult";
  195. protected const int m_Magnification = 2;
  196. [SerializeField]
  197. [Header("フェードアウト時間")]
  198. protected float m_FadeTime;
  199. [SerializeField]
  200. [Header("ボタン")]
  201. protected GameObject m_ButtonUI;
  202. [SerializeField]
  203. protected string m_NextSpriteName = "cm3d2_common_nextbuttom";
  204. [SerializeField]
  205. [Header("リザルト表示UIグループ")]
  206. protected Transform m_ResultGroup;
  207. [SerializeField]
  208. [Header("UIがスライドするときのSE")]
  209. protected string m_SlideSEName = "3_result.ogg";
  210. protected List<Vector3> m_GroupStart = new List<Vector3>();
  211. protected List<Vector3> m_GroupEnd = new List<Vector3>();
  212. protected UIPanel m_MyPanel;
  213. protected string m_EndLabel;
  214. protected static Dictionary<string, Result_Display.DisplayInfo> DisplayData = new Dictionary<string, Result_Display.DisplayInfo>();
  215. protected static bool IsNextDisplay = false;
  216. protected string m_NowSceneName = string.Empty;
  217. protected int m_TimeSpeed = 1;
  218. public enum ResultType
  219. {
  220. String,
  221. Image
  222. }
  223. protected class DisplayInfo
  224. {
  225. public Result_Display.ResultType Type;
  226. public string Value = string.Empty;
  227. }
  228. }