SettingsView.cs 4.7 KB

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