BluetoothStatus.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /* 蓝牙状态信息获取接口 */
  5. public class BluetoothStatus
  6. {
  7. // return textID, Color
  8. public static (int, Color) GetStatusInfo(BluetoothStatusEnum status)
  9. {
  10. if (status == BluetoothStatusEnum.Connecting) {
  11. //return (15, Color.blue);
  12. return (15,new Color(255f / 255f, 165f / 255f, 0));
  13. } else if (status == BluetoothStatusEnum.ConnectSuccess) {
  14. //return (16, Color.new Color32(255,215,0,0));
  15. // return (16,new Color(255f / 255f, 215f / 255f, 0));
  16. return (16, new Color(255 / 255f, 243 / 255f, 103 / 255f));
  17. } else if (status == BluetoothStatusEnum.ConnectFail) {
  18. return (17, Color.red);
  19. }
  20. return (14, Color.white);
  21. }
  22. public static string GetStatusTextKey(BluetoothStatusEnum status)
  23. {
  24. string result = "Connect_BLE_None";
  25. switch (BluetoothAim.ins.status)
  26. {
  27. case BluetoothStatusEnum.None:
  28. result = "Connect_BLE_None";
  29. break;
  30. case BluetoothStatusEnum.Connect:
  31. result = "Connect_BLE_Connect";
  32. break;
  33. case BluetoothStatusEnum.Connecting:
  34. result = "Connect_BLE_Connecting";
  35. break;
  36. case BluetoothStatusEnum.ConnectSuccess:
  37. result = "Connect_BLE_Connected";
  38. break;
  39. case BluetoothStatusEnum.ConnectFail:
  40. result = "Connect_BLE_Break";
  41. break;
  42. }
  43. return result;
  44. }
  45. public static (int, Color) GetBLE2StatusInfo(SmartBowSDK.BluetoothStatusEnum status)
  46. {
  47. if (status == SmartBowSDK.BluetoothStatusEnum.Connecting)
  48. {
  49. //return (15, Color.blue);
  50. return (15, new Color(255f / 255f, 165f / 255f, 0));
  51. }
  52. else if (status == SmartBowSDK.BluetoothStatusEnum.Connected)
  53. {
  54. //return (16, Color.new Color32(255,215,0,0));
  55. // return (16,new Color(255f / 255f, 215f / 255f, 0));
  56. return (16, new Color(255 / 255f, 243 / 255f, 103 / 255f));
  57. }
  58. //else if (status == SmartBowSDK.BluetoothStatusEnum.None)
  59. //{
  60. // return (17, Color.red);
  61. //}
  62. return (14, Color.white);
  63. }
  64. public static string GetBLE2StatusTextKey(SmartBowSDK.BluetoothStatusEnum status)
  65. {
  66. string result = "Connect_BLE_None";
  67. switch (status)
  68. {
  69. case SmartBowSDK.BluetoothStatusEnum.None:
  70. result = "Connect_BLE_None";
  71. break;
  72. case SmartBowSDK.BluetoothStatusEnum.Connecting:
  73. result = "Connect_BLE_Connecting";
  74. break;
  75. case SmartBowSDK.BluetoothStatusEnum.Connected:
  76. result = "Connect_BLE_Connected";
  77. break;
  78. }
  79. return result;
  80. }
  81. public static bool IsAllConnected()
  82. {
  83. if (!BluetoothAim.ins) return false;
  84. return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  85. }
  86. }
  87. public enum BluetoothStatusEnum
  88. {
  89. None,
  90. Connect,
  91. Connecting,
  92. ConnectSuccess,
  93. ConnectFail
  94. }
  95. public enum BluetoothPlayer {
  96. FIRST_PLAYER,
  97. SECONDE_PLAYER,
  98. }