SettingsView.cs 4.3 KB

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