| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ConnectGuidanceView : MonoBehaviour
- {
- [SerializeField] List<GameObject> layouts;
- bool isNext = false;
- void Start()
- {
- InitConfirmStorage();
- transform.Find("BtnNext").GetComponent<Button>().onClick.AddListener(OnClick_Next);
- if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMIS)
- {
- ShowDeviceLayout(1);
- }
- else {
- ShowDeviceLayout(0);
- }
- //NewUserGuiderManager newUserGuiderManager = FindObjectOfType<NewUserGuiderManager>();
- //newUserGuiderManager.curConfigKey = "视角归位-触发";
- //newUserGuiderManager.isNewModule = AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMIS;
- ////进入射箭场景
- //GlobalData.pkMatchType = PKMatchType.None;
- //GameMgr.gameType = 1;
- ////射一箭回到连接页面,Device.view
- //GameMgr.bNavBack = true;
- //GameMgr.bShowDistance = false;
- //AimHandler.ins.bInitOne = true;
- //UnityEngine.SceneManagement.SceneManager.LoadScene(
- // "Game", UnityEngine.SceneManagement.LoadSceneMode.Single);
- }
- void ShowDeviceLayout(int index)
- {
- for (int i = 0; i < layouts.Count; i++)
- {
- GameObject _button = layouts[i];
- _button.SetActive(index == i);
- }
- }
- void Update()
- {
- UpdateBtnForConnect();
- }
- void OnClick_Next()
- {
- if (bowStatus == BluetoothStatusEnum.ConnectSuccess)
- {
- AimHandler.ins.OnSaveAimDeviceInfos();
- ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
- ViewManager2.ShowView(ViewManager2.Path_GyrGuidanceView);
- }
- }
- void InitConfirmStorage()
- {
- transform.Find("ConfirmStep/Toggle").GetComponent<Toggle>().SetIsOnWithoutNotify(IsConfirmInStorage());
- transform.Find("ConfirmStep/Toggle").GetComponent<Toggle>().onValueChanged.AddListener(v =>
- {
- SetConfirmToStorage(v);
- });
- }
- bool IsConfirmInStorage()
- {
- return PlayerPrefs.GetInt("connect-confirm-" + LoginMgr.myUserInfo.id, 0) == 1;
- }
- void SetConfirmToStorage(bool value)
- {
- PlayerPrefs.SetInt("connect-confirm-" + LoginMgr.myUserInfo.id, value ? 1 : 0);
- }
- [SerializeField] GameObject btnConnectBow;
- BluetoothStatusEnum bowStatus;
- void UpdateBtnForConnect()
- {
- if (BluetoothAim.ins && bowStatus != BluetoothAim.ins.status)
- {
- bowStatus = BluetoothAim.ins.status;
- (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothAim.ins.status);
- btnConnectBow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
- btnConnectBow.GetComponentInChildren<Text>().color = color;
- btnConnectBow.transform.Find("Check").gameObject.SetActive(bowStatus == BluetoothStatusEnum.ConnectSuccess);
- }
- //自动跳转
- if(!isNext && bowStatus == BluetoothStatusEnum.ConnectSuccess)
- {
- isNext = true;
- OnClick_Next();
- }
- }
- public void OnClick_ConnectBLE()
- {
- if (!IsConfirmInStorage())
- {
- PopupMgr.ins.ShowTip("Please Confirmed the completion of the above steps");
- return;
- }
- if (HomeView.ShowProminentBeforeConnectBLE()) return;
- BluetoothAim.ins.DoConnect();
- }
- public void OnClick_Back()
- {
- AudioMgr.ins.PlayBtn();
- ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
- }
- }
|