fix:调整体感服问题

This commit is contained in:
bzx
2025-10-20 15:26:55 +08:00
parent 8bbb954c15
commit 7bc3335044
6 changed files with 78 additions and 33 deletions

View File

@@ -9,7 +9,7 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="picoapp" android:host="launch" android:path="/com.pineappletech.defendnj.hunanhengyangzhuhuidongzhoudaonei"/>
<data android:scheme="picoapp" android:host="launch" android:path="/com.pineappletech.defendnj.yunnanlincanglinxianghengjidixia"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

View File

@@ -17963,6 +17963,7 @@ MonoBehaviour:
doorPos: {fileID: 1128989868}
pkPos: {fileID: 107388154}
gQPos: {fileID: 508421177}
endPkPos: []
doorAnim: {fileID: 2116810936}
--- !u!1 &1318686166
GameObject:

View File

@@ -18,7 +18,7 @@ public class TrueGearEffectManager : MonoBehaviour
GetConnectIndex = 20;
AddHitPart();
#if !UNITY_EDITOR
StartRequestTrueGear();
//TrueGearEffectManager.Ins.StartRequestTrueGear();
#endif
}
@@ -111,17 +111,27 @@ public class TrueGearEffectManager : MonoBehaviour
if (!res)
return;
List<DeviceData> res1 = androidConnector.GetScanedDevices();
Debug.Log(res1.ToString());
foreach (var item in res1)
List<DeviceData> devices = androidConnector.GetScanedDevices();
if (devices == null || devices.Count == 0)
{
Debug.Log("未扫描到任何设备");
return;
}
foreach (var device in devices)
{
bool connected = androidConnector.ConnectToDevice(device.address);
if (connected)
{
androidConnector.ConnectToDevice(item.address);
Debug.Log(string.Format("Device Connect: {0}, {1}", item.name, item.address));
Debug.Log($"成功连接设备: {device.name} - {device.address}");
isGetConnect = true;
ChangeElectricalLevel();
return;
}
else
{
Debug.LogWarning($"设备被占用或连接失败: {device.name} - {device.address}");
}
}
Debug.Log("No device found");
}
@@ -197,7 +207,7 @@ public class TrueGearEffectManager : MonoBehaviour
}}
]
}}";
SendPlayEffectByContent(json);
}
@@ -208,8 +218,34 @@ public class TrueGearEffectManager : MonoBehaviour
Debug.Log("OnTestClick" + res);
if (!res)
return;
androidConnector.SendPlayEffectByContent(jsonStr);
try
{
androidConnector.SendPlayEffectByContent(jsonStr);
}
catch (Exception ex)
{
Debug.LogError("调用 TrueGear 崩溃保护: " + ex);
ReconnectTrueGear();
}
}
// 当检测蓝牙断开或异常时调用
void ReconnectTrueGear()
{
try
{
var conn = TruegearAndroidConnector.Instance;
conn.InitShellJavaObject();
conn.RequestPermission();
conn.StartScan();
}
catch (Exception e)
{
Debug.LogError("重新初始化 TrueGear 失败:" + e);
}
}
public List<string> hitParts=new List<string>();
public void AddHitPart()
@@ -222,7 +258,28 @@ public class TrueGearEffectManager : MonoBehaviour
}
public void OnHit(bool isUp, int index,bool isArm)
{
//ChangeElectricalLevel();
TruegearAndroidConnector androidConnector = TruegearAndroidConnector.Instance;
if (androidConnector == null)
{
Debug.LogWarning("TrueGear connector 为空,跳过调用");
isGetConnect = false;
return;
}
if (!androidConnector.IsAvailable())
{
Debug.LogWarning("TrueGear 蓝牙不可用或断开,跳过调用");
isGetConnect = false;
return;
}
if (!isGetConnect)
{
androidConnector.InitShellJavaObject();
androidConnector.RequestPermission();
StartCoroutine(TrueGearAndroidConnector());
return;
}
List<int> motorIDs = new List<int>();
string hitPart= hitParts[index];
switch (hitPart)
@@ -236,11 +293,11 @@ public class TrueGearEffectManager : MonoBehaviour
case "rightDown":
motorIDs.AddRange(isUp?new int[] { 10,11,14,15}: new int[] { 114, 115, 118,119 }); break;
case "rightAim":
Debug.Log("xxzz");
motorIDs.AddRange(new int[] { 0,100}); break;
default:
motorIDs.Add(0); break;
}
PlayVibrationEffect(
effectName: $"Hit_{hitPart}",
motorIndex: motorIDs,

View File

@@ -127,25 +127,10 @@ public class Player : NetworkRoomPlayer,IDamagable
Vector3 directionFormHit=(transform.position-_sender.position).normalized;
float angle = Vector3.Angle(forward, directionFormHit);
int index = Random.Range(0, 4);
TrueGearEffectManager.Ins.OnHit(angle > 90,index,false);
if(TrueGearEffectManager.Ins!=null)
TrueGearEffectManager.Ins.OnHit(angle > 90,index,false);
}
#endif
// if (currentHp <= 0 && IsAlive)
// {
// IsAlive = false;
// isDie = true;
// GameLocal.Ins.DieUI.SetActive(true);
// GameManager.Ins.PlaySound2DRPC("1.35");
// MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
// {
// IsAlive = true;
// isDie = false;
// GameLocal.Ins.DieUI.SetActive(false);
// currentHp = maxHp;
// EventDispatcher.TriggerEvent("HpChange", currentHp, maxHp);
// time = 0f;
// }, 5f, this);
// }
if (currentHp > 0)
{
GameLocal.Ins.HitUI.SetActive(true);