| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- using UnityEngine.SceneManagement;
 
- /* 设备断线重连界面(同时也检测进入游戏时是否已经连接所需设备) */
 
- public class DeviceReconnectView : MonoBehaviour
 
- {
 
-     [SerializeField] GameObject btnConnectBow;
 
-     [SerializeField] GameObject btnConnectArrow;
 
-     [SerializeField] Button btnClose;
 
-     static DeviceReconnectView ins;
 
-     public Action onComplete = null;
 
-     public static GameObject Show() {
 
-         string sceneName = SceneManager.GetActiveScene().name;
 
-         if (!sceneName.StartsWith("Game")) return null;
 
-         try {
 
-             GameObject view = Resources.Load<GameObject>("Prefabs/Views/DeviceReconnectView");
 
-             return GameObject.Instantiate(view);
 
-         } catch (Exception) {}
 
-         return null;
 
-     }
 
-     void Awake() 
 
-     {
 
-         if (ins)
 
-         {
 
-             Destroy(this.gameObject);
 
-         } else {
 
-             ins = this;
 
-         }
 
-     }
 
-     
 
-     void Start()
 
-     {
 
-         InitBtnForConnect();
 
-         RenderDeviceNames();
 
-         GameMgr.ins.addLockerForGamePause(this);
 
-         //用于测试阶段,暂时屏蔽该页面
 
-         Destroy(this.gameObject); if (onComplete != null) onComplete();
 
-     }
 
-     void OnDestroy()
 
-     {
 
-         if (ins == this) ins = null;
 
-         if (GameMgr.ins) GameMgr.ins.removeLockerForGamePause(this);
 
-     }
 
-     void Update()
 
-     {
 
-         UpdateBtnForConnect();
 
-         btnClose.interactable = BluetoothStatus.IsAllConnected();
 
-     }
 
-     void RenderDeviceNames()
 
-     {
 
-         try {
 
-             (DeviceInfo bowInfo, DeviceInfo arrowInfo) = DeviceMgr.ins.GetCurrentBowArrowInfo();
 
-             this.transform.Find("ShowBow/Text").GetComponent<TextAutoLanguage>().SetText(bowInfo.config.name);
 
-             this.transform.Find("ShowArrow/Text").GetComponent<TextAutoLanguage>().SetText(arrowInfo.config.name);
 
-         } catch (System.Exception) {}
 
-     }
 
-     void InitBtnForConnect()
 
-     {
 
-         btnConnectBow.GetComponent<Button>().onClick.AddListener(delegate() {
 
-             BluetoothAim.ins.DoConnect();
 
-         });
 
-         btnConnectArrow.GetComponent<Button>().onClick.AddListener(delegate() {
 
-             BluetoothShoot.ins.DoConnect();
 
-         });
 
-     }
 
-     BluetoothStatusEnum bowStatus;
 
-     BluetoothStatusEnum arrowStatus;
 
-     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;
 
-         }
 
-         if (BluetoothShoot.ins && arrowStatus != BluetoothShoot.ins.status) {
 
-             arrowStatus = BluetoothShoot.ins.status;
 
-             (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothShoot.ins.status);
 
-             btnConnectArrow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
 
-             btnConnectArrow.GetComponentInChildren<Text>().color = color;
 
-         }
 
-     }
 
-     public void BackHome() {
 
-         AudioMgr.ins.PlayBtn();
 
-         SceneManager.LoadScene("Home", LoadSceneMode.Single);
 
-     }
 
-     public void Close() {
 
-         AudioMgr.ins.PlayBtn();
 
-         Destroy(this.gameObject);
 
-         if (onComplete != null) {
 
-             onComplete();   
 
-         }
 
-     }
 
- }
 
 
  |