| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /* 蓝牙状态信息获取接口 */
- public class BluetoothStatus
- {
- // return textID, Color
- public static (int, Color) GetStatusInfo(BluetoothStatusEnum status)
- {
- if (status == BluetoothStatusEnum.Connecting) {
- //return (15, Color.blue);
- return (15,new Color(255f / 255f, 165f / 255f, 0));
- } else if (status == BluetoothStatusEnum.ConnectSuccess) {
- //return (16, Color.new Color32(255,215,0,0));
- // return (16,new Color(255f / 255f, 215f / 255f, 0));
- return (16, new Color(255 / 255f, 243 / 255f, 103 / 255f));
- } else if (status == BluetoothStatusEnum.ConnectFail) {
- return (17, Color.red);
- }
- return (14, Color.white);
- }
- public static string GetStatusTextKey(BluetoothStatusEnum status)
- {
- string result = "Connect_BLE_None";
- switch (BluetoothAim.ins.status)
- {
- case BluetoothStatusEnum.None:
- result = "Connect_BLE_None";
- break;
- case BluetoothStatusEnum.Connect:
- result = "Connect_BLE_Connect";
- break;
- case BluetoothStatusEnum.Connecting:
- result = "Connect_BLE_Connecting";
- break;
- case BluetoothStatusEnum.ConnectSuccess:
- result = "Connect_BLE_Connected";
- break;
- case BluetoothStatusEnum.ConnectFail:
- result = "Connect_BLE_Break";
- break;
- }
- return result;
- }
- public static (int, Color) GetBLE2StatusInfo(SmartBowSDK.BluetoothStatusEnum status)
- {
- if (status == SmartBowSDK.BluetoothStatusEnum.Connecting)
- {
- //return (15, Color.blue);
- return (15, new Color(255f / 255f, 165f / 255f, 0));
- }
- else if (status == SmartBowSDK.BluetoothStatusEnum.Connected)
- {
- //return (16, Color.new Color32(255,215,0,0));
- // return (16,new Color(255f / 255f, 215f / 255f, 0));
- return (16, new Color(255 / 255f, 243 / 255f, 103 / 255f));
- }
- //else if (status == SmartBowSDK.BluetoothStatusEnum.None)
- //{
- // return (17, Color.red);
- //}
- return (14, Color.white);
- }
- public static string GetBLE2StatusTextKey(SmartBowSDK.BluetoothStatusEnum status)
- {
- string result = "Connect_BLE_None";
- switch (status)
- {
- case SmartBowSDK.BluetoothStatusEnum.None:
- result = "Connect_BLE_None";
- break;
- case SmartBowSDK.BluetoothStatusEnum.Connecting:
- result = "Connect_BLE_Connecting";
- break;
- case SmartBowSDK.BluetoothStatusEnum.Connected:
- result = "Connect_BLE_Connected";
- break;
- }
- return result;
- }
- public static bool IsAllConnected()
- {
- if (!BluetoothAim.ins) return false;
- return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
- }
- }
- public enum BluetoothStatusEnum
- {
- None,
- Connect,
- Connecting,
- ConnectSuccess,
- ConnectFail
- }
- public enum BluetoothPlayer {
- FIRST_PLAYER,
- SECONDE_PLAYER,
- }
|