UIController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System;
  2. using System.Collections;
  3. using DG.Tweening;
  4. using UnityEngine;
  5. public class UIController : SingletonMono<UIController>
  6. {
  7. private void Awake()
  8. {
  9. this.Camera = this.CameraGO.GetComponent<Camera>();
  10. }
  11. public void Reset()
  12. {
  13. if (this.bossHpBar.Visible)
  14. {
  15. this.bossHpBar.Disappear();
  16. }
  17. R.Ui.HitsGrade.HideHitNumAndBar();
  18. }
  19. public YieldInstruction ShowUI(bool immediately = false)
  20. {
  21. if (immediately)
  22. {
  23. for (int i = 0; i < this._uiNeedHide.Length; i++)
  24. {
  25. this._uiNeedHide[i].alpha = 1f;
  26. }
  27. this.IsHide = false;
  28. return null;
  29. }
  30. return base.StartCoroutine(this.IFadeInAnim());
  31. }
  32. public YieldInstruction HideUI(bool immediately = false)
  33. {
  34. if (immediately)
  35. {
  36. for (int i = 0; i < this._uiNeedHide.Length; i++)
  37. {
  38. this._uiNeedHide[i].alpha = 0f;
  39. }
  40. this.IsHide = true;
  41. return null;
  42. }
  43. return base.StartCoroutine(this.IFadeOutAnim());
  44. }
  45. public GameObject CreateEnemyPoint(EnemyAttribute enemy)
  46. {
  47. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.enemyPoint);
  48. if (gameObject != null)
  49. {
  50. UIEnemyPointController component = gameObject.GetComponent<UIEnemyPointController>();
  51. component.enemy = enemy;
  52. }
  53. return this.enemyPoint;
  54. }
  55. public void EnterMovieMode()
  56. {
  57. UIWidget component = this.movieModePlayAnimation.GetComponent<UIWidget>();
  58. if (component.alpha < 1f)
  59. {
  60. component.alpha = 1f;
  61. this.movieModePlayAnimation.Play(true);
  62. return;
  63. }
  64. }
  65. public void ExitMovieMode()
  66. {
  67. UIWidget widget = this.movieModePlayAnimation.GetComponent<UIWidget>();
  68. if (widget.alpha < 1f)
  69. {
  70. return;
  71. }
  72. EventDelegate.Add(this.movieModePlayAnimation.onFinished, delegate()
  73. {
  74. widget.alpha = 0f;
  75. }, true);
  76. this.movieModePlayAnimation.Play(false);
  77. }
  78. private IEnumerator IFadeInAnim()
  79. {
  80. for (int i = 0; i < this._uiNeedHide.Length; i++)
  81. {
  82. this.FadeTo(this._uiNeedHide[i], 1f, 0.5f);
  83. }
  84. yield return WorldTime.WaitForSecondsIgnoreTimeScale(0.5f);
  85. this.IsHide = false;
  86. yield break;
  87. }
  88. private IEnumerator IFadeOutAnim()
  89. {
  90. this.IsHide = true;
  91. for (int i = 0; i < this._uiNeedHide.Length; i++)
  92. {
  93. this.FadeTo(this._uiNeedHide[i], 0f, 0.5f);
  94. }
  95. yield return WorldTime.WaitForSecondsIgnoreTimeScale(0.5f);
  96. yield break;
  97. }
  98. private void FadeTo(UIRect widget, float endValue, float duration)
  99. {
  100. DOTween.To(() => widget.alpha, delegate(float alpha)
  101. {
  102. widget.alpha = alpha;
  103. }, endValue, duration);
  104. }
  105. public bool IsHide;
  106. [SerializeField]
  107. public UIWidget RootWidget;
  108. [SerializeField]
  109. public GameObject CameraGO;
  110. [NonSerialized]
  111. public Camera Camera;
  112. [SerializeField]
  113. private UIRect[] _uiNeedHide;
  114. [HideInInspector]
  115. public UISubtitleController UISubtitle;
  116. [SerializeField]
  117. public UIBlackSceneController BlackScene;
  118. [SerializeField]
  119. public UIHitsGradeController HitsGrade;
  120. [SerializeField]
  121. public UIEnhancementController Enhancement;
  122. [SerializeField]
  123. public UINotifacationController uiNotifacation;
  124. [SerializeField]
  125. public UIBossHpBarController bossHpBar;
  126. [SerializeField]
  127. public UIToast Toast;
  128. [SerializeField]
  129. public UISaveProgressCircleController SaveProgressCircle;
  130. [SerializeField]
  131. public UITerminalController Terminal;
  132. [SerializeField]
  133. public UILevelSelectController LevelSelect;
  134. [SerializeField]
  135. public UITutorialController Tutorial;
  136. [SerializeField]
  137. public UIPauseController Pause;
  138. [SerializeField]
  139. public UILevelNameController LevelName;
  140. [SerializeField]
  141. public UIVolumeController Volume;
  142. [SerializeField]
  143. public UIEndTitleController EndTitle;
  144. [SerializeField]
  145. public UIFlashController Flash;
  146. [SerializeField]
  147. public UIBloodPalaceController BloodPalace;
  148. [SerializeField]
  149. public UITrophyNotificationController TrophyNotification;
  150. [SerializeField]
  151. private GameObject enemyPoint;
  152. [SerializeField]
  153. private UIPlayAnimation movieModePlayAnimation;
  154. }