Explorar el Código

蓝牙模块相关调整

lvjincheng hace 4 años
padre
commit
09548c6b71

+ 7 - 2
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -220,13 +220,18 @@ public class BluetoothAim : MonoBehaviour
                 else needModularAwake.Unlock();;
                 CheckAndStartUp();
             };
+            GlobalEventCenter.ins.onDeviceCalibrateViewAwakeChanged += (waked) => {
+                if (waked) needModularAwake.Lock();
+                else needModularAwake.Unlock();;
+                CheckAndStartUp();
+            };
         }
         void InitWhenConenct() { 
             canAutoDormancy = true;
             //刚连上时先获取电量
             SendCDM(null, () => {
                 CheckAndStartUp();
-            }, "b", "b");
+            }, "b", "b", "1", "s");
         }
         void DestroyWhenDisconenct() {
             canAutoDormancy = false;
@@ -239,7 +244,7 @@ public class BluetoothAim : MonoBehaviour
                 return !isStartUp;
             }, () => {
                 isStartUp = true;
-            }, "b", "w", "1", "3");
+            }, "b", "w", "3");
         }
         //休眠
         void Dormancy() {

+ 1 - 0
Assets/BowArrow/Scripts/Event/GlobalEventCenter.cs

@@ -7,6 +7,7 @@ public class GlobalEventCenter : MonoBehaviour
     public System.Action onGameSceneLoad;
     public System.Action onGameSceneDestroy;
     public System.Action<bool> onSimulateMouseAwakeChanged; //Param0:激活/熄灭
+    public System.Action<bool> onDeviceCalibrateViewAwakeChanged;
 
     private static GlobalEventCenter _ins;
     public static GlobalEventCenter ins {

+ 1 - 1
Assets/BowArrow/Scripts/Expand/SB_EventSystem.cs

@@ -103,7 +103,7 @@ public class SB_EventSystem : MonoBehaviour
             if (!simulateMouseIsAwaked) return;
             if (hasAxisQuat) {
                 Vector3 lastAngle = nowAxisQuat.eulerAngles;
-                nowAxisQuat = Quaternion.Lerp(nowAxisQuat, targetAxisQuat, 0.333f * 8);
+                nowAxisQuat = Quaternion.Lerp(nowAxisQuat, targetAxisQuat, 0.033f * 8);
                 Vector3 curAngle = nowAxisQuat.eulerAngles;
                 float dx = FormatDeltaAngleY(curAngle.y - lastAngle.y) / 150f * simulateMouse.GetScaleScreenWidth();
                 float dy = -FormatDeltaAngleX(curAngle.x - lastAngle.x) / 100f * simulateMouse.GetScaleScreenHeight();

+ 9 - 0
Assets/BowArrow/Scripts/View/DeviceCalibrateView.cs

@@ -27,6 +27,12 @@ public class DeviceCalibrateView : MonoBehaviour
         o.GetComponent<DeviceCalibrateView>().guide = itemType == DeviceCalibrateItem.Guide;
     }
 
+    void Awake() {
+        try { 
+            GlobalEventCenter.ins.onDeviceCalibrateViewAwakeChanged?.Invoke(true); 
+        } catch (System.Exception e) { Debug.LogError(e.Message); }
+    }
+
     void Start()
     {
         BluetoothHolder.ins.ShowMagEllipse(this);
@@ -52,6 +58,9 @@ public class DeviceCalibrateView : MonoBehaviour
 
     void OnDestroy()
     {
+        try { 
+            GlobalEventCenter.ins.onDeviceCalibrateViewAwakeChanged?.Invoke(false); 
+        } catch (System.Exception e) { Debug.LogError(e.Message); }
         BluetoothHolder.ins.HideMagEllipse(this);
         // if (gyrCalibrating) {
         //     AimHandler.ins.CalibrateGyr(false);