骑行界面调整,底层逻辑细化
This commit is contained in:
1 parent
d5133ee7b0
commit
9a7830f46a
168 files changed
+19164
-393
No files matched your search
@@ -0,0 +1,108 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using GeoJSON.Net.Geometry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
{
|
||||
public abstract class BaseCycling
|
||||
{
|
||||
public CyclingModel Mode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否记录数据
|
||||
/// </summary>
|
||||
internal bool IsRecord { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 骑行数据记录器
|
||||
/// </summary>
|
||||
public RecorderDataModel recorderData { get; protected set; }
|
||||
|
||||
public List<BaseRider> riders { get; protected set; }
|
||||
/// <summary>
|
||||
/// 骑行的路线
|
||||
/// </summary>
|
||||
public Route route;
|
||||
/// <summary>
|
||||
/// 计时器
|
||||
/// </summary>
|
||||
public int Ticks = 0;
|
||||
/// <summary>
|
||||
/// 当前骑行的距离
|
||||
/// </summary>
|
||||
protected double currentDistance { get; set; }
|
||||
|
||||
public virtual bool CanPause => true;
|
||||
|
||||
protected TurfHelper _turfHelper;
|
||||
|
||||
protected double Zoom { get; private set; }
|
||||
protected string Bounds { get; private set; }
|
||||
|
||||
protected List<OutUser> realRiders;
|
||||
|
||||
protected GeographicPosition CenterPoint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束的时间
|
||||
/// </summary>
|
||||
protected DateTime? EndTime { get; set; }
|
||||
|
||||
public BaseCycling(Route route, CyclingModel cyclingModel)
|
||||
{
|
||||
this.route = route;
|
||||
this.Mode = cyclingModel;
|
||||
_turfHelper = new TurfHelper(route.JsonData.List.Select(d => d.Point));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 骑行函数(如果此方法不满足,可以在子类中重写此方法)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
protected virtual void Run(TargetData targetData)
|
||||
{
|
||||
//将当前用户的位置发送到udf服务
|
||||
SendUserPositionToServer();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// =>发送用户的位置信息到服务端
|
||||
/// </summary>
|
||||
private void SendUserPositionToServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (recorderData.RiderDatas.Any())
|
||||
{
|
||||
var lastData = recorderData.RiderDatas.Last();
|
||||
var preDistance = recorderData.PreDistance;
|
||||
|
||||
var weightKg = Math.Round(lastData._Power / recorderData.CurrentUser.Weight, 2);
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId,
|
||||
new double[] { lastData._Lat, lastData._Lon },
|
||||
recorderData.IsCompleted, false, recorderData.EndDistance,
|
||||
true, 1, lastData._Speed, false, preDistance, weightKg, competitionId: recorderData.Competitionid, recorderData.Saved);
|
||||
}
|
||||
else if (recorderData.EndDistance > 0)//没有骑,但是有初始位置的情况
|
||||
{
|
||||
var point = _turfHelper.Along(recorderData.EndDistance);
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId, new double[] { point.Latitude, point.Longitude }, competitionId: recorderData.Competitionid);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId, route.Point.First().Reverse().ToArray(), competitionId: recorderData.Competitionid);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89d63056e2fd43e41b30635a0036ba33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user