Quellcode durchsuchen

红外线射击遮挡时间不能为0

lvjincheng vor 4 Jahren
Ursprung
Commit
aa3519a985
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

+ 5 - 1
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -329,13 +329,17 @@ public class ShootCheck : MonoBehaviour
         int id = bytes[1]; //序号
         float time1 = bytes[2] * 0.1f; //时区1耗时
         float time2 = bytes[3] * 0.1f; //时区2耗时
+        float totalTime = time1 + time2;
+        if (totalTime <= 0) {
+            totalTime = 0.3f;
+        }
         //校验和
         int sumCheck = bytes[0] + bytes[1] + bytes[2] + bytes[3]; 
         sumCheck &= 0xff;
         //校验和比较结果
         bool sumCheckRes = sumCheck == bytes[4];
         //弓轨速度
-        float speed = 0.05f / (time1 / 1000 + time2 / 1000);
+        float speed = 0.05f / (totalTime / 1000f);
         //通过动能定理求箭的速度(实体箭质量*实体箭速度^2=游戏中箭的质量*游戏中箭的速度^2)
         shootSpeed = Mathf.Sqrt(speed * speed * arrowWeight / LoginMgr.myUserInfo.actualArrowWeight);  
         //打印