OptionPanel.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. public class OptionPanel : OffAnimation
  7. {
  8. private static readonly int CloseHash = Animator.StringToHash("Close");
  9. private static readonly int OpenHash = Animator.StringToHash("Open");
  10. [SerializeField] VolumePanel _volumePanel;
  11. [SerializeField] ResizeWindow _resizeWindowPanel;
  12. [SerializeField] GameplayOption _gameplayOption;
  13. [SerializeField] GraphicsOptionPanel _graphicsOptionPanel;
  14. [SerializeField] ServerRegionPanel _serverRegionPanel;
  15. [SerializeField] LanguagePanel _languagePanel;
  16. [SerializeField] Animator _anim;
  17. bool _isOpen = false;
  18. public void OnClickOpenOptionPanelButton()
  19. {
  20. if (_isOpen)
  21. {
  22. CloseOptionPanel();
  23. }
  24. else
  25. {
  26. if (Opening.instance != null)
  27. {
  28. Opening.instance.PlayDecisionSE();
  29. }
  30. else if (GManager.instance != null)
  31. {
  32. GManager.instance.PlayDecisionSE();
  33. }
  34. Open();
  35. }
  36. }
  37. public void Open()
  38. {
  39. _isOpen = true;
  40. gameObject.SetActive(true);
  41. _anim.SetInteger("Open", 1);
  42. _anim.SetInteger("Close", 0);
  43. if (_volumePanel != null)
  44. {
  45. _volumePanel.Off();
  46. }
  47. if (_resizeWindowPanel != null)
  48. {
  49. _resizeWindowPanel.Off();
  50. }
  51. if (_gameplayOption != null)
  52. {
  53. _gameplayOption.Off();
  54. }
  55. if (_graphicsOptionPanel != null)
  56. {
  57. _graphicsOptionPanel.Off();
  58. }
  59. if (_serverRegionPanel != null)
  60. {
  61. _serverRegionPanel.Off();
  62. }
  63. if (_languagePanel != null)
  64. {
  65. _languagePanel.Off();
  66. }
  67. }
  68. public void Close()
  69. {
  70. Close_(true);
  71. }
  72. public void CloseOptionPanel()
  73. {
  74. _isOpen = false;
  75. bool playSE = false;
  76. if (gameObject.activeSelf)
  77. {
  78. playSE = true;
  79. }
  80. if (_resizeWindowPanel != null)
  81. {
  82. if (_resizeWindowPanel.gameObject.activeSelf)
  83. {
  84. playSE = true;
  85. }
  86. }
  87. if (_volumePanel != null)
  88. {
  89. if (_volumePanel.gameObject.activeSelf)
  90. {
  91. playSE = true;
  92. }
  93. }
  94. if (_gameplayOption != null)
  95. {
  96. if (_gameplayOption.gameObject.activeSelf)
  97. {
  98. playSE = true;
  99. }
  100. }
  101. if (_graphicsOptionPanel != null)
  102. {
  103. if (_graphicsOptionPanel.gameObject.activeSelf)
  104. {
  105. playSE = true;
  106. }
  107. }
  108. if (_serverRegionPanel != null)
  109. {
  110. if (_serverRegionPanel.gameObject.activeSelf)
  111. {
  112. playSE = true;
  113. }
  114. }
  115. if (_languagePanel != null)
  116. {
  117. if (_languagePanel.gameObject.activeSelf)
  118. {
  119. playSE = true;
  120. }
  121. }
  122. Close_(playSE);
  123. if (_resizeWindowPanel != null)
  124. {
  125. _resizeWindowPanel.Close_(false);
  126. }
  127. if (_volumePanel != null)
  128. {
  129. _volumePanel.Close_(false);
  130. }
  131. if (_gameplayOption != null)
  132. {
  133. _gameplayOption.Close_(false);
  134. }
  135. if (_graphicsOptionPanel != null)
  136. {
  137. _graphicsOptionPanel.Close_(false);
  138. }
  139. if (_serverRegionPanel != null)
  140. {
  141. _serverRegionPanel.Close_(false);
  142. }
  143. if (_languagePanel != null)
  144. {
  145. _languagePanel.Close_(false);
  146. }
  147. }
  148. public void Close_(bool playSE)
  149. {
  150. if (playSE)
  151. {
  152. if (Opening.instance != null)
  153. {
  154. Opening.instance.PlayCancelSE();
  155. }
  156. else if (GManager.instance != null)
  157. {
  158. GManager.instance.PlayCancelSE();
  159. }
  160. }
  161. _anim.SafeSetInt(OpenHash, 0);
  162. _anim.SafeSetInt(CloseHash, 1);
  163. }
  164. public void Init()
  165. {
  166. Off();
  167. if (_volumePanel != null)
  168. {
  169. _volumePanel.Init();
  170. }
  171. if (_resizeWindowPanel != null)
  172. {
  173. _resizeWindowPanel.Init();
  174. }
  175. if (_gameplayOption != null)
  176. {
  177. _gameplayOption.Init();
  178. }
  179. if (_graphicsOptionPanel != null)
  180. {
  181. _graphicsOptionPanel.Init();
  182. }
  183. if (_serverRegionPanel != null)
  184. {
  185. _serverRegionPanel.Init();
  186. }
  187. if (_languagePanel != null)
  188. {
  189. _languagePanel.Init();
  190. }
  191. }
  192. public void OnClickExitGameButton()
  193. {
  194. #if UNITY_EDITOR || !UNITY_STANDALONE
  195. return;
  196. #endif
  197. //Application.Quit();
  198. }
  199. }