解决累计爬升不准问题&本地文件记录样式

This commit is contained in:
lishuo committed 2021-09-09 16:29:22 +08:00
1 parent 8a4657c11c
commit ee1114e2cf
45 files changed
+6924 -405

No files matched your search

+9 -7
View File
@@ -495,7 +495,8 @@ public class LoginController : MonoBehaviour
//Task.Run(async () =>
//{
//});
//});
#if !(UNITY_ANDROID || UNITY_IOS)
var r = await ConfigHelper.userApi.GetNotify();
if (r.result)
{
@@ -516,6 +517,7 @@ public class LoginController : MonoBehaviour
PlayerPrefs.SetInt("notifyId", r.data.Value<int>("Id"));
}
}
#endif
GetRotateImage();
}
@@ -650,7 +652,7 @@ public class LoginController : MonoBehaviour
{
}
#region 倒计时获取验证码
#region 倒计时获取验证码
int time = 0;
float timer = 0f;
bool startCaptcha = false;
@@ -689,7 +691,7 @@ public class LoginController : MonoBehaviour
Utils.SetValidate(signFormDict, r.errFieldMsg);
}
}
#endregion
#endregion
void CaptchaTimerTick()
{
@@ -1257,7 +1259,7 @@ public class LoginController : MonoBehaviour
}
//float adjTime = 0;
//bool startJs = false;
#region 主页面滑动逻辑
#region 主页面滑动逻辑
private int tmpImdex = 0;
private int scrollPanelIndex = 2;
//private float scrollValue = 0.5f;
@@ -1296,9 +1298,9 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#endregion
#region 注册页面滑动逻辑
#region 注册页面滑动逻辑
private bool startScrollSign = false;
private int scrollSignIndex = 0;
@@ -1366,5 +1368,5 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#endregion
}
@@ -88,6 +88,9 @@ namespace Assets.Scenes.Ride.Scripts
private void CountDown()
{
raceViewBtn.SetActive(mainController.isWatch);
#if UNITY_IOS || UNITY_ANDROID
raceViewBtn.SetActive(false);
#endif
miniMap.SetActive(false); //隐藏小地图
//viewButton.gameObject.SetActive(false);//隐藏切换视角
headPanel.SetActive(!mainController.isWatch); //隐藏海拔图观察者的头像
@@ -34,7 +34,7 @@ namespace Assets.Scenes.Ride.Scripts
{
var count = competitionModel.StartCountdown();
//比赛开始前倒计时
if (count > 0 && !competitionModel.recorderData.Saved)
if (count >= 0 && !competitionModel.recorderData.Saved)
{
ShowCountDown(count, "Get Ready!");//显示倒计时面板信息
Timer.gameObject.SetActive(false);
@@ -372,7 +372,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
public int StartCountdown()
{
if (CanStart()) return 0;
if (CanStart()) return -1;
return (int)Math.Floor((mapCompetition.StartTime.ToLocalTime() - Now).TotalSeconds);
}
@@ -28,6 +28,7 @@ namespace Assets.Scenes.Ride.Scripts
protected AbstractMap map;
//AbstractMap map;
public bool IsShowInfo { get; set; }
protected int StartIndex { get; set; }
#region 动画控制参数
public Vector3 nextPos;
protected Vector3 prePos = Vector3.zero;
@@ -89,6 +90,7 @@ namespace Assets.Scenes.Ride.Scripts
#endregion
void Start()
{
Init();
//StartCoroutine("TestExcute");
}
@@ -109,6 +111,7 @@ namespace Assets.Scenes.Ride.Scripts
protected BaseCycling cyclingExcutor;
protected virtual void Init()
{
StartIndex = 0;
characterAnimator = GetComponentInChildren<Animator>();
mainController = transform.parent.GetComponent<CyclingController>();
map = transform.parent.Find("Map").GetComponent<AbstractMap>();
@@ -121,6 +124,7 @@ namespace Assets.Scenes.Ride.Scripts
chartDataSourceScript = mainController.chartDataSourceScript;
graph = mainController.graph;
cyclingExcutor = mainController.cyclingController;
ComputeNextSlope();//计算下一个坡度相关数据
}
IEnumerator TestExcute()
{
@@ -155,7 +159,7 @@ namespace Assets.Scenes.Ride.Scripts
{
if (mapData == null)
return;
ComputeNextSlope();//计算下一个坡度相关数据
//ComputeNextSlope();//计算下一个坡度相关数据
MoveGraphHead();//移动海拔图头像
//人物动画控制
if (characterAnimator != null)
@@ -185,29 +189,22 @@ namespace Assets.Scenes.Ride.Scripts
ticks++;
}
Compute();//接受蓝牙设备数据计算
//计算累计爬升
if (CurrentIndex > 0)
{
totalClimb = 0;
for (int i = 1; i <= CurrentIndex; i++)
{
var diff = mapData.List[i].Elevation - mapData.List[i - 1].Elevation;
if (diff > 0)
{
totalClimb += diff;
}
}
}
if (totalDistance >= mapData.TotalDistance)
{
distance = totalDistance - mapData.TotalDistance;
totalDistance = mapData.TotalDistance;
}
ComputeNextSlope();//计算下一个坡度相关数据和累计爬升
Record();
//数据处理
if (totalDistance >= mapData.TotalDistance)
{
stopRecord = true;
StartCoroutine("LateUpload");
}
//数据处理
nextPos = map.GeoToWorldPosition(currentlatlong);//下一个点
nextPos.y += 1.35f;//提高y轴让人物站在地图上面
prePos = transform.localPosition;//当前点
@@ -241,6 +238,12 @@ namespace Assets.Scenes.Ride.Scripts
protected virtual void Compute()
{
}
protected virtual void Record()
{
}
//当前用户调用来上传骑行记录
public virtual void Upload()
@@ -300,6 +303,19 @@ namespace Assets.Scenes.Ride.Scripts
nextSlopeDistance = sumDistance - totalDistance * 1000;
NextSlopeTotalDistance = pointList[nextIndex].Distance;
currentSlopeDistance = (totalDistance * 1000 - (sumDistance - pointList[index].Distance));// CurrentDistance-( totalDistance * 1000 - (sumDistance - pointList[index].Distance));
//计算累计爬升
if (CurrentIndex > StartIndex)
{
totalClimb = 0;
for (int i = StartIndex+1; i <= CurrentIndex; i++)
{
var diff = mapData.List[i].Elevation - mapData.List[i - 1].Elevation;
if (diff > 0)
{
totalClimb += diff;
}
}
}
}
public double PreElevation;
public double PreSlope;
@@ -106,8 +106,8 @@ namespace Assets.Scenes.Ride.Scripts
_map.OnInitialized += _map_OnInitialized;
canvasGroup = transform.GetComponent<CanvasGroup>();
rideNow.enabled = false;
rideNow.interactable = false;
//rideNow.enabled = false;
UIManager.AddEvent(rideNow.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
UIManager.AddEvent(cancel.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, Cancel);
@@ -163,7 +163,7 @@ namespace Assets.Scenes.Ride.Scripts
if (process >= 100)
{
rideNow.interactable = true;
rideNow.enabled = true;
//rideNow.enabled = true;
}
}
@@ -174,10 +174,12 @@ namespace Assets.Scenes.Ride.Scripts
}
protected virtual void StartRide(BaseEventData baseEvent)
{
if (!rideNow.IsInteractable())
return;
var checkAnt = cyclingController.CheckAnt();
#if UNITY_EDITOR
//#if UNITY_EDITOR
checkAnt = true;
#endif
//#endif
if (!checkAnt && !cyclingController.isWatch)
{
#if UNITY_IOS || UNITY_ANDROID
@@ -302,15 +302,6 @@ namespace Assets.Scenes.Ride.Scripts
#if UNITY_IOS || UNITY_ANDROID
totalDistanceCompetition.text = Math.Round(mainController.GetMapData().TotalDistance, 1).ToString() + "KM";//总里程
var watchList = mainController.GetWatcherList();
if (mainController.competitionId > 0)
{
var showLeft = watchList.Count > 0;
distanceIconCompetition.SetActive(!showLeft);
totalDistanceCompetition.gameObject.SetActive(!showLeft);
totalDistance.gameObject.SetActive(showLeft);
totalDistanceIcon.gameObject.SetActive(showLeft);
}
#endif
Utils.DisplayImage(altitudeGraph, route.RouteInstance.AltitudeGraph);//渲染海拔图
@@ -388,6 +379,19 @@ namespace Assets.Scenes.Ride.Scripts
//绑定数据源
public void BindDataSource()
{
#if UNITY_IOS || UNITY_ANDROID
var watchList = mainController.GetWatcherList();
if (mainController.competitionId > 0)
{
var showLeft = watchList.Count > 0;
viewButton.enabled = true;
viewButton.interactable = true;
distanceIconCompetition.SetActive(!showLeft);
totalDistanceCompetition.gameObject.SetActive(!showLeft);
totalDistance.gameObject.SetActive(showLeft);
totalDistanceIcon.gameObject.SetActive(showLeft);
}
#endif
//获取当前选中玩家绑定当前UI
var currentPlayer = mainController.currentPlayer;
if (currentPlayer != null)
@@ -496,6 +500,7 @@ namespace Assets.Scenes.Ride.Scripts
if (playerController?.TotalTicks > 0)
{
quitPanel.SetActive(true);
quitPanel.transform.SetAsLastSibling();
}
else
{
@@ -515,6 +520,7 @@ namespace Assets.Scenes.Ride.Scripts
public void ShowSettingPanel(BaseEventData baseEventData)
{
settingPanel.SetActive(true);
settingPanel.transform.SetAsLastSibling();
}
//进入简约模式
protected int isSimple = 1;
@@ -33,7 +33,7 @@ namespace Assets.Scenes.Ride.Scripts
}
protected override void CreateList()
{
OnlineUserNum.text = MapUDPService.GetNearRiderCount().ToString();
OnlineUserNum.text = " "+ MapUDPService.GetNearRiderCount().ToString();
LayoutRebuilder.ForceRebuildLayoutImmediate(OnlineUserNum.rectTransform);
var nearList = MapUDPService.GetNearRiderData(pageIndex, pageSize, new double[] { playerController.Currentlatlong.x, playerController.Currentlatlong.y });
var mod = MapUDPService.GetNearRiderCount() % pageSize;
@@ -22,6 +22,7 @@ namespace Assets.Scenes.Ride.Scripts
base.Init();
UserId = App.CurrentUser.Id;
totalDistance = mainController.selectParamModel.EndDistance;
StartIndex = mainController.GetCurrentIndex(totalDistance);
currentlatlong = mainController.GetCenterCoordinate();
uipanel = mainController.GetUIPanel();
trail = FindObjectOfType<TrailRenderer>();
@@ -58,7 +59,7 @@ namespace Assets.Scenes.Ride.Scripts
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
#if UNITY_EDITOR
power = 500;
power = 343;
#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
}
@@ -81,21 +82,9 @@ namespace Assets.Scenes.Ride.Scripts
speed = 0;
distance = 0;
}
//计算累计爬升
if (CurrentIndex > 0)
{
totalClimb = 0;
for (int i = 1; i <= CurrentIndex; i++)
{
var diff = mapData.List[i].Elevation - mapData.List[i - 1].Elevation;
if (diff > 0)
{
totalClimb += diff;
}
}
}
}
protected override void Record()
{
if (!stopRecord)
{
//记录骑行数据
@@ -114,15 +103,14 @@ namespace Assets.Scenes.Ride.Scripts
_TotalClimb = totalClimb,
};
var preDistance = totalDistance >= mapData.TotalDistance ? targetData._Distance : targetData._Distance - Distance;
recorderData.PreDistance = Math.Round(preDistance,6,MidpointRounding.AwayFromZero);
recorderData.EndDistance = Math.Round(targetData._Distance,6,MidpointRounding.AwayFromZero);
recorderData.PreDistance = Math.Round(preDistance, 6, MidpointRounding.AwayFromZero);
recorderData.EndDistance = Math.Round(targetData._Distance, 6, MidpointRounding.AwayFromZero);
recorderData.RiderDatas.Add(targetData);
//实时计算MaxAp
//mainController.ComputeMaxAP(Power, ticks);
}
}
protected override void BeforeRun()
protected override void BeforeRun()
{
//if (mainController != null)
//{