using System.Collections; using System.Collections.Generic; using UnityEngine; using SmartBowSDK; public class SmartBowHandler { SmartBowHelper smartBowHelper; Bow bow; public SmartBowHandler(SmartBowHelper smartBowHelper, Bow bow) { smartBowHelper.OnBluetoothModuleInited += OnBluetoothModuleInited; smartBowHelper.OnRotationUpdate += OnRotationUpdate; smartBowHelper.OnShooting += OnShooting; smartBowHelper.OnBleDeviceState += OnBleDeviceState; smartBowHelper.OnFunctionKeyPress += OnFunctionKeyPress; this.smartBowHelper = smartBowHelper; this.bow = bow; } void OnBluetoothModuleInited() { smartBowHelper.StartRotationSensor(); smartBowHelper.StartShootingSensor(); } void OnRotationUpdate(Quaternion rotation) { bow.transform.localRotation = rotation; } void OnShooting(float speed) { bow.Shoot(); } void OnFunctionKeyPress() { smartBowHelper.ResetAim(); } void OnBleDeviceState(BluetoothDeviceType bluetoothDeviceType, BluetoothDeviceStatus bluetoothDeviceStatus) { Debug.Log("设备类型:" + bluetoothDeviceType + "设备状态" + bluetoothDeviceStatus); if (bluetoothDeviceType == BluetoothDeviceType.Pistol1) { if (bluetoothDeviceStatus == BluetoothDeviceStatus.MagazineSeparation) { this.bow.info.text = "设备类型:枪" + ",状态:弹夹分离"; Debug.Log(this.bow.info.text); } else if (bluetoothDeviceStatus == BluetoothDeviceStatus.MagazineLoading) { this.bow.info.text = "设备类型:枪" + ",状态:弹夹上膛"; Debug.Log(this.bow.info.text); } else { this.bow.info.text = "设备类型:枪" + ",其他状态:" + bluetoothDeviceStatus; Debug.Log(this.bow.info.text); } } } }