骑行记录实时保存,异常中断重新连接
This commit is contained in:
parent
cc6730cbc4
commit
de4292d55a
@ -104,6 +104,8 @@ public static class App
|
|||||||
public static string WorkoutsUrl { get; internal set; }
|
public static string WorkoutsUrl { get; internal set; }
|
||||||
public static long delayTime { get; set; }
|
public static long delayTime { get; set; }
|
||||||
public static List<OnlineUser> userList = new List<OnlineUser>();
|
public static List<OnlineUser> userList = new List<OnlineUser>();
|
||||||
|
|
||||||
|
public static TempRecordData tempRecordData { get; set; }
|
||||||
private static string language { get; set; }
|
private static string language { get; set; }
|
||||||
|
|
||||||
public static Dictionary<string, string> LanguageManager { get; set; }
|
public static Dictionary<string, string> LanguageManager { get; set; }
|
||||||
|
|||||||
@ -37,6 +37,19 @@ public static class PFConstants
|
|||||||
return Application.persistentDataPath + "/MapWorkoutRecords/";
|
return Application.persistentDataPath + "/MapWorkoutRecords/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string MapWorkoutRecordTempFolder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Application.persistentDataPath + "/MapWorkoutTempRecords/"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Application.persistentDataPath + "/MapWorkoutTempRecords/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Application.persistentDataPath + "/MapWorkoutTempRecords/";
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备连接缓存在本地的路径
|
/// 设备连接缓存在本地的路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Assets.Scenes.Ride.Scripts;
|
using Assets.Scenes.Ride.Scripts;
|
||||||
|
using Assets.Scenes.Ride.Scripts.Model;
|
||||||
using Assets.Scripts;
|
using Assets.Scripts;
|
||||||
using Assets.Scripts.Devices.Ant;
|
using Assets.Scripts.Devices.Ant;
|
||||||
using Assets.Scripts.Scenes;
|
using Assets.Scripts.Scenes;
|
||||||
@ -9,6 +10,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class MainController : BaseScene
|
public class MainController : BaseScene
|
||||||
@ -109,6 +111,7 @@ public class MainController : BaseScene
|
|||||||
}
|
}
|
||||||
|
|
||||||
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
||||||
|
LastRide();//检查本地异常中断的骑行并弹窗提示继续
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,4 +147,24 @@ public class MainController : BaseScene
|
|||||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||||
App.CurrentUser = result.data;
|
App.CurrentUser = result.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查上次异常中断的骑行
|
||||||
|
/// </summary>
|
||||||
|
private void LastRide()
|
||||||
|
{
|
||||||
|
var tempFileList = System.IO.Directory.GetFiles(PFConstants.MapWorkoutRecordTempFolder);
|
||||||
|
if (tempFileList.Length > 0)
|
||||||
|
{
|
||||||
|
var tempFile = tempFileList[0];
|
||||||
|
var content = System.IO.File.ReadAllText(tempFile);
|
||||||
|
if (!string.IsNullOrEmpty(content))
|
||||||
|
{
|
||||||
|
var tempRecordData = Newtonsoft.Json.JsonConvert.DeserializeObject<TempRecordData>(content);
|
||||||
|
App.tempRecordData = tempRecordData;
|
||||||
|
SceneManager.LoadScene("Ride");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
|||||||
CurrentRouteStartDistance = param.EndDistance == 0 ? 0 : param.EndDistance,
|
CurrentRouteStartDistance = param.EndDistance == 0 ? 0 : param.EndDistance,
|
||||||
//DeviceNumber = DeviceNumber,
|
//DeviceNumber = DeviceNumber,
|
||||||
//AntModelId = antModelId
|
//AntModelId = antModelId
|
||||||
|
selectParam = param,
|
||||||
};
|
};
|
||||||
|
|
||||||
IsRecord = true;
|
IsRecord = true;
|
||||||
|
|||||||
@ -53,6 +53,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
|||||||
CurrentRouteStartDistance = 0,
|
CurrentRouteStartDistance = 0,
|
||||||
//DeviceNumber = DeviceNumber,
|
//DeviceNumber = DeviceNumber,
|
||||||
//AntModelId = antModelId
|
//AntModelId = antModelId
|
||||||
|
selectParam = param
|
||||||
};
|
};
|
||||||
|
|
||||||
if (param != null)
|
if (param != null)
|
||||||
|
|||||||
@ -28,6 +28,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
|||||||
CurrentRoute = route,
|
CurrentRoute = route,
|
||||||
CurrentRouteStartDistance = 0,
|
CurrentRouteStartDistance = 0,
|
||||||
StartTime = UIManager.Now.GetDateTime(),//DateTime.Now
|
StartTime = UIManager.Now.GetDateTime(),//DateTime.Now
|
||||||
|
selectParam = param
|
||||||
};
|
};
|
||||||
|
|
||||||
if (param != null)
|
if (param != null)
|
||||||
|
|||||||
@ -117,6 +117,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
|||||||
public double? OneMinuteMaxAP { get; set; }
|
public double? OneMinuteMaxAP { get; set; }
|
||||||
public double? FiveMinutesMaxAp { get; set; }
|
public double? FiveMinutesMaxAp { get; set; }
|
||||||
|
|
||||||
|
public RouteResultParam selectParam { get; set; }
|
||||||
|
|
||||||
public void SaveWithLocalRecordAysnc(CyclingModel cyclingModel, RouteResultParam selectParam, string imageName,string recordId,string path)
|
public void SaveWithLocalRecordAysnc(CyclingModel cyclingModel, RouteResultParam selectParam, string imageName,string recordId,string path)
|
||||||
{
|
{
|
||||||
Saved = true;
|
Saved = true;
|
||||||
@ -261,4 +263,25 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TempRecordData
|
||||||
|
{
|
||||||
|
public int RouteId { get; set; }
|
||||||
|
public RouteResultParam selectParam { get; set; }
|
||||||
|
public double CurrentRouteStartDistance { get; set; }
|
||||||
|
public DateTime StartTime { get; set; }
|
||||||
|
public double EndDistance { get; set; }
|
||||||
|
public int? ManufacturerId { get; set; }
|
||||||
|
|
||||||
|
public string ManufacturerName { get; set; }
|
||||||
|
|
||||||
|
public string Mode { get; set; }
|
||||||
|
|
||||||
|
public int? AntModelId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 骑行数据
|
||||||
|
/// </summary>
|
||||||
|
public List<TargetData> RiderDatas = new List<TargetData>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -469,6 +469,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
//保存游戏
|
//保存游戏
|
||||||
public virtual void SaveRide(BaseEventData baseEventData)
|
public virtual void SaveRide(BaseEventData baseEventData)
|
||||||
{
|
{
|
||||||
|
mainController.ClearTempFile();
|
||||||
if (playerController?.TotalTicks > 0 && !mainController.isQuit)
|
if (playerController?.TotalTicks > 0 && !mainController.isQuit)
|
||||||
{
|
{
|
||||||
mainController.SetQuit();
|
mainController.SetQuit();
|
||||||
@ -484,6 +485,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
public virtual void CancelQuit(BaseEventData baseEventData)
|
public virtual void CancelQuit(BaseEventData baseEventData)
|
||||||
{
|
{
|
||||||
quitPanel.SetActive(false);
|
quitPanel.SetActive(false);
|
||||||
|
mainController.ClearTempFile();
|
||||||
SceneManager.LoadScene("MainScene");
|
SceneManager.LoadScene("MainScene");
|
||||||
}
|
}
|
||||||
//取消退出
|
//取消退出
|
||||||
|
|||||||
@ -22,6 +22,7 @@ using System.IO;
|
|||||||
using ChartAndGraph;
|
using ChartAndGraph;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class CyclingController : DeviceServiceMonoBase
|
public class CyclingController : DeviceServiceMonoBase
|
||||||
{
|
{
|
||||||
@ -35,13 +36,13 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
|
|
||||||
public Dictionary<int, SeletedPlayerScript> selectPlayerDic { set; get; } = new Dictionary<int, SeletedPlayerScript>();
|
public Dictionary<int, SeletedPlayerScript> selectPlayerDic { set; get; } = new Dictionary<int, SeletedPlayerScript>();
|
||||||
|
|
||||||
public int preticks;
|
public int preticks { get; set; }
|
||||||
|
|
||||||
#region 参数
|
#region 参数
|
||||||
public MapRoute mapRoute { get; set; }//当前路书数据
|
public MapRoute mapRoute { get; set; }//当前路书数据
|
||||||
public MapCompetition competition { get; set; }//当前赛事数据
|
public MapCompetition competition { get; set; }//当前赛事数据
|
||||||
private MapDataModel mapData { get; set; }//当前路书数据
|
private MapDataModel mapData { get; set; }//当前路书数据
|
||||||
private Route route;//当前路书综合数据
|
private Route route { get; set; }//当前路书综合数据
|
||||||
public List<MapRouteRanking> mapRouteRankingList { get; set; }
|
public List<MapRouteRanking> mapRouteRankingList { get; set; }
|
||||||
private Vector2d coordiantes;//当前地图中心
|
private Vector2d coordiantes;//当前地图中心
|
||||||
|
|
||||||
@ -84,6 +85,14 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
|
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
|
||||||
competitionId = App.CompetionId;
|
competitionId = App.CompetionId;
|
||||||
App.CompetionId = 0;//清空比赛参数
|
App.CompetionId = 0;//清空比赛参数
|
||||||
|
|
||||||
|
//处理异常中断的骑行
|
||||||
|
if (App.tempRecordData != null)
|
||||||
|
{
|
||||||
|
selectParamModel = App.tempRecordData.selectParam;
|
||||||
|
competitionId = selectParamModel.CompetitionId ?? 0;
|
||||||
|
routeId = selectParamModel.RouteId ?? 0;
|
||||||
|
}
|
||||||
Resources.UnloadUnusedAssets();
|
Resources.UnloadUnusedAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +227,9 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//loadingController = FindObjectOfType<LoadingController>();
|
//loadingController = FindObjectOfType<LoadingController>();
|
||||||
//
|
//
|
||||||
loadingController.InjectController(this);
|
loadingController.InjectController(this);
|
||||||
|
|
||||||
|
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
|
||||||
|
|
||||||
//进入比赛
|
//进入比赛
|
||||||
if (competitionId > 0)
|
if (competitionId > 0)
|
||||||
{
|
{
|
||||||
@ -234,6 +246,33 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
}
|
}
|
||||||
float timer = 1f;
|
float timer = 1f;
|
||||||
bool clearLock = false;
|
bool clearLock = false;
|
||||||
|
|
||||||
|
private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
|
||||||
|
{
|
||||||
|
ClearTempFile();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 检测是否点击UI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mousePosition"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsPointerOverGameObject(Vector2 mousePosition)
|
||||||
|
{
|
||||||
|
//创建一个点击事件
|
||||||
|
PointerEventData eventData = new PointerEventData(EventSystem.current);
|
||||||
|
eventData.position = mousePosition;
|
||||||
|
List<RaycastResult> raycastResults = new List<RaycastResult>();
|
||||||
|
//向点击位置发射一条射线,检测是否点击UI
|
||||||
|
EventSystem.current.RaycastAll(eventData, raycastResults);
|
||||||
|
if (raycastResults.Count > 0)
|
||||||
|
{
|
||||||
|
return !raycastResults.Where(c => c.gameObject.name == "ToolBarPanel" || c.gameObject.name == "SettingPanel" || c.gameObject.name == "QuitPanel").Any();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -242,13 +281,15 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
if (competitionId == 0 && singleUIManager != null)
|
if (competitionId == 0 && singleUIManager != null)
|
||||||
{
|
{
|
||||||
var mouse = Input.GetMouseButton(0);
|
var mouse = Input.GetMouseButton(0);
|
||||||
if (mouse && clearLock && singleUIManager.clearLock)
|
|
||||||
|
if (mouse && isStart && singleUIManager.clearLock)
|
||||||
|
{
|
||||||
|
if (IsPointerOverGameObject(Input.mousePosition))
|
||||||
{
|
{
|
||||||
clearLock = false;
|
|
||||||
activeSeconds = 0;
|
|
||||||
singleUIManager?.ClearPanel(null);
|
singleUIManager?.ClearPanel(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timer -= Time.deltaTime;
|
timer -= Time.deltaTime;
|
||||||
@ -261,23 +302,41 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
UIManager.SendCompetitionStartMessage("Ride");
|
UIManager.SendCompetitionStartMessage("Ride");
|
||||||
}
|
}
|
||||||
#if UNITY_IOS || UNITY_ANDROID
|
#if UNITY_IOS || UNITY_ANDROID
|
||||||
if (isStart)
|
//if (isStart)
|
||||||
{
|
//{
|
||||||
activeSeconds++;
|
// activeSeconds++;
|
||||||
}
|
//}
|
||||||
if (activeSeconds >= App.autoClearTimes && !clearLock)
|
//if (activeSeconds >= App.autoClearTimes && !clearLock)
|
||||||
{
|
//{
|
||||||
if (competitionId == 0)
|
// if (competitionId == 0)
|
||||||
{
|
// {
|
||||||
clearLock = true;
|
// clearLock = true;
|
||||||
singleUIManager?.ClearPanel(null);
|
// singleUIManager?.ClearPanel(null);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
#endif
|
#endif
|
||||||
timer += 1.0f;
|
timer += 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool isWatch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理中断骑行
|
||||||
|
/// </summary>
|
||||||
|
private void TempFileHandler()
|
||||||
|
{
|
||||||
|
//处理异常中断的骑行
|
||||||
|
if (App.tempRecordData != null)
|
||||||
|
{
|
||||||
|
recorderData.EndDistance = App.tempRecordData.EndDistance;
|
||||||
|
recorderData.StartTime = App.tempRecordData.StartTime;
|
||||||
|
recorderData.RiderDatas = App.tempRecordData.RiderDatas;
|
||||||
|
coordiantes = Along(App.tempRecordData.EndDistance);
|
||||||
|
startTime = App.tempRecordData.StartTime;
|
||||||
|
preticks = recorderData.RiderDatas.Last().Ticks;
|
||||||
|
App.tempRecordData = null;//清空
|
||||||
|
}
|
||||||
|
}
|
||||||
private IEnumerator Init()
|
private IEnumerator Init()
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(1);
|
yield return new WaitForSeconds(1);
|
||||||
@ -289,7 +348,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
MapUDPService.Init();//初始化TCP
|
MapUDPService.Init();//初始化TCP
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
}
|
}
|
||||||
public bool isWatch { get; set; }
|
|
||||||
//初始比赛
|
//初始比赛
|
||||||
private IEnumerator InitRace()
|
private IEnumerator InitRace()
|
||||||
{
|
{
|
||||||
@ -339,12 +398,14 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App.routeResult = null;
|
App.routeResult = null;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
double endDistance = selectParamModel.EndDistance;
|
double endDistance = selectParamModel.EndDistance;
|
||||||
coordiantes = Along(endDistance);
|
coordiantes = Along(endDistance);
|
||||||
var shaowList = mapApi.GetShadowList(App.RouteIdParam, "", 0, 10);
|
var shaowList = mapApi.GetShadowList(routeId, "", 0, 10);
|
||||||
if (shaowList.result)
|
if (shaowList.result)
|
||||||
{
|
{
|
||||||
mapRouteRankingList = shaowList.data.list;
|
mapRouteRankingList = shaowList.data.list;
|
||||||
@ -370,9 +431,8 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//计算上次骑行距离调整地图中心点
|
|
||||||
double endDistance = selectParamModel.EndDistance;
|
double endDistance = selectParamModel.EndDistance;
|
||||||
|
//计算上次骑行距离调整地图中心点
|
||||||
coordiantes = Along(endDistance);
|
coordiantes = Along(endDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,6 +537,8 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//初始化人物位置角度
|
//初始化人物位置角度
|
||||||
private void InitPlayer()
|
private void InitPlayer()
|
||||||
{
|
{
|
||||||
|
TempFileHandler();//处理中断骑行继续骑的逻辑
|
||||||
|
|
||||||
lockView = true;
|
lockView = true;
|
||||||
|
|
||||||
Vector2d lastLatLon = Along(recorderData.EndDistance);
|
Vector2d lastLatLon = Along(recorderData.EndDistance);
|
||||||
@ -497,7 +559,12 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//初始化海拔图头像位置
|
//初始化海拔图头像位置
|
||||||
var index = GetCurrentIndex(recorderData.EndDistance);
|
var index = GetCurrentIndex(recorderData.EndDistance);
|
||||||
InitGraph(index);
|
InitGraph(index);
|
||||||
playerController.CurrentIndex = index;
|
int tick = 0;
|
||||||
|
if (recorderData.RiderDatas.Count > 0)
|
||||||
|
{
|
||||||
|
tick = recorderData.RiderDatas.Last().Ticks;
|
||||||
|
}
|
||||||
|
playerController.Init(index, recorderData.EndDistance, tick);
|
||||||
}
|
}
|
||||||
public void InitGraph(int index)
|
public void InitGraph(int index)
|
||||||
{
|
{
|
||||||
@ -783,7 +850,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//开始骑行
|
//开始骑行
|
||||||
public void SetStart()
|
public void SetStart()
|
||||||
{
|
{
|
||||||
if (!isPause || DateTime.MinValue == startTime)
|
if (!isPause && DateTime.MinValue == startTime)
|
||||||
{
|
{
|
||||||
isStart = true;
|
isStart = true;
|
||||||
startTime = UIManager.Now.GetDateTime();
|
startTime = UIManager.Now.GetDateTime();
|
||||||
@ -850,6 +917,35 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
{
|
{
|
||||||
return mapData;
|
return mapData;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清空临时文件
|
||||||
|
/// </summary>
|
||||||
|
public void ClearTempFile()
|
||||||
|
{
|
||||||
|
Helper.DelectDir(PFConstants.MapWorkoutRecordTempFolder);
|
||||||
|
}
|
||||||
|
TempRecordData tempRecordData { get; set; }
|
||||||
|
public void SaveRealTime()
|
||||||
|
{
|
||||||
|
if (tempRecordData == null)
|
||||||
|
{
|
||||||
|
tempRecordData = new TempRecordData();
|
||||||
|
}
|
||||||
|
RecorderDataModel recorderData = cyclingController.recorderData;
|
||||||
|
tempRecordData.RiderDatas = recorderData.RiderDatas;
|
||||||
|
tempRecordData.selectParam = recorderData.selectParam;
|
||||||
|
tempRecordData.RouteId = mapRoute.Id;
|
||||||
|
tempRecordData.StartTime = startTime;
|
||||||
|
tempRecordData.ManufacturerId = recorderData.ManufacturerId;
|
||||||
|
tempRecordData.ManufacturerName = recorderData.ManufacturerName;
|
||||||
|
tempRecordData.Mode = cyclingModel.ToString();
|
||||||
|
tempRecordData.EndDistance = recorderData.EndDistance;
|
||||||
|
|
||||||
|
var guid = recorderData.ContinueMark;
|
||||||
|
var filePath = PFConstants.MapWorkoutRecordTempFolder + "/" + guid.ToString()+".txt";
|
||||||
|
var tempContent = Newtonsoft.Json.JsonConvert.SerializeObject(tempRecordData);
|
||||||
|
System.IO.File.WriteAllText(filePath, tempContent);
|
||||||
|
}
|
||||||
|
|
||||||
public void Save(double totalDistance)
|
public void Save(double totalDistance)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -61,7 +61,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
weight = App.CurrentUser.Weight;
|
weight = App.CurrentUser.Weight;
|
||||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
power = 143;
|
power = 1430;
|
||||||
#endif
|
#endif
|
||||||
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
|
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
|
||||||
}
|
}
|
||||||
@ -85,6 +85,12 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
distance = 0;
|
distance = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void Init(int index, double distance, int tick)
|
||||||
|
{
|
||||||
|
CurrentIndex = index;
|
||||||
|
totalDistance = distance;
|
||||||
|
ticks = tick;
|
||||||
|
}
|
||||||
protected override void Record()
|
protected override void Record()
|
||||||
{
|
{
|
||||||
if (!stopRecord)
|
if (!stopRecord)
|
||||||
@ -110,6 +116,9 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
recorderData.RiderDatas.Add(targetData);
|
recorderData.RiderDatas.Add(targetData);
|
||||||
//实时计算MaxAp
|
//实时计算MaxAp
|
||||||
//mainController.ComputeMaxAP(Power, ticks);
|
//mainController.ComputeMaxAP(Power, ticks);
|
||||||
|
//实时保存骑行记录
|
||||||
|
|
||||||
|
mainController.SaveRealTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void BeforeRun()
|
protected override void BeforeRun()
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using Assets.Scenes.Ride.Scripts.Model;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using Assets.Scripts;
|
using Assets.Scripts;
|
||||||
using Assets.Scripts.Apis;
|
using Assets.Scripts.Apis;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Assets.Scenes.Ride.Scripts
|
namespace Assets.Scenes.Ride.Scripts
|
||||||
{
|
{
|
||||||
@ -28,22 +29,37 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
//继续骑行如果有伴侣就自动进入伴侣骑行
|
//继续骑行如果有伴侣就自动进入伴侣骑行
|
||||||
public override void ContinueRide()
|
public override void ContinueRide()
|
||||||
{
|
{
|
||||||
|
string mode = string.Empty;
|
||||||
|
List<string> rankingsId = null;
|
||||||
|
//继续骑
|
||||||
if (mainController.routeResult != null)
|
if (mainController.routeResult != null)
|
||||||
|
{
|
||||||
|
mode = mainController.routeResult.Mode;
|
||||||
|
rankingsId = mainController.routeResult.ContinueCyclingParam.RankingsId;
|
||||||
|
}
|
||||||
|
//异常中断骑行继续骑
|
||||||
|
if (App.tempRecordData != null)
|
||||||
|
{
|
||||||
|
mode = App.tempRecordData.Mode;
|
||||||
|
rankingsId = App.tempRecordData.selectParam.RankingsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(mode))
|
||||||
{
|
{
|
||||||
#region 注释伴侣骑行的重骑和继续骑行的逻辑
|
#region 注释伴侣骑行的重骑和继续骑行的逻辑
|
||||||
if (mainController.routeResult.Mode == CyclingModel.Review.ToString())
|
if (mode == CyclingModel.Review.ToString())
|
||||||
{
|
{
|
||||||
mainController.SetCyclingModel(CyclingModel.Review);
|
mainController.SetCyclingModel(CyclingModel.Review);
|
||||||
selectPanel.SetActive(false);
|
selectPanel.SetActive(false);
|
||||||
//查询选中人员的骑行记录
|
//查询选中人员的骑行记录
|
||||||
MapApi mapApi = new MapApi();
|
MapApi mapApi = ConfigHelper.mapApi;
|
||||||
var rankingList = mapApi.GetRecordFileFromServer(mainController.routeResult.ContinueCyclingParam.RankingsId);
|
var rankingList = mapApi.GetRecordFileFromServer(rankingsId);
|
||||||
var reviewFactory = reviewPanel.transform.GetComponent<ReviewFactory>();
|
var reviewFactory = reviewPanel.transform.GetComponent<ReviewFactory>();
|
||||||
reviewFactory.Refresh();
|
reviewFactory.Refresh();
|
||||||
reviewFactory.SetReview(rankingList);
|
reviewFactory.SetReview(rankingList);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
if (mainController.routeResult.Mode == CyclingModel.Single.ToString())
|
if (mode == CyclingModel.Single.ToString())
|
||||||
{
|
{
|
||||||
mainController.SetCyclingModel(CyclingModel.Single);
|
mainController.SetCyclingModel(CyclingModel.Single);
|
||||||
reviewPanel.SetActive(false);
|
reviewPanel.SetActive(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user