Przeglądaj źródła

激光默认状态

17600099689 1 rok temu
rodzic
commit
1fc9f7c32c

+ 6 - 2
Assets/BowArrow/Scripts/ArrowSerialPort.cs

@@ -163,7 +163,7 @@ public class ArrowSerialPort : MonoBehaviour
     bool lightWaitClose = false;
     public void DelayCloseLight()
     {
-        if (!lightWaitClose)
+        if (!lightWaitClose && hasOnceInceCoin)
         {
             LOG("游戏时间结束 延迟关闭激光");
             Invoke("DoDelayCloseLight", 60f);
@@ -183,13 +183,17 @@ public class ArrowSerialPort : MonoBehaviour
         RequestLightState(false);
     }
 
+    //是否有过首次投币 没投币过 不关闭摄像头
+    bool hasOnceInceCoin = false;
     #region APP请求
     // 异或校验内容:命令+长度+数据内容
     /// <summary>
     /// 设置激光状态
     /// </summary>
-    public void RequestLightState(bool on)
+    public void RequestLightState(bool on, bool insertCoin = false)
     {
+        if (insertCoin)
+            hasOnceInceCoin = true;
         List<byte> data = new List<byte>();
         data.Add(0xAA);//起始码
         data.Add(0x83);//命令号

+ 1 - 1
Assets/BowArrow/Scripts/Standalone/StandaloneAPI.cs

@@ -172,7 +172,7 @@ public class StandaloneAPI
             var port = SerialPortHelper.ins.GetPort();
             port?.CancelDelayCloseLight();
             if (!UserSettings.ins.lightState)
-                port?.RequestLightState(true);
+                port?.RequestLightState(true, true);
 
             CoinCount -= UserSettings.ins.PerRoundCoin;
             AddGameTimeCountDown(UserSettings.ins.PerRoundSeconds);