SettingsView.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. [SerializeField] Transform BtnNewUserObj;
  12. void Start()
  13. {
  14. PersistenHandler.ins?.menuBackCtr.views.Add(this);
  15. //ShowBoxSound(true);
  16. }
  17. void OnDestroy()
  18. {
  19. PersistenHandler.ins?.menuBackCtr.views.Remove(this);
  20. }
  21. public bool OnMenuBack()
  22. {
  23. ViewManager2.HideView(ViewManager2.Path_SettingsView);
  24. return true;
  25. }
  26. //模拟点击新手教程按钮
  27. public void OnClick_BtnNewUser() {
  28. this.OnClick_PanelLeftItem(BtnNewUserObj.transform);
  29. }
  30. public void OnClick_PanelLeftItem(Transform target)
  31. {
  32. foreach (Transform item in panelLeftContent)
  33. {
  34. if (item.name == "BtnSignOut") continue;
  35. if (item == target)
  36. {
  37. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Bold;
  38. item.Find("Text").GetComponent<Text>().color = Color.white;
  39. bool oldActive = item.Find("LightMask").gameObject.activeSelf;
  40. item.Find("LightMask").gameObject.SetActive(true);
  41. if (!oldActive)
  42. {
  43. AudioMgr.ins.PlayBtn();
  44. ShowBox(item.name);
  45. }
  46. }
  47. else
  48. {
  49. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Normal;
  50. item.Find("Text").GetComponent<Text>().color = Color.gray;
  51. item.Find("LightMask").gameObject.SetActive(false);
  52. }
  53. }
  54. }
  55. void ShowBox(string itemName)
  56. {
  57. ShowBoxSound(itemName == "BtnSound");
  58. ShowBoxLevel(itemName == "BtnLevel");
  59. ShowBoxNewUser(itemName == "BtnNewUser");
  60. ShowBoxScreenDistance(itemName == "BtnScreenDistance");
  61. ShowBoxLanguage(itemName == "BtnLanguage");
  62. ShowBoxUserAgreement(itemName == "BtnUserAgreement");
  63. ShowBoxPrivacyPolicy(itemName == "BtnPrivacyPolicy");
  64. ShowBoxAboutUs(itemName == "BtnAboutUs");
  65. }
  66. public void ShowBoxSound(bool show)
  67. {
  68. transform.Find("PanelContent/BoxSound").gameObject.SetActive(show);
  69. }
  70. void ShowBoxLevel(bool show)
  71. {
  72. transform.Find("PanelContent/BoxLevel").gameObject.SetActive(show);
  73. }
  74. void ShowBoxNewUser(bool show)
  75. {
  76. transform.Find("PanelContent/BoxNewUser").gameObject.SetActive(show);
  77. }
  78. void ShowBoxScreenDistance(bool show)
  79. {
  80. transform.Find("PanelContent/BoxScreenDistance").gameObject.SetActive(show);
  81. }
  82. void ShowBoxLanguage(bool show)
  83. {
  84. transform.Find("PanelContent/BoxLanguage").gameObject.SetActive(show);
  85. }
  86. void ShowBoxUserAgreement(bool show)
  87. {
  88. transform.Find("PanelContent/BoxUserAgreement").gameObject.SetActive(show);
  89. }
  90. void ShowBoxPrivacyPolicy(bool show)
  91. {
  92. transform.Find("PanelContent/BoxPrivacyPolicy").gameObject.SetActive(show);
  93. }
  94. void ShowBoxAboutUs(bool show)
  95. {
  96. transform.Find("PanelContent/BoxAboutUs").gameObject.SetActive(show);
  97. }
  98. public void ShowModalConfirmSignOut(bool show)
  99. {
  100. transform.Find("ModalConfirmSignOut").gameObject.SetActive(show);
  101. }
  102. public void OnClick_QuitGame()
  103. {
  104. AudioMgr.ins.PlayBtn();
  105. Application.Quit();
  106. }
  107. public void OnClick_SignOut()
  108. {
  109. AudioMgr.ins.PlayBtn();
  110. ShowModalConfirmSignOut(true);
  111. }
  112. public void OnClick_Back()
  113. {
  114. AudioMgr.ins.PlayBtn();
  115. ViewManager2.HideView(ViewManager2.Path_SettingsView);
  116. }
  117. }
  118. }