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 bb140829..ac75f51b 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -177,6 +177,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/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/Scenes/Ride/Scripts/CyclingController.cs b/Assets/Scripts/Scenes/Ride/Scripts/CyclingController.cs index a43cd9c6..0f65b620 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; @@ -237,6 +241,7 @@ public class CyclingController : DeviceServiceMonoBase SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; HandleTouchAndInput(); + StartCoroutine(Ping()); //进入比赛 if (competitionId > 0) { @@ -253,6 +258,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; @@ -1187,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/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; diff --git a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs index f5156e99..4c32b979 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/LocalRouteItem.cs @@ -79,42 +79,50 @@ 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 { 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)