From fccc830f713a53df05be5a48cb34c0330babee8b Mon Sep 17 00:00:00 2001 From: lishuo Date: Fri, 8 Jul 2022 18:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=89=8D=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Devices/Ble/Characteristic/C2RowerData.cs | 4 ++- Assets/Scripts/Scenes/Ride/Model/OutModel.cs | 2 +- .../Scenes/Ride/Scripts/AbstractPlayer.cs | 2 +- .../Ride/Scripts/DeviceServiceMonoBase.cs | 4 ++- .../Scenes/Ride/Scripts/NearByItemScript.cs | 1 + .../Scenes/Ride/Scripts/ResultPanelScript.cs | 7 ++-- Assets/Scripts/UI/Prefab/Device/DeviceView.cs | 32 +------------------ .../Scripts/UI/Prefab/Login/QuickLoginUser.cs | 1 - 8 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Assets/Scripts/Devices/Ble/Characteristic/C2RowerData.cs b/Assets/Scripts/Devices/Ble/Characteristic/C2RowerData.cs index a9dbde56..b9e48597 100644 --- a/Assets/Scripts/Devices/Ble/Characteristic/C2RowerData.cs +++ b/Assets/Scripts/Devices/Ble/Characteristic/C2RowerData.cs @@ -62,7 +62,9 @@ namespace Assets.Scripts.Devices.Ble.Characteristic public static RowerTaskPanel.RowerType rowerType { get; private set; } public void HandleAttributeReceived(byte[] data) { - + if ((App.IsRowerMode?? false)) { + return; + } if (data[0] == 0x35) { PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true); diff --git a/Assets/Scripts/Scenes/Ride/Model/OutModel.cs b/Assets/Scripts/Scenes/Ride/Model/OutModel.cs index 45ebc6e8..07f41419 100644 --- a/Assets/Scripts/Scenes/Ride/Model/OutModel.cs +++ b/Assets/Scripts/Scenes/Ride/Model/OutModel.cs @@ -598,7 +598,7 @@ namespace Assets.Scenes.Ride.Scripts.Model try { DateTime ? startTime = null;// string.IsNullOrEmpty(list[16]) ? null : Convert.ToDateTime(list[16], CultureInfo.InvariantCulture); - if (!string.IsNullOrEmpty(list[16])) + if (list.Length>= 16 && !string.IsNullOrEmpty(list[16])) { startTime = Convert.ToDateTime(list[16], CultureInfo.InvariantCulture); } diff --git a/Assets/Scripts/Scenes/Ride/Scripts/AbstractPlayer.cs b/Assets/Scripts/Scenes/Ride/Scripts/AbstractPlayer.cs index bba32e95..d16e0b2a 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/AbstractPlayer.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/AbstractPlayer.cs @@ -296,7 +296,7 @@ namespace Assets.Scenes.Ride.Scripts currentSlope = currentSlope > 0? Math.Min(PreSlope, 15) : Math.Max(PreSlope, -15); CurrentDistance = pointList[CurrentIndex].Distance; //计算下一个海拔和坡度&当前区间距离 - nextSlope = pointList[nextIndex].Grade; + nextSlope = pointList[nextIndex].Grade > 0 ? Math.Min(pointList[nextIndex].Grade, 15) : Math.Max(pointList[nextIndex].Grade, -15); nextSlopeDistance = sumDistance - totalDistance * 1000; NextSlopeTotalDistance = pointList[nextIndex].Distance; currentSlopeDistance = (totalDistance * 1000 - (sumDistance - pointList[index].Distance));// CurrentDistance-( totalDistance * 1000 - (sumDistance - pointList[index].Distance)); diff --git a/Assets/Scripts/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs b/Assets/Scripts/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs index b8240cb0..30647738 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs @@ -13,11 +13,13 @@ namespace Assets.Scenes.Ride.Scripts { public class DeviceServiceMonoBase: BaseScene { + double pregrade = 0; public void TrackResistance(double grade) { var device = (CurrentTrainer as ITrainerDevice); - if (device != null) + if (device != null && grade != pregrade) { + pregrade = grade; device.SetTrackResistance(grade); } } diff --git a/Assets/Scripts/Scenes/Ride/Scripts/NearByItemScript.cs b/Assets/Scripts/Scenes/Ride/Scripts/NearByItemScript.cs index a1af2b00..00f306cc 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/NearByItemScript.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/NearByItemScript.cs @@ -53,6 +53,7 @@ namespace Assets.Scenes.Ride.Scripts { if (!_headUrl.Equals(url)) { + _headUrl = url; //if (App.TextureCache.ContainsKey(url)) //{ // Head.texture = App.TextureCache[url]; diff --git a/Assets/Scripts/Scenes/Ride/Scripts/ResultPanelScript.cs b/Assets/Scripts/Scenes/Ride/Scripts/ResultPanelScript.cs index 80af75b2..07f7c740 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/ResultPanelScript.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/ResultPanelScript.cs @@ -111,10 +111,11 @@ namespace Assets.Scenes.Ride.Scripts private async void shareToWx(BaseEventData b) { UIManager.Instance.StartCoroutine(ShowLoading()); - var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId); + //var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId); if (App.weChatController.IsWeChatAppInstalled()) { - App.weChatController.ShareImageToWX(0, res.data, Resources.Load("Images/pf").texture.EncodeToJPG()); + App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.NickName, "By " + App.CurrentUser.Nickname, null); + //App.weChatController.ShareImageToWX(0, res.data, Resources.Load("Images/pf").texture.EncodeToJPG()); } else { @@ -124,7 +125,7 @@ namespace Assets.Scenes.Ride.Scripts private IEnumerator ShowLoading() { - Utils.showToast(null, "首次分享图片会消耗一些时间,请耐心等待", type: 1); + //Utils.showToast(null, "首次分享图片会消耗一些时间,请耐心等待", type: 1); yield return null; } private async void shareToWxGp(BaseEventData b) diff --git a/Assets/Scripts/UI/Prefab/Device/DeviceView.cs b/Assets/Scripts/UI/Prefab/Device/DeviceView.cs index 2ad5311d..5e5ed22a 100644 --- a/Assets/Scripts/UI/Prefab/Device/DeviceView.cs +++ b/Assets/Scripts/UI/Prefab/Device/DeviceView.cs @@ -151,43 +151,13 @@ public class DeviceView : MonoBehaviour { return; } - var device = GetDevice(); - if (device != null && device.State == DeviceState.Connected) - { - UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () => - { - device.Disconnect(false); - DeviceCache.Remove(device); - UIManager.CloseConfirm(); - }, 2, () => { - UIManager.CloseConfirm(); - }); - } - else - { - mDisconnectButtonClick(); - } + mDisconnectButtonClick(); })); #endif UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction(e => { -#if UNITY_IOS || UNITY_ANDROID - var device = GetDevice(); - if (device != null && device.State == DeviceState.Connected) - { - UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () => - { - device.Disconnect(false); - DeviceCache.Remove(device); - UIManager.CloseConfirm(); - }, 2, () => { - UIManager.CloseConfirm(); - }); - } -#else mDisconnectButtonClick(); -#endif })); } diff --git a/Assets/Scripts/UI/Prefab/Login/QuickLoginUser.cs b/Assets/Scripts/UI/Prefab/Login/QuickLoginUser.cs index 256ab9aa..e3413c31 100644 --- a/Assets/Scripts/UI/Prefab/Login/QuickLoginUser.cs +++ b/Assets/Scripts/UI/Prefab/Login/QuickLoginUser.cs @@ -73,7 +73,6 @@ public class QuickLoginUser : MonoBehaviour private IEnumerator Loading() { yield return null; - DontDestroyOnLoad(loadingPanel); Utils.showLoadingExtension(loadingPanel); }