OptionPanel.cs 4.8 KB

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