|
|
@@ -25,11 +25,6 @@ public class ShootCheck : MonoBehaviour
|
|
|
{
|
|
|
ins = this;
|
|
|
BluetoothDispatcher.shoot = OnDataReceived;
|
|
|
- //debug
|
|
|
- if (Application.platform == RuntimePlatform.WindowsEditor)
|
|
|
- {
|
|
|
- transportMode = 1;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//用户输入时的变化
|
|
|
@@ -125,7 +120,6 @@ public class ShootCheck : MonoBehaviour
|
|
|
Sequence sequence = DOTween.Sequence();
|
|
|
sequence.PrependInterval(1).AppendCallback(delegate() {
|
|
|
canAdjustNormalOrHightMode = true;
|
|
|
- transportMode = 0;
|
|
|
AdjustNormalOrHightMode();
|
|
|
});
|
|
|
sequence.SetUpdate(true);
|
|
|
@@ -138,23 +132,19 @@ public class ShootCheck : MonoBehaviour
|
|
|
{
|
|
|
if (!canAdjustNormalOrHightMode) return;
|
|
|
try {
|
|
|
- string sceneName = SceneManager.GetActiveScene().name;
|
|
|
- if (sceneName == "Game")
|
|
|
- {
|
|
|
- if (transportMode == 0)
|
|
|
- {
|
|
|
- transportMode = 1;
|
|
|
- BluetoothShoot.ins.WriteData("HA");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (transportMode == 1)
|
|
|
- {
|
|
|
- transportMode = 0;
|
|
|
- BluetoothShoot.ins.WriteData("NA");
|
|
|
- }
|
|
|
- }
|
|
|
+ // string sceneName = SceneManager.GetActiveScene().name;
|
|
|
+ // if (sceneName == "Game")
|
|
|
+ // {
|
|
|
+ // transportMode = 1;
|
|
|
+ // BluetoothShoot.ins.WriteData("HA");
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // transportMode = 0;
|
|
|
+ // BluetoothShoot.ins.WriteData("NA");
|
|
|
+ // }
|
|
|
+ transportMode = 0;
|
|
|
+ BluetoothShoot.ins.WriteData("NA");
|
|
|
} catch (Exception) {}
|
|
|
}
|
|
|
|
|
|
@@ -165,6 +155,7 @@ public class ShootCheck : MonoBehaviour
|
|
|
DeviceBatteryView.ins.RenderBattery(2, bytes[0]);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
string str1 = "byte=";
|
|
|
if (webSocket != null)
|
|
|
{
|
|
|
@@ -178,7 +169,22 @@ public class ShootCheck : MonoBehaviour
|
|
|
|
|
|
string str2 = "";
|
|
|
|
|
|
- if (transportMode == 1)
|
|
|
+ if (transportMode == 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < (bytes.Length -2 ) /6; i++)
|
|
|
+ {
|
|
|
+ float acc = ToAcceleratedSpeed(bytes[i * 6 + 5], bytes[i * 6 + 6]);
|
|
|
+
|
|
|
+ string t = "(采样时间:"+(int)bytes[i * 6 + 3] + "分"+ (int)bytes[i * 6 + 4]+"秒"+ TwoByteToInt(bytes[i * 6 + 1], bytes[i * 6 + 2])+"毫秒)" ;
|
|
|
+ str2 += "加速度:"+ acc + t + "\n";
|
|
|
+
|
|
|
+ if (ins.check(0, acc, 0, t) && ArmBow.ins)
|
|
|
+ {
|
|
|
+ ArmBow.ins.ADS_fire();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (transportMode == 1)
|
|
|
{
|
|
|
for (int i = 0; i < bytes.Length / 11; i++)
|
|
|
{
|
|
|
@@ -186,7 +192,7 @@ public class ShootCheck : MonoBehaviour
|
|
|
float ay = ToAcceleratedSpeed(bytes[i * 11 + 7], bytes[i * 11 + 8]);
|
|
|
float az = ToAcceleratedSpeed(bytes[i * 11 + 9], bytes[i * 11 + 10]);
|
|
|
|
|
|
- string t = "(采样时间:"+(int)bytes[i * 6 + 3] + "分"+ (int)bytes[i * 6 + 4]+"秒"+ TwoByteToInt(bytes[i * 6 + 1], bytes[i * 6 + 2])+"毫秒)" ;
|
|
|
+ string t = "(采样时间:"+(int)bytes[i * 11 + 3] + "分"+ (int)bytes[i * 11 + 4]+"秒"+ TwoByteToInt(bytes[i * 11 + 1], bytes[i * 11 + 2])+"毫秒)" ;
|
|
|
str2 += "加速度:"+ax+t+"\n";
|
|
|
|
|
|
if (ins.check(ax, ay, az, t) && ArmBow.ins)
|
|
|
@@ -206,7 +212,7 @@ public class ShootCheck : MonoBehaviour
|
|
|
float ToAcceleratedSpeed(byte b1, byte b2)
|
|
|
{
|
|
|
int value = TwoByteToInt(b1, b2);
|
|
|
- return (float)value / 32768 * LoginMgr.myUserInfo.deviceAccValue;
|
|
|
+ return (float)value / 32768 * LoginMgr.myUserInfo.arrowAccValue;
|
|
|
}
|
|
|
|
|
|
int TwoByteToInt(byte b1, byte b2)
|
|
|
@@ -230,12 +236,7 @@ public class ShootCheck : MonoBehaviour
|
|
|
{
|
|
|
maxAcc = acc;
|
|
|
}
|
|
|
- // if (acc == 15.99951f) {
|
|
|
- if (acc > 15.9f) {
|
|
|
- // double p1 = -1.188748333;
|
|
|
- // double p2 = 0.033890372;
|
|
|
- // double p3 = 3.408473747;
|
|
|
-
|
|
|
+ if (acc > 15.9f && LoginMgr.myUserInfo.arrowAccValue == 16) {
|
|
|
double p1 = -1.56729339506415;
|
|
|
double p2 = 0.0397744840580165;
|
|
|
double p3 = 4.73453844008481;
|
|
|
@@ -258,7 +259,6 @@ public class ShootCheck : MonoBehaviour
|
|
|
float totalAx = 0;
|
|
|
float totalAy = 0;
|
|
|
float totalAz = 0;
|
|
|
- Debug.LogWarning("=============keyAcc===========");
|
|
|
foreach (var keyAcc in keyAccList)
|
|
|
{
|
|
|
totalAx += Mathf.Abs(keyAcc.x);
|
|
|
@@ -275,9 +275,7 @@ public class ShootCheck : MonoBehaviour
|
|
|
}
|
|
|
lasKeytAcc = keyAcc.y;
|
|
|
keyAccIndex++;
|
|
|
- Debug.LogWarning(keyAcc);
|
|
|
}
|
|
|
- Debug.LogWarning("---------keyAcc---------");
|
|
|
|
|
|
//是不是合法射出
|
|
|
bool isLegalShoot = totalAy > totalAx && totalAy > totalAz;
|
|
|
@@ -289,7 +287,6 @@ public class ShootCheck : MonoBehaviour
|
|
|
//积分出来的值还是太小,需要一个倍率
|
|
|
shootSpeed *= 20;
|
|
|
string strShootSpeed = "初速度: " + shootSpeed + " 帧数: " + keyAccList.Count + "\n";
|
|
|
- Debug.LogWarning(strShootSpeed);
|
|
|
|
|
|
string str1 = strShootSpeed + "/////////检测到射出的数据////////////:\n";
|
|
|
for (int i=0;i<keyAccList.Count;i++)
|