骑行记录实时保存,异常中断重新连接
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 long delayTime { get; set; }
|
||||
public static List<OnlineUser> userList = new List<OnlineUser>();
|
||||
|
||||
public static TempRecordData tempRecordData { get; set; }
|
||||
private static string language { get; set; }
|
||||
|
||||
public static Dictionary<string, string> LanguageManager { get; set; }
|
||||
|
||||
@ -37,6 +37,19 @@ public static class PFConstants
|
||||
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>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Scenes;
|
||||
@ -9,6 +10,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainController : BaseScene
|
||||
@ -109,6 +111,7 @@ public class MainController : BaseScene
|
||||
}
|
||||
|
||||
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
||||
LastRide();//检查本地异常中断的骑行并弹窗提示继续
|
||||
}
|
||||
|
||||
|
||||
@ -144,4 +147,24 @@ public class MainController : BaseScene
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
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,
|
||||
//DeviceNumber = DeviceNumber,
|
||||
//AntModelId = antModelId
|
||||
selectParam = param,
|
||||
};
|
||||
|
||||
IsRecord = true;
|
||||
|
||||
@ -53,6 +53,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
CurrentRouteStartDistance = 0,
|
||||
//DeviceNumber = DeviceNumber,
|
||||
//AntModelId = antModelId
|
||||
selectParam = param
|
||||
};
|
||||
|
||||
if (param != null)
|
||||
|
||||
@ -28,6 +28,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
CurrentRoute = route,
|
||||
CurrentRouteStartDistance = 0,
|
||||
StartTime = UIManager.Now.GetDateTime(),//DateTime.Now
|
||||
selectParam = param
|
||||
};
|
||||
|
||||
if (param != null)
|
||||
|
||||
@ -117,6 +117,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
public double? OneMinuteMaxAP { 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
mainController.ClearTempFile();
|
||||
if (playerController?.TotalTicks > 0 && !mainController.isQuit)
|
||||
{
|
||||
mainController.SetQuit();
|
||||
@ -484,6 +485,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public virtual void CancelQuit(BaseEventData baseEventData)
|
||||
{
|
||||
quitPanel.SetActive(false);
|
||||
mainController.ClearTempFile();
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
//取消退出
|
||||
|
||||
@ -22,6 +22,7 @@ using System.IO;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
@ -35,13 +36,13 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
public Dictionary<int, SeletedPlayerScript> selectPlayerDic { set; get; } = new Dictionary<int, SeletedPlayerScript>();
|
||||
|
||||
public int preticks;
|
||||
public int preticks { get; set; }
|
||||
|
||||
#region 参数
|
||||
public MapRoute mapRoute { get; set; }//当前路书数据
|
||||
public MapCompetition competition { get; set; }//当前赛事数据
|
||||
private MapDataModel mapData { get; set; }//当前路书数据
|
||||
private Route route;//当前路书综合数据
|
||||
private Route route { get; set; }//当前路书综合数据
|
||||
public List<MapRouteRanking> mapRouteRankingList { get; set; }
|
||||
private Vector2d coordiantes;//当前地图中心
|
||||
|
||||
@ -73,17 +74,25 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
if (App.CurrentUser == null)
|
||||
{
|
||||
Login();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
//获取路书信息
|
||||
mapApi = ConfigHelper.mapApi;
|
||||
routeId = App.RouteIdParam > 0? App.RouteIdParam : 2633;
|
||||
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
|
||||
competitionId = App.CompetionId;
|
||||
App.CompetionId = 0;//清空比赛参数
|
||||
|
||||
//处理异常中断的骑行
|
||||
if (App.tempRecordData != null)
|
||||
{
|
||||
selectParamModel = App.tempRecordData.selectParam;
|
||||
competitionId = selectParamModel.CompetitionId ?? 0;
|
||||
routeId = selectParamModel.RouteId ?? 0;
|
||||
}
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
@ -130,7 +139,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
return Graph4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Material GetMaterial1()
|
||||
{
|
||||
@ -218,6 +227,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//loadingController = FindObjectOfType<LoadingController>();
|
||||
//
|
||||
loadingController.InjectController(this);
|
||||
|
||||
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
|
||||
|
||||
//进入比赛
|
||||
if (competitionId > 0)
|
||||
{
|
||||
@ -234,6 +246,33 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
float timer = 1f;
|
||||
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()
|
||||
{
|
||||
base.Update();
|
||||
@ -242,11 +281,13 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
if (competitionId == 0 && singleUIManager != null)
|
||||
{
|
||||
var mouse = Input.GetMouseButton(0);
|
||||
if (mouse && clearLock && singleUIManager.clearLock)
|
||||
|
||||
if (mouse && isStart && singleUIManager.clearLock)
|
||||
{
|
||||
clearLock = false;
|
||||
activeSeconds = 0;
|
||||
singleUIManager?.ClearPanel(null);
|
||||
if (IsPointerOverGameObject(Input.mousePosition))
|
||||
{
|
||||
singleUIManager?.ClearPanel(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -261,23 +302,41 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
UIManager.SendCompetitionStartMessage("Ride");
|
||||
}
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
if (isStart)
|
||||
{
|
||||
activeSeconds++;
|
||||
}
|
||||
if (activeSeconds >= App.autoClearTimes && !clearLock)
|
||||
{
|
||||
if (competitionId == 0)
|
||||
{
|
||||
clearLock = true;
|
||||
singleUIManager?.ClearPanel(null);
|
||||
}
|
||||
}
|
||||
//if (isStart)
|
||||
//{
|
||||
// activeSeconds++;
|
||||
//}
|
||||
//if (activeSeconds >= App.autoClearTimes && !clearLock)
|
||||
//{
|
||||
// if (competitionId == 0)
|
||||
// {
|
||||
// clearLock = true;
|
||||
// singleUIManager?.ClearPanel(null);
|
||||
// }
|
||||
//}
|
||||
#endif
|
||||
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()
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
@ -289,7 +348,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
MapUDPService.Init();//初始化TCP
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
public bool isWatch { get; set; }
|
||||
|
||||
//初始比赛
|
||||
private IEnumerator InitRace()
|
||||
{
|
||||
@ -315,15 +374,15 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
||||
route = new Route(mapData, mapRoute);
|
||||
loadingController.AddProcess(10);
|
||||
#region 其他场景传参处理
|
||||
#region 其他场景传参处理
|
||||
//骑行结果
|
||||
if (App.routeResult != null )
|
||||
if (App.routeResult != null)
|
||||
{
|
||||
routeResult = App.routeResult;
|
||||
selectParamModel = App.routeResult.ContinueCyclingParam;//继续骑行
|
||||
preticks = App.routeResult.Ticks;
|
||||
}
|
||||
|
||||
|
||||
if (selectParamModel == null)
|
||||
{
|
||||
selectParamModel = new RouteResultParam
|
||||
@ -339,12 +398,14 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
App.routeResult = null;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
double endDistance = selectParamModel.EndDistance;
|
||||
coordiantes = Along(endDistance);
|
||||
var shaowList = mapApi.GetShadowList(App.RouteIdParam, "", 0, 10);
|
||||
coordiantes = Along(endDistance);
|
||||
var shaowList = mapApi.GetShadowList(routeId, "", 0, 10);
|
||||
if (shaowList.result)
|
||||
{
|
||||
mapRouteRankingList = shaowList.data.list;
|
||||
@ -356,7 +417,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
||||
route = new Route(mapData, mapRoute);
|
||||
loadingController.AddProcess(10);
|
||||
#region 其他场景传参处理
|
||||
#region 其他场景传参处理
|
||||
selectParamModel = new RouteResultParam
|
||||
{
|
||||
CompetitionId = competitionId,
|
||||
@ -369,10 +430,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
RouteId = App.RouteIdParam
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
//计算上次骑行距离调整地图中心点
|
||||
#endregion
|
||||
double endDistance = selectParamModel.EndDistance;
|
||||
//计算上次骑行距离调整地图中心点
|
||||
coordiantes = Along(endDistance);
|
||||
}
|
||||
|
||||
@ -400,7 +460,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
map.gameObject.SetActive(true);
|
||||
player.SetActive(true);
|
||||
UIObject.SetActive(true);
|
||||
singleUIManager = UIObject.AddComponent<CompetitionUIManager>();
|
||||
singleUIManager = UIObject.AddComponent<CompetitionUIManager>();
|
||||
//miniMap.SetActive(true);
|
||||
map.OnTileFinished += Map_OnTileFinished;
|
||||
mapPos = map.transform.position;
|
||||
@ -444,7 +504,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
public void ChangeCurrentPlayer(int userId)
|
||||
{
|
||||
var coll = FindObjectsOfType<AbstractPlayer>();
|
||||
var selectedPlayer =coll.Where(c => c.UserId == userId).FirstOrDefault();
|
||||
var selectedPlayer = coll.Where(c => c.UserId == userId).FirstOrDefault();
|
||||
if (selectedPlayer != null)
|
||||
{
|
||||
currentPlayer = selectedPlayer;
|
||||
@ -459,7 +519,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
ss.transform.localScale = Is3dView ? MAX_SIZE : MIN_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var unselectedPlayers = coll.Where(c => c.UserId != userId).ToList();
|
||||
foreach (var item in unselectedPlayers)
|
||||
{
|
||||
@ -477,6 +537,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//初始化人物位置角度
|
||||
private void InitPlayer()
|
||||
{
|
||||
TempFileHandler();//处理中断骑行继续骑的逻辑
|
||||
|
||||
lockView = true;
|
||||
|
||||
Vector2d lastLatLon = Along(recorderData.EndDistance);
|
||||
@ -497,7 +559,12 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//初始化海拔图头像位置
|
||||
var index = GetCurrentIndex(recorderData.EndDistance);
|
||||
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)
|
||||
{
|
||||
@ -517,15 +584,15 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = true;
|
||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled = true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = false;
|
||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled = false;
|
||||
Utils.showToast(null, "Please connect the device!", duration: int.MaxValue, isLowest: true
|
||||
, stopFunc: () => isWatch || CheckAnt() || transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy
|
||||
, endCallback: () =>
|
||||
, endCallback: () =>
|
||||
{
|
||||
if (!transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy)
|
||||
if (!transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy)
|
||||
{
|
||||
UIManager.Instance.DevicePanel.Close();
|
||||
singleUIManager.StartRide();
|
||||
@ -538,10 +605,10 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
public void GoContinueRide()
|
||||
{
|
||||
singleUIManager.ContinueRide();
|
||||
singleUIManager.ContinueRide();
|
||||
}
|
||||
|
||||
#region TCP相关
|
||||
#region TCP相关
|
||||
|
||||
public void TcpHandler()
|
||||
{
|
||||
@ -585,8 +652,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
otherList.Add(onlinePlayerController);
|
||||
|
||||
onlinePlayerController.UserId = onlineRider.UserId;
|
||||
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude),index);
|
||||
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index);
|
||||
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
||||
if (competitionId == 0)
|
||||
{
|
||||
@ -596,7 +663,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
miniController.SetController(onlinePlayerController);
|
||||
}
|
||||
//发消息xx进入路书
|
||||
if(messageIndex > 0)
|
||||
if (messageIndex > 0)
|
||||
EventQueueSystem.QueueEvent(new JoinMessageEvent(onlineRider.NickName, onlineRider.WxHeadImg));
|
||||
|
||||
}
|
||||
@ -617,8 +684,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
//显示观察者头像
|
||||
}
|
||||
if(onlineRiders.Count > 0)
|
||||
messageIndex++;
|
||||
if (onlineRiders.Count > 0)
|
||||
messageIndex++;
|
||||
//移除
|
||||
foreach (var item in currentOnlineUserList)
|
||||
{
|
||||
@ -634,9 +701,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
item.IsShowInfo = false;
|
||||
}
|
||||
var frontPlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance < 0.25 && c.TotalDistance - currentPlayer.TotalDistance >= 0 && c.UserId != currentPlayer.UserId).OrderBy(c=>c.TotalDistance).FirstOrDefault();
|
||||
var bakePlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance >-0.25 && c.TotalDistance - currentPlayer.TotalDistance < 0 && c.UserId != currentPlayer.UserId).OrderByDescending(c=>c.TotalDistance).FirstOrDefault();
|
||||
if(frontPlayer != null)
|
||||
var frontPlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance < 0.25 && c.TotalDistance - currentPlayer.TotalDistance >= 0 && c.UserId != currentPlayer.UserId).OrderBy(c => c.TotalDistance).FirstOrDefault();
|
||||
var bakePlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance > -0.25 && c.TotalDistance - currentPlayer.TotalDistance < 0 && c.UserId != currentPlayer.UserId).OrderByDescending(c => c.TotalDistance).FirstOrDefault();
|
||||
if (frontPlayer != null)
|
||||
frontPlayer.IsShowInfo = true;
|
||||
if (bakePlayer != null)
|
||||
bakePlayer.IsShowInfo = true;
|
||||
@ -647,7 +714,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
return MapUDPService.GetCompetitionWatchers(competitionId);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public void SetUIManager(PFUIPanel mainPanel, PFUIPanel model)
|
||||
{
|
||||
@ -684,7 +751,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
return UIManager.Instance.loginRegOptions.GetCountryImageByName(name);
|
||||
}
|
||||
|
||||
#region 视角切换
|
||||
#region 视角切换
|
||||
|
||||
public AbstractMap map3d;
|
||||
public bool Is3dView;
|
||||
@ -744,9 +811,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
private bool lockView = false;
|
||||
private void Map_OnTileFinished(Mapbox.Unity.MeshGeneration.Data.UnityTile obj)
|
||||
{
|
||||
if (!lockView)
|
||||
if (!lockView)
|
||||
{
|
||||
|
||||
|
||||
var playerController = player.GetComponent<PlayerController>();
|
||||
player.transform.localScale = new Vector3(3f, 3f, 3f);
|
||||
var locations = playerController.Currentlatlong == null ? playerController.Currentlatlong : new Vector2d(mapData.List[0].Point[0], mapData.List[0].Point[1]);
|
||||
@ -755,7 +822,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
if (recorderData != null)
|
||||
{
|
||||
var lastLatLon = Along(recorderData.EndDistance);
|
||||
var nextLatLon = Along(recorderData.EndDistance+0.1);
|
||||
var nextLatLon = Along(recorderData.EndDistance + 0.1);
|
||||
player.transform.position = map.GeoToWorldPosition(lastLatLon);
|
||||
//设定人物方向
|
||||
var s = map.GeoToWorldPosition(lastLatLon);
|
||||
@ -776,14 +843,14 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 游戏状态控制
|
||||
#region 游戏状态控制
|
||||
Stopwatch sw { get; set; }
|
||||
//开始骑行
|
||||
public void SetStart()
|
||||
{
|
||||
if (!isPause || DateTime.MinValue == startTime)
|
||||
if (!isPause && DateTime.MinValue == startTime)
|
||||
{
|
||||
isStart = true;
|
||||
startTime = UIManager.Now.GetDateTime();
|
||||
@ -823,9 +890,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
isStart = false;
|
||||
isQuit = true;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 数据处理
|
||||
#region 数据处理
|
||||
/// <summary>
|
||||
/// 当前骑行数据的记录器
|
||||
/// </summary>
|
||||
@ -836,7 +903,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
return cyclingController?.recorderData;
|
||||
}
|
||||
}
|
||||
public Route GetRoute()
|
||||
public Route GetRoute()
|
||||
{
|
||||
return route;
|
||||
}
|
||||
@ -850,6 +917,35 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
weight = App.CurrentUser.Weight;
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
#if UNITY_EDITOR
|
||||
power = 143;
|
||||
power = 1430;
|
||||
#endif
|
||||
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
|
||||
}
|
||||
@ -85,7 +85,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
distance = 0;
|
||||
}
|
||||
}
|
||||
protected override void Record()
|
||||
public void Init(int index, double distance, int tick)
|
||||
{
|
||||
CurrentIndex = index;
|
||||
totalDistance = distance;
|
||||
ticks = tick;
|
||||
}
|
||||
protected override void Record()
|
||||
{
|
||||
if (!stopRecord)
|
||||
{
|
||||
@ -110,6 +116,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
recorderData.RiderDatas.Add(targetData);
|
||||
//实时计算MaxAp
|
||||
//mainController.ComputeMaxAP(Power, ticks);
|
||||
//实时保存骑行记录
|
||||
|
||||
mainController.SaveRealTime();
|
||||
}
|
||||
}
|
||||
protected override void BeforeRun()
|
||||
|
||||
@ -4,6 +4,7 @@ using Assets.Scenes.Ride.Scripts.Model;
|
||||
using UnityEngine.EventSystems;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@ -28,22 +29,37 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//继续骑行如果有伴侣就自动进入伴侣骑行
|
||||
public override void ContinueRide()
|
||||
{
|
||||
string mode = string.Empty;
|
||||
List<string> rankingsId = 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 注释伴侣骑行的重骑和继续骑行的逻辑
|
||||
if (mainController.routeResult.Mode == CyclingModel.Review.ToString())
|
||||
if (mode == CyclingModel.Review.ToString())
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
//查询选中人员的骑行记录
|
||||
MapApi mapApi = new MapApi();
|
||||
var rankingList = mapApi.GetRecordFileFromServer(mainController.routeResult.ContinueCyclingParam.RankingsId);
|
||||
MapApi mapApi = ConfigHelper.mapApi;
|
||||
var rankingList = mapApi.GetRecordFileFromServer(rankingsId);
|
||||
var reviewFactory = reviewPanel.transform.GetComponent<ReviewFactory>();
|
||||
reviewFactory.Refresh();
|
||||
reviewFactory.SetReview(rankingList);
|
||||
}
|
||||
#endregion
|
||||
if (mainController.routeResult.Mode == CyclingModel.Single.ToString())
|
||||
if (mode == CyclingModel.Single.ToString())
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.Single);
|
||||
reviewPanel.SetActive(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user