From 5f0efe3995c2aba59784836586034655f73555e3 Mon Sep 17 00:00:00 2001 From: lishuo Date: Fri, 11 Feb 2022 17:00:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dios=E8=93=9D=E7=89=99?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=8A=9F=E7=8E=87=E4=B8=8D=E5=8F=98=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Plugins/iOS/UnityBluetoothLE.mm | 12 ++++++++++-- Assets/Scripts/Apis/ApiBase.cs | 3 ++- Assets/Scripts/Apis/MapApi.cs | 9 +++++++++ Assets/Scripts/Apis/PfHttpClientHandler.cs | 4 ++++ Assets/Scripts/App.cs | 3 ++- .../Scripts/Scenes/Ride/Scripts/CyclingController.cs | 9 +++++++++ .../Scripts/UI/Prefab/ResultList/LocalRouteItem.cs | 4 ++-- 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Assets/Plugins/iOS/UnityBluetoothLE.mm b/Assets/Plugins/iOS/UnityBluetoothLE.mm index 174fc25e..e794b768 100644 --- a/Assets/Plugins/iOS/UnityBluetoothLE.mm +++ b/Assets/Plugins/iOS/UnityBluetoothLE.mm @@ -748,7 +748,8 @@ extern "C" { { NSLog(@"Central State: Powered Off"); - NSString *message = [NSString stringWithFormat:@"Error~Bluetooth LE Powered Off"]; + //NSString *message = [NSString stringWithFormat:@"Error~Bluetooth LE Powered Off"]; + NSString *message = [NSString stringWithFormat:@"BleStatusChanged~13"]; UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", [message UTF8String] ); } break; @@ -756,7 +757,14 @@ extern "C" { { NSLog(@"Central State: Powered On"); if (_isInitializing) - UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", "Initialized"); + { + UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", "Initialized"); + } + else + { + NSString *message = [NSString stringWithFormat:@"BleStatusChanged~11"]; + UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", [message UTF8String] ); + } _isInitializing = FALSE; } break; diff --git a/Assets/Scripts/Apis/ApiBase.cs b/Assets/Scripts/Apis/ApiBase.cs index 3e6b0b25..ffb6bb4c 100644 --- a/Assets/Scripts/Apis/ApiBase.cs +++ b/Assets/Scripts/Apis/ApiBase.cs @@ -122,7 +122,7 @@ namespace Assets.Scripts.Apis #else defaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion)); #endif - defaultRequestHeaders.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier); + defaultRequestHeaders.Add("deviceUniqueIdentifier", App.DeviceUniqueIdentifier); defaultRequestHeaders.Remove("Language"); defaultRequestHeaders.Add("Language", App.GetLocalLanguage()); } @@ -558,6 +558,7 @@ namespace Assets.Scripts.Apis request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString(); request.Accept = "application/json"; request.Headers.Add("Language", App.GetLocalLanguage()); + request.Headers.Add("deviceUniqueIdentifier", App.DeviceUniqueIdentifier); request.CookieContainer = new CookieContainer(); foreach (Cookie item in cookies) { diff --git a/Assets/Scripts/Apis/MapApi.cs b/Assets/Scripts/Apis/MapApi.cs index e20006dd..7aa68be7 100644 --- a/Assets/Scripts/Apis/MapApi.cs +++ b/Assets/Scripts/Apis/MapApi.cs @@ -95,6 +95,15 @@ namespace Assets.Scripts.Apis { return Get>>($"Map/GetServiceKey").data; } + /// + /// 骑行场景轮询是否有新设备登录 + /// + /// + public async Task GetPing() + { + var res = await GetAsync($"/Map/v1/Ping"); + return res; + } /// /// 获取在线用户的数据 diff --git a/Assets/Scripts/Apis/PfHttpClientHandler.cs b/Assets/Scripts/Apis/PfHttpClientHandler.cs index 184c7513..d1ac154d 100644 --- a/Assets/Scripts/Apis/PfHttpClientHandler.cs +++ b/Assets/Scripts/Apis/PfHttpClientHandler.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using UnityEngine; +using Assets.Scenes.Ride.Scripts; namespace Assets.Scripts.Apis { @@ -62,6 +63,9 @@ namespace Assets.Scripts.Apis } IEnumerator LoadLogin(string msg) { + //删除本地文件 + Helper.DelectDir(PFConstants.MapWorkoutRecordTempFolder); + App.tempRecordData = null; UnityEngine.SceneManagement.SceneManager.LoadScene(0); yield return null; } diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index 50afeec2..4f560fc6 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -20,7 +20,7 @@ public delegate void ChangeLanguageDelegate(); public static class App { - public static string Host = "http://192.168.0.101:5084/"; + public static string Host = "http://192.168.0.102:5082/"; public static string AppVersion = Application.version; @@ -174,6 +174,7 @@ public static class App public static List RouteList = new List(); public static bool _currentPageIsHome = false; public static event EventHandler isHomeChanged; + public static string DeviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier; public static bool currentPageIsHome { get => _currentPageIsHome; diff --git a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs index a283f7f6..59c9c7a5 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs @@ -237,6 +237,7 @@ public class CyclingController : DeviceServiceMonoBase SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; HandleTouchAndInput(); + StartCoroutine(Ping()); //进入比赛 if (competitionId > 0) { @@ -253,6 +254,14 @@ public class CyclingController : DeviceServiceMonoBase } + private IEnumerator Ping() + { + while (true) + { + var result = ConfigHelper.mapApi.GetPing(); + yield return new WaitForSeconds(5); + } + } float timer = 1f; bool clearLock = false; diff --git a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs index f5156e99..939e49dc 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs @@ -79,9 +79,9 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH Name.text = record.RouteName; Time.text = record.StartTime.ToLocalString("HH:mm:ss dd-MM-yyyy"); - RidingTime.text = $"{App.GetLocalString("Riding time")}:{Helper.FormatTicks(record.Ticks)}"; + RidingTime.text = $"{App.GetLocalString("Riding Time")}:{Helper.FormatTicks(record.Ticks)}"; RidingDistance.text = $"{App.GetLocalString("Mileage")}:{record.EndDistance.ToString("#0.00")}KM"; - Device.text = $"{App.GetLocalString("Cycling equipment")}:{record.ManufacturerName}"; + Device.text = $"{App.GetLocalString("Cycling Equipment")}:{record.ManufacturerName}"; } else { From 0c1c2ed3825e3caa3e79db12de48535fa346d580 Mon Sep 17 00:00:00 2001 From: lishuo Date: Mon, 21 Feb 2022 16:16:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=BC=98=E5=8C=96&?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=B0=E5=BD=95=E8=87=AA=E5=8A=A8=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Ride/Scripts/CyclingController.cs | 8 +++- .../UI/Prefab/ResultList/LocalRouteItem.cs | 48 +++++++++++-------- .../Prefab/ResultList/ResultListController.cs | 2 +- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs index 59c9c7a5..1a67ba82 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs @@ -62,6 +62,7 @@ public class CyclingController : DeviceServiceMonoBase #endregion GameObject loadingcanvas; AbstratctLoadingController loadingController; + private async Task Login() { var result = await new UserApi().Login("15261826280", "123456", ""); @@ -73,6 +74,8 @@ public class CyclingController : DeviceServiceMonoBase public GraphChartBase graph { get; set; } private float activeSeconds { get; set; }//移动端用户进入骑行超过2min,界面进入沉浸状态 + public int RankingId; + public string recordId; protected override void Awake() { base.Awake(); @@ -83,6 +86,7 @@ public class CyclingController : DeviceServiceMonoBase } #endif //获取路书信息 + recordId = Guid.NewGuid().ToString(); mapApi = ConfigHelper.mapApi; routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633; competitionId = App.CompetionId; @@ -1196,14 +1200,14 @@ public BaseUIManager singleUIManager; var tempContent = Newtonsoft.Json.JsonConvert.SerializeObject(tempRecordData); System.IO.File.WriteAllText(filePath, tempContent); } - public int RankingId; + public void Save(double totalDistance) { ClearTempFile(); cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime(); isQuit = true; isStart = false; - string recordId = Guid.NewGuid().ToString(); + //string recordId = Guid.NewGuid().ToString(); //var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId); var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId; Helper.CreateDirectoryIfNotExsit(path); diff --git a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs index 939e49dc..4c32b979 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs @@ -88,33 +88,41 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH listFileName.Add(item); } } + DeleteLocalRecord(); } + void DeleteLocalRecord(bool showMessage=false) + { + //自动上传 + try + { + MapInterruptRecordApi service = ConfigHelper.mapInterruptRecordApi; + var result = service.Add(record, listFileName); + //删除文件 + if (result.result) + { + Helper.DelectDir(path); + Destroy(gameObject); + } + if (showMessage) + { + Utils.showToast(gameObject, result.errMsg); + } + + } + catch (Exception e) + { + Utils.showToast(gameObject, e.Message); + } + } void GoUplaod() { UIManager.ShowConfirm("Upload", "Upload the local record?", () => { - try - { - MapInterruptRecordApi service = new MapInterruptRecordApi(); - var result = service.Add(record, listFileName); - //删除文件 - UIManager.CloseConfirm(); - if (result.result) - { - Helper.DelectDir(path); - DestroyImmediate(gameObject); - } - else - { - Utils.showToast(gameObject, result.errMsg); - } - } - catch (Exception e) - { - Utils.showToast(gameObject, e.Message); - } + DeleteLocalRecord(true); + //删除文件 + UIManager.CloseConfirm(); }); } void GoDelete() diff --git a/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs b/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs index 46f54fa2..aeb4cbfb 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/ResultListController.cs @@ -264,7 +264,7 @@ public class ResultListController : PFUIPanel { if (Directory.Exists(item)) { - var d = new DirectoryInfo(item); + //var d = new DirectoryInfo(item); //var createTime = d.CreationTime;//create time //var newTime = createTime.AddSeconds(30D); //if (newTime < DateTime.Now) From ed9dc530937c42199d23ef83d51469dd15e25fd7 Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 23 Feb 2022 18:14:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?loading60%=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E8=A6=81=E5=8A=A0=E8=BD=BD=E5=88=B0=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=93=A6=E7=89=87=E7=9A=84=E9=AB=98=E5=BA=A6=E5=B0=B1?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E9=AA=91=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Ride/Scripts/AbstratctLoadingController.cs | 8 ++------ Assets/Scripts/UI/Control/PFUIText.cs | 2 +- Assets/Scripts/UI/Prefab/MultiTips.cs | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Scenes/Ride/Scripts/AbstratctLoadingController.cs b/Assets/Scripts/Scenes/Ride/Scripts/AbstratctLoadingController.cs index 5ed54937..4dbc3c99 100644 --- a/Assets/Scripts/Scenes/Ride/Scripts/AbstratctLoadingController.cs +++ b/Assets/Scripts/Scenes/Ride/Scripts/AbstratctLoadingController.cs @@ -210,13 +210,9 @@ namespace Assets.Scenes.Ride.Scripts protected void _map_OnInitialized() { var visualizer = _map.MapVisualizer; - visualizer.OnMapVisualizerStateChanged += (s) => + visualizer.OnTileHeightProcessingFinished += (s) => { - if (s == ModuleState.Finished) - { - AddProcess(40); - Debug.Log($"add 40"); - } + AddProcess(40); }; } } diff --git a/Assets/Scripts/UI/Control/PFUIText.cs b/Assets/Scripts/UI/Control/PFUIText.cs index 22c09c53..1c0added 100644 --- a/Assets/Scripts/UI/Control/PFUIText.cs +++ b/Assets/Scripts/UI/Control/PFUIText.cs @@ -12,7 +12,7 @@ namespace Assets.Scripts.UI.Control public class PFUIText : PFUIComponentBase { public string key; - private Text text; + protected Text text; public string Text { diff --git a/Assets/Scripts/UI/Prefab/MultiTips.cs b/Assets/Scripts/UI/Prefab/MultiTips.cs index 81385c15..d3b971e3 100644 --- a/Assets/Scripts/UI/Prefab/MultiTips.cs +++ b/Assets/Scripts/UI/Prefab/MultiTips.cs @@ -7,7 +7,6 @@ using Assets.Scripts; public class MultiTips:PFUIText { - private Text text; private Button button; private string[] tips { get; set; } private int currentIndex = 0;