From 53ec9c60acc3ca45bdd72be0df2f1c98524c9c7f Mon Sep 17 00:00:00 2001 From: suntao Date: Wed, 12 May 2021 10:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/PlayerFactory.cs | 26 ------------- Assets/PlayerFactory.cs.meta | 11 ------ .../Images/{config_bg-min.jpg => main-bg.jpg} | Bin ...onfig_bg-min.jpg.meta => main-bg.jpg.meta} | 2 +- Assets/Scripts/Apis/UserApi.cs | 4 +- Assets/Scripts/Devices/Ant/AntConnector.cs | 36 +++++++++++------- Assets/Scripts/Scenes/LoginController.cs | 8 ++-- Assets/Scripts/Scenes/MainController.cs | 14 ++++--- Assets/Scripts/UI/Prefab/Device/DeviceView.cs | 6 --- .../UI/Prefab/Panel/EditUserController.cs | 8 ++-- 10 files changed, 42 insertions(+), 73 deletions(-) delete mode 100644 Assets/PlayerFactory.cs delete mode 100644 Assets/PlayerFactory.cs.meta rename Assets/Resources/Images/{config_bg-min.jpg => main-bg.jpg} (100%) rename Assets/Resources/Images/{config_bg-min.jpg.meta => main-bg.jpg.meta} (99%) diff --git a/Assets/PlayerFactory.cs b/Assets/PlayerFactory.cs deleted file mode 100644 index b785deca..00000000 --- a/Assets/PlayerFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Mapbox.Directions; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Assets.Scenes.Ride.Scripts -{ - public class PlayerFactory : MonoBehaviour - { - [SerializeField] - public GameObject _playerPrefab; - // Start is called before the first frame update - void Start() - { - if (_playerPrefab != null) - { - for (int i = 0; i < 100; i++) - { - Instantiate(_playerPrefab, new Vector3(i, 1, 0), Quaternion.identity); - } - } - } - } -} - - diff --git a/Assets/PlayerFactory.cs.meta b/Assets/PlayerFactory.cs.meta deleted file mode 100644 index ea6c715f..00000000 --- a/Assets/PlayerFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d3579ed37837f6c4cb6197c19a9ef8af -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/Images/config_bg-min.jpg b/Assets/Resources/Images/main-bg.jpg similarity index 100% rename from Assets/Resources/Images/config_bg-min.jpg rename to Assets/Resources/Images/main-bg.jpg diff --git a/Assets/Resources/Images/config_bg-min.jpg.meta b/Assets/Resources/Images/main-bg.jpg.meta similarity index 99% rename from Assets/Resources/Images/config_bg-min.jpg.meta rename to Assets/Resources/Images/main-bg.jpg.meta index 6296f34b..ec9db3ca 100644 --- a/Assets/Resources/Images/config_bg-min.jpg.meta +++ b/Assets/Resources/Images/main-bg.jpg.meta @@ -100,5 +100,5 @@ TextureImporter: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 userData: - assetBundleName: + assetBundleName: ab assetBundleVariant: diff --git a/Assets/Scripts/Apis/UserApi.cs b/Assets/Scripts/Apis/UserApi.cs index 5c57da62..ce69b1b8 100644 --- a/Assets/Scripts/Apis/UserApi.cs +++ b/Assets/Scripts/Apis/UserApi.cs @@ -62,7 +62,7 @@ namespace Assets.Scripts.Apis user.ContactPhone = ret.data.ContactPhone; user.ContactAddress = ret.data.ContactAddress; user.Sensitivity = ret.data.Sensitivity; - if (ret.data.ConnectedToStrava != null) + //if (ret.data.ConnectedToStrava != null) { user.ConnectedToStrava = ret.data.ConnectedToStrava; } @@ -224,7 +224,7 @@ namespace Assets.Scripts.Apis return Newtonsoft.Json.JsonConvert.DeserializeObject>(res); } - public async Task> Update(UserResultModel currUser, string filePath = "") + public JsonResult Update(UserResultModel currUser, string filePath = "") { //return await PostAsync>("User/UpdateUserSetting", new { // UID = currUser.Id, diff --git a/Assets/Scripts/Devices/Ant/AntConnector.cs b/Assets/Scripts/Devices/Ant/AntConnector.cs index a7d941df..103ab48c 100644 --- a/Assets/Scripts/Devices/Ant/AntConnector.cs +++ b/Assets/Scripts/Devices/Ant/AntConnector.cs @@ -4,8 +4,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using ANT_Managed_Library; -using Assets.Scripts.UI.Prefab.Device; -using UnityEngine; namespace Assets.Scripts.Devices.Ant { @@ -36,6 +34,9 @@ namespace Assets.Scripts.Devices.Ant private bool IsBackgroundScanning { get; set; } //int searchingDeviceIndex = -1; + /// + /// 可以搜索的设备 + /// private List deviceList = new List(); public bool IsAvailable = false; @@ -43,17 +44,28 @@ namespace Assets.Scripts.Devices.Ant /// 设备号,频道编号 /// public readonly List usedChannels = new List(); - + /// + /// 搜索到的设备 + /// public readonly List discoveredDevices = new List(); private Action _action; private static AntConnector _antConnector; - public static AntConnector Instance(Action action = null) + private Action _log; + + /// + /// + /// + /// 探索到新的设备 + /// + public static AntConnector Instance(Action action = null, + Action log = null) { if (_antConnector == null) { _antConnector = new AntConnector(); _antConnector._action = action; + _antConnector._log = log; } return _antConnector; @@ -226,7 +238,7 @@ namespace Assets.Scripts.Devices.Ant //设备断开连接 else if (antEventId == ANT_ReferenceLibrary.ANTEventID.EVENT_RX_FAIL_GO_TO_SEARCH_0x08) { - Debug.Log(antEventId.ToString() + ", " + string.Join(",", response.messageContents)); + _log?.Invoke(antEventId.ToString() + ", " + string.Join(",", response.messageContents)); var cc1 = usedChannels.Where(d => d.Index == channelIndex).FirstOrDefault(); var dd1 = discoveredDevices.SingleOrDefault(d => d.searchProfile.deviceNumber.ToString() == cc1.DeviceNumber && d.searchProfile.deviceType.ToString() == cc1.DeviceTypeId); @@ -300,24 +312,20 @@ namespace Assets.Scripts.Devices.Ant if (device2 != null) { //ReSearch(); + _action?.Invoke(device2); if (device2.State == DeviceState.Connected) { device2.handleChannelResponse(response); return; } - else if (device2.State == DeviceState.Disconnected) - { + //else if (device2.State == DeviceState.Disconnected) + //{ //var deviceInfo = deviceService.Get(App.CurrentUser.Id, $"{ device2.searchProfile.deviceNumber }:{ device2.searchProfile.deviceType }"); //if (deviceInfo != null && deviceInfo.Paired) //{ // device2.Connect(); - //} - - if(_action != null) - { - _action(device2); - } - } + //} + //} return; } var device1 = deviceList.SingleOrDefault(d => d.searchProfile.deviceType == deviceTypeId); diff --git a/Assets/Scripts/Scenes/LoginController.cs b/Assets/Scripts/Scenes/LoginController.cs index d285809a..52bcc681 100644 --- a/Assets/Scripts/Scenes/LoginController.cs +++ b/Assets/Scripts/Scenes/LoginController.cs @@ -796,9 +796,9 @@ public class LoginController : MonoBehaviour /// /// 去最后一页准备进入主场景 /// - async void goRegEnd() + void goRegEnd() { - if (!await UpdateInfo()) return; + if (!UpdateInfo()) return; if (pageNums == 5) { this.StartScrollPanel(4); @@ -839,7 +839,7 @@ public class LoginController : MonoBehaviour /// 注册页2 修改信息 /// /// - async Task UpdateInfo() + bool UpdateInfo() { if (userResult == null) return false; var _days = signForm.days.GetComponent(); @@ -874,7 +874,7 @@ public class LoginController : MonoBehaviour { userResult.Nickname = userResult.Phone; } - var r = await ConfigHelper.userApi.Update(userResult); + var r = ConfigHelper.userApi.Update(userResult); return r.result; //userResult.Birthday.v } diff --git a/Assets/Scripts/Scenes/MainController.cs b/Assets/Scripts/Scenes/MainController.cs index af7b5539..4bf4fa70 100644 --- a/Assets/Scripts/Scenes/MainController.cs +++ b/Assets/Scripts/Scenes/MainController.cs @@ -19,13 +19,17 @@ public class MainController : MonoBehaviour DeviceCache.Init(PFConstants.DeviceCacheFolder); AntConnector.Instance((device2) => { - //自动连接 - if (DeviceCache.Exist(device2)) + if (device2.State == DeviceState.Disconnected) { - Debug.Log("自动连接" + device2.DeviceNumber); - device2.Connect(); + //Debug.Log($"探索到新的设备{ device2.DeviceNumber }"); + //自动连接 + if (DeviceCache.Exist(device2)) + { + Debug.Log("自动连接" + device2.DeviceNumber); + device2.Connect(); + } } - }); + }, Debug.Log); //Debug.Log(Application.dataPath); diff --git a/Assets/Scripts/UI/Prefab/Device/DeviceView.cs b/Assets/Scripts/UI/Prefab/Device/DeviceView.cs index e051c525..05eb71df 100644 --- a/Assets/Scripts/UI/Prefab/Device/DeviceView.cs +++ b/Assets/Scripts/UI/Prefab/Device/DeviceView.cs @@ -290,22 +290,16 @@ public class DeviceView : MonoBehaviour break; case SensorType.Cadence: return "Cadence Sensor"; - break; case SensorType.HeartRate: return "Heart Rate Monitor"; - break; case SensorType.Power: return "Power Meter"; - break; case SensorType.Speed: break; case SensorType.SpeedCadence: return "Speed Meter"; - break; case SensorType.Trainer: return "Smart Trainer"; - - break; case SensorType.VirtualPower: break; default: diff --git a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs index 11a21303..7815c4ee 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs @@ -293,7 +293,7 @@ public class EditUserController : PFUIPanel //UIManager.ShowAlert("result.errMsg"); } - async void SaveFunc() + void SaveFunc() { var user = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(App.CurrentUser)); user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem)); @@ -324,7 +324,7 @@ public class EditUserController : PFUIPanel user.Contact = mName.Text; user.ContactPhone = mPhone.Text; user.ContactAddress = mAddr.Text; - var result = await userApi.Update(user); + var result = userApi.Update(user); App.isChanged = false; if (result.result == false) { @@ -348,9 +348,9 @@ public class EditUserController : PFUIPanel LoadDataSync(); } - async void ChangeAvatar(string path) + void ChangeAvatar(string path) { - var r = await userApi.Update(App.CurrentUser, path); + var r = userApi.Update(App.CurrentUser, path); App.isChanged = false; if (r.result) {