| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using AppUI.Bluetooth;
- using AppUI.Localization;
- using AppUI.Manager;
- using AppUI.Manager.View;
- using AppUI.Util.TabSwitcher;
- using AppUI.View.Home.UserCenter;
- using InfraredManager;
- using SmartBowSDK;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using UnityEngine.UI;
- namespace AppUI.View.Home.Main
- {
- public class HomeViewBottomBar : MonoBehaviour
- {
- void Start()
- {
- Dictionary<string, Transform> actionMap = new Dictionary<string, Transform>
- {
- { "IconConnect", null },
- { "IconScreen", null },
- //{ "IconGuider", null },
- //{ "IconShop", null },
- //{ "IconNewUser", null },
- //{ "IconFriend", null },
- { "IconRank", null },
- { "IconSetUp", null }
- };
- SortChildObjects(actionMap);
- // 按条件禁用特定按钮的交互性
- if (CommonConfig.StandaloneMode)
- {
- DisableButtonInteractivity(actionMap, new List<string> { "IconGuider", "IconFriend", "IconRank" });
- }
- }
- void DisableButtonInteractivity(Dictionary<string, Transform> actionMap, List<string> buttonNames)
- {
- foreach (var buttonName in buttonNames)
- {
- // 检查 actionMap 中是否有该键且对应的 Transform 不为 null
- if (actionMap.TryGetValue(buttonName, out Transform buttonTransform) && buttonTransform != null)
- {
- Image image = buttonTransform.GetComponent<Image>();
- if (image != null)
- {
- image.color = new Color(200f / 255f, 200f / 255f, 200f / 255f, 130f / 255f);
- }
- Button button = buttonTransform.GetComponent<Button>();
- if (button != null)
- {
- button.interactable = false;
- button.gameObject.SetActive(false);
- }
- }
- }
- }
- void SortChildObjects(Dictionary<string, Transform> actionMap)
- {
- // 查找子对象并按名称填充 actionMap
- foreach (Transform child in transform)
- {
- 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);
- }
- }
- // Update is called once per frame
- //void Update()
- //{
- //}
- public void GoToConnect()
- {
- Debug.Log("进入连接页面");
- AudioMgr.ins.PlayBtn();
- //ViewMgr.Instance.ShowView<DeviceViewInfrared>();
- ViewManager.ShowView(UIViewType.DeviceView);
- }
- public void GoToScreen()
- {
- AudioMgr.ins.PlayBtn();
- if (CommonConfig.bLimitTip && !HomeView.ins.IsConnectSuccess()) {
- ModuleViewMgr.ins.ShowDeviceConnect();
- return;
- }
- if (!IsInfraredHardwareConnected())
- {
- ModuleViewMgr.ins.ShowDeviceConnectInfrared();
- return;
- }
- //如果没有屏幕定位,则直接启动屏幕定位
- if (HomeView.ins.IsScreenPositioned())
- {
- ViewManager.ShowView(UIViewType.PositioningView);
- }
- else {
- ViewManager.ShowView(UIViewType.InfraredView);
- }
- }
- static bool IsInfraredHardwareConnected()
- {
- SmartBowDeviceHub hub = SmartBowDeviceHub.ins;
- if (hub == null || !hub.IsConnected(BluetoothPlayer.FIRST_PLAYER))
- return false;
- return hub.IsMainConnectToInfraredDevice() || hub.IsMainConnectToGun();
- }
- public void GoToSetup()
- {
- AudioMgr.ins.PlayBtn();
- GameObject settingsViewObj = ViewManager.ShowView(UIViewType.SettingsView);
- //settingsViewObj.GetComponent<SmartBow.SettingsView>().ShowBoxSound(true);
- UITabSwitcher tab = settingsViewObj.GetComponent<UITabSwitcher>();
- tab.SetDefaultTab("BtnCommon");
- }
- public void GoToShop()
- {
- AudioMgr.ins.PlayBtn();
- //if (ShopView.ins) return;
- //ViewMgr.Instance.ShowView<ShopView>();
- }
- public void GoToGuider()
- {
- AudioMgr.ins.PlayBtn();
- //跳转至 设置-教程视频
- //GameObject settingsViewObj = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_SettingsView);
- //settingsViewObj.GetComponent<SmartBow.SettingsView>().OnClick_BtnNewUser();
- //NewUserGuiderManager.ins.ReviewNewUserGuide();
- }
- public void GoToNewUser()
- {
- AudioMgr.ins.PlayBtn();
- //ViewManager2.ShowView(ViewManager2.Path_ConnectGuidanceView);
- }
- public void GoToFriends()
- {
- Debug.Log("进入好友页面");
- AudioMgr.ins.PlayBtn();
- //ViewManager2.ShowView(ViewManager2.Path_SocialView);
- }
- public void GoToRanking()
- {
- Debug.Log("进入排名页面");
- AudioMgr.ins.PlayBtn();
- ViewManager.ShowView(UIViewType.RankingView);
- }
- public void GoToUserCenterView()
- {
- if (CommonConfig.StandaloneMode) return;
-
- AudioMgr.ins.PlayBtn();
- ViewManager.ShowView(UIViewType.UserCenterView);
- }
- }
- }
|