SettingsView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6. namespace SmartBow
  7. {
  8. public class SettingsView : MonoBehaviour, MenuBackInterface
  9. {
  10. [SerializeField] Transform panelLeftContent;
  11. void Start()
  12. {
  13. PersistenHandler.ins?.menuBackCtr.views.Add(this);
  14. ShowBoxSound(true);
  15. }
  16. void OnDestroy()
  17. {
  18. PersistenHandler.ins?.menuBackCtr.views.Remove(this);
  19. }
  20. public bool OnMenuBack()
  21. {
  22. ViewManager2.HideView(ViewManager2.Path_SettingsView);
  23. return true;
  24. }
  25. public void OnClick_PanelLeftItem(Transform target)
  26. {
  27. foreach (Transform item in panelLeftContent)
  28. {
  29. if (item == target)
  30. {
  31. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Bold;
  32. item.Find("Text").GetComponent<Text>().color = Color.white;
  33. bool oldActive = item.Find("LightMask").gameObject.activeSelf;
  34. item.Find("LightMask").gameObject.SetActive(true);
  35. if (!oldActive)
  36. {
  37. AudioMgr.ins.PlayBtn();
  38. ShowBox(item.name);
  39. }
  40. }
  41. else
  42. {
  43. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Normal;
  44. item.Find("Text").GetComponent<Text>().color = Color.gray;
  45. item.Find("LightMask").gameObject.SetActive(false);
  46. }
  47. }
  48. }
  49. void ShowBox(string itemName)
  50. {
  51. ShowBoxSound(itemName == "BtnSound");
  52. ShowBoxLevel(itemName == "BtnLevel");
  53. ShowBoxNewUser(itemName == "BtnNewUser");
  54. ShowBoxScreenDistance(itemName == "BtnScreenDistance");
  55. ShowBoxLanguage(itemName == "BtnLanguage");
  56. ShowBoxUserAgreement(itemName == "BtnUserAgreement");
  57. ShowBoxPrivacyPolicy(itemName == "BtnPrivacyPolicy");
  58. ShowBoxAboutUs(itemName == "BtnAboutUs");
  59. }
  60. void ShowBoxSound(bool show)
  61. {
  62. transform.Find("PanelContent/BoxSound").gameObject.SetActive(show);
  63. }
  64. void ShowBoxLevel(bool show)
  65. {
  66. transform.Find("PanelContent/BoxLevel").gameObject.SetActive(show);
  67. }
  68. void ShowBoxNewUser(bool show)
  69. {
  70. transform.Find("PanelContent/BoxNewUser").gameObject.SetActive(show);
  71. }
  72. void ShowBoxScreenDistance(bool show)
  73. {
  74. transform.Find("PanelContent/BoxScreenDistance").gameObject.SetActive(show);
  75. }
  76. void ShowBoxLanguage(bool show)
  77. {
  78. transform.Find("PanelContent/BoxLanguage").gameObject.SetActive(show);
  79. }
  80. void ShowBoxUserAgreement(bool show)
  81. {
  82. transform.Find("PanelContent/BoxUserAgreement").gameObject.SetActive(show);
  83. }
  84. void ShowBoxPrivacyPolicy(bool show)
  85. {
  86. transform.Find("PanelContent/BoxPrivacyPolicy").gameObject.SetActive(show);
  87. }
  88. void ShowBoxAboutUs(bool show)
  89. {
  90. transform.Find("PanelContent/BoxAboutUs").gameObject.SetActive(show);
  91. }
  92. public void ShowModalConfirmSignOut(bool show)
  93. {
  94. transform.Find("ModalConfirmSignOut").gameObject.SetActive(show);
  95. }
  96. public void OnClick_QuitGame()
  97. {
  98. AudioMgr.ins.PlayBtn();
  99. Application.Quit();
  100. }
  101. public void OnClick_SignOut()
  102. {
  103. AudioMgr.ins.PlayBtn();
  104. ShowModalConfirmSignOut(true);
  105. }
  106. public void OnClick_Back()
  107. {
  108. AudioMgr.ins.PlayBtn();
  109. ViewManager2.HideView(ViewManager2.Path_SettingsView);
  110. }
  111. }
  112. }