| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- using UnityEngine.SceneManagement;
 
- using System.Linq;
 
- namespace SmartBow
 
- {
 
-     public class SettingsView : JCUnityLib.ViewBase, MenuBackInterface
 
-     {
 
-         [SerializeField] Transform panelLeftContent;
 
-         [SerializeField] Transform BtnNewUserObj;
 
-         [SerializeField] Text GameVersionText;
 
-         void Start()
 
-         {
 
-             PersistenHandler.ins?.menuBackCtr.views.Add(this);
 
-             //ShowBoxSound(true);
 
-             switch (CommonConfig.OP)
 
-             {
 
-                 case OperatingPlatform.A:
 
-                     if (CommonConfig.bInfraredApp)
 
-                     {
 
-                         //隐藏弓到屏幕的距离
 
-                         Dictionary<string, Transform> actionMapInfrared= new Dictionary<string, Transform>
 
-                         {
 
-                             { "BtnSound", null },
 
-                             { "BtnLanguage", null },
 
-                             { "BtnNewUser", null },
 
-                             { "BtnLevel", null },
 
-                             { "BtnUserAgreement", null },
 
-                             { "BtnPrivacyPolicy", null },
 
-                             { "BtnAboutUs", null }
 
-                         };
 
-                         SortChildObjects(actionMapInfrared);
 
-                     }
 
-                     else {
 
-                         Dictionary<string, Transform> actionMapA = new Dictionary<string, Transform>
 
-                         {
 
-                             { "BtnSound", null },
 
-                             { "BtnLanguage", null },
 
-                             { "BtnNewUser", null },
 
-                             { "BtnScreenDistance", null },//弓到屏幕的距离
 
-                             { "BtnLevel", null },
 
-                             { "BtnUserAgreement", null },
 
-                             { "BtnPrivacyPolicy", null },
 
-                             { "BtnAboutUs", null }
 
-                         };
 
-                         SortChildObjects(actionMapA);
 
-                     }
 
-                     break;
 
-                 case OperatingPlatform.B:
 
-                     // 定义排序字典
 
-                     Dictionary<string, Transform> actionMapB = new Dictionary<string, Transform>
 
-                     {
 
-                         { "BtnSound", null },
 
-                         { "BtnLanguage", null },
 
-                         { "BtnLevel", null },
 
-                         { "BtnUserSettings", null },
 
-                         { "BtnBackStageManagement", null },
 
-                         { "BtnAboutUs", null }
 
-                     };
 
-                     SortChildObjects(actionMapB);
 
-                     break;
 
-                 case OperatingPlatform.C:
 
-                     //隐藏弓到屏幕的距离
 
-                     Dictionary<string, Transform> actionMapInfraredC = new Dictionary<string, Transform>
 
-                         {
 
-                             { "BtnSound", null },
 
-                             { "BtnLanguage", null },
 
-                             { "BtnNewUser", null },
 
-                             { "BtnLevel", null },
 
-                             { "BtnUserAgreement", null },
 
-                             { "BtnPrivacyPolicy", null },
 
-                             { "BtnAboutUs", null }
 
-                         };
 
-                     SortChildObjects(actionMapInfraredC);
 
-                     break;
 
-             }
 
-         }
 
-         void SortChildObjects(Dictionary<string, Transform> actionMap) {
 
-           
 
-             // 查找子对象并按名称填充 actionMap
 
-             foreach (Transform child in panelLeftContent)
 
-             {
 
-                 if (actionMap.ContainsKey(child.name))
 
-                 {
 
-                     actionMap[child.name] = child;
 
-                 }
 
-                 else
 
-                 {
 
-                     // 如果子对象不在 actionMap 中,则隐藏它
 
-                     child.gameObject.SetActive(false);
 
-                 }
 
-             }
 
-             // 获取按字典定义顺序的子对象列表(过滤掉未找到的对象)
 
-             var sortedChildren = actionMap.Values.Where(child => child != null).ToList();
 
-             // 重新排列子对象
 
-             for (int i = 0; i < sortedChildren.Count; i++)
 
-             {
 
-                 sortedChildren[i].SetSiblingIndex(i);
 
-             }
 
-         }
 
-         void OnDestroy()
 
-         {
 
-             PersistenHandler.ins?.menuBackCtr.views.Remove(this);
 
-         }
 
-         public bool OnMenuBack()
 
-         {
 
-             ViewManager2.HideView(ViewManager2.Path_SettingsView);
 
-             return true;
 
-         }
 
-         //模拟点击新手教程按钮
 
-         public void OnClick_BtnNewUser() {
 
-             this.OnClick_PanelLeftItem(BtnNewUserObj.transform);
 
-         }
 
-         public void OnClick_PanelLeftItem(Transform target)
 
-         {
 
-             foreach (Transform item in panelLeftContent)
 
-             {
 
-                 if (item.name == "BtnSignOut") continue;
 
-                 if (item == target)
 
-                 {
 
-                     item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Bold;
 
-                     item.Find("Text").GetComponent<Text>().color = Color.white;
 
-                     bool oldActive = item.Find("LightMask").gameObject.activeSelf;
 
-                     item.Find("LightMask").gameObject.SetActive(true);
 
-                     if (!oldActive)
 
-                     {
 
-                         AudioMgr.ins.PlayBtn();
 
-                         ShowBox(item.name);
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Normal;
 
-                     item.Find("Text").GetComponent<Text>().color = Color.gray;
 
-                     item.Find("LightMask").gameObject.SetActive(false);
 
-                 }
 
-             }
 
-         }
 
-         void ShowBox(string itemName)
 
-         {
 
-             // 定义所有 ShowBox 方法,并将初始状态设为 false
 
-             var actionMap = new Dictionary<string, System.Action<bool>>
 
-             {
 
-                 { "BtnSound", ShowBoxSound },
 
-                 { "BtnLevel", ShowBoxLevel },
 
-                 { "BtnNewUser", ShowBoxNewUser },
 
-                 { "BtnUserSettings", ShowBoxUserSettings },
 
-                 { "BtnBackStageManagement",ShowBackStageManagement},
 
-                 { "BtnLanguage", ShowBoxLanguage },
 
-                 { "BtnUserAgreement", ShowBoxUserAgreement },
 
-                 { "BtnPrivacyPolicy", ShowBoxPrivacyPolicy },
 
-                 { "BtnAboutUs", ShowBoxAboutUs }
 
-             };
 
-             // 如果不是红外应用,则包括 BtnScreenDistance
 
-             if (!CommonConfig.bInfraredApp)
 
-             {
 
-                 actionMap["BtnScreenDistance"] = ShowBoxScreenDistance;
 
-             }
 
-             // 先将所有状态设为 false
 
-             foreach (var action in actionMap.Values)
 
-             {
 
-                 action(false);
 
-             }
 
-             // 将指定的 itemName 对应的按钮设为 true
 
-             if (actionMap.TryGetValue(itemName, out var selectedAction))
 
-             {
 
-                 selectedAction(true);
 
-             }
 
-         }
 
-         //void ShowBox(string itemName)
 
-         //{
 
-         //    ShowBoxSound(itemName == "BtnSound");
 
-         //    ShowBoxLevel(itemName == "BtnLevel");
 
-         //    ShowBoxNewUser(itemName == "BtnNewUser");
 
-         //    ShowBoxUserSettings(itemName == "BtnUserSettings");
 
-         //    if (!CommonConfig.bInfraredApp)ShowBoxScreenDistance(itemName == "BtnScreenDistance");
 
-         //    ShowBoxLanguage(itemName == "BtnLanguage");
 
-         //    ShowBoxUserAgreement(itemName == "BtnUserAgreement");
 
-         //    ShowBoxPrivacyPolicy(itemName == "BtnPrivacyPolicy");
 
-         //    ShowBoxAboutUs(itemName == "BtnAboutUs");
 
-         //}
 
-         public void ShowBoxUserSettings(bool show) {
 
-             transform.Find("PanelContent/BoxUserSettings").gameObject.SetActive(show);
 
-         }
 
-         public void ShowBackStageManagement(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxBackStageManagement").gameObject.SetActive(show);
 
-         }
 
-         public void ShowBoxSound(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxSound").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxLevel(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxLevel").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxNewUser(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxNewUser").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxScreenDistance(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxScreenDistance").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxLanguage(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxLanguage").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxUserAgreement(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxUserAgreement").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxPrivacyPolicy(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxPrivacyPolicy").gameObject.SetActive(show);
 
-         }
 
-         void ShowBoxAboutUs(bool show)
 
-         {
 
-             transform.Find("PanelContent/BoxAboutUs").gameObject.SetActive(show);
 
-             GameVersionText.text = "V" + Application.version;
 
-         }
 
-         public void ShowModalConfirmSignOut(bool show)
 
-         {
 
-             transform.Find("ModalConfirmSignOut").gameObject.SetActive(show);
 
-         }
 
-         public void OnClick_QuitGame()
 
-         {
 
-             AudioMgr.ins.PlayBtn();
 
-             Application.Quit();
 
-         }
 
-         public void OnClick_SignOut()
 
-         {
 
-             AudioMgr.ins.PlayBtn();
 
-             ShowModalConfirmSignOut(true);
 
-         }
 
-         public void OnClick_Back()
 
-         {
 
-             AudioMgr.ins.PlayBtn();
 
-             ViewManager2.HideView(ViewManager2.Path_SettingsView);
 
-         }
 
-       
 
-     }
 
- }
 
 
  |