92 lines
3.3 KiB
C#
92 lines
3.3 KiB
C#
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
|
using Assets.Scripts.Apis.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
|
{
|
|
public class SingleModel : BaseCycling
|
|
{
|
|
|
|
public SingleModel(Route route,RouteResultParam param)
|
|
: base(route, CyclingModel.Single)
|
|
{
|
|
this.IsRecord = true;
|
|
recorderData = new RecorderDataModel()
|
|
{
|
|
CurrentUser = App.CurrentUser,
|
|
Competitionid = 0,
|
|
ContinueIndex = 0,
|
|
ContinueMark = Guid.NewGuid().ToString(),
|
|
EndDistance = 0,
|
|
IsCompleted = false,
|
|
IsNeedRanking = true,
|
|
CyclingState = CyclingStateEnum.Prepare,
|
|
CurrentRoute = route,
|
|
CurrentRouteStartDistance = 0,
|
|
StartTime = DateTime.Now,//UIManager.Now.GetDateTime(),//DateTime.Now
|
|
selectParam = param
|
|
};
|
|
|
|
if (param != null)
|
|
{
|
|
recorderData.EndDistance = param.EndDistance;
|
|
recorderData.CurrentRouteStartDistance = param.EndDistance;
|
|
if (!string.IsNullOrWhiteSpace(param.ContinueMark))
|
|
{
|
|
recorderData.ContinueMark = param.ContinueMark;
|
|
}
|
|
else
|
|
{
|
|
param.ContinueMark = recorderData.ContinueMark;
|
|
}
|
|
recorderData.ContinueIndex = param.ContinueIndex.GetValueOrDefault(0);
|
|
}
|
|
|
|
recorderData.PreDistance = recorderData.EndDistance;
|
|
|
|
riders = new List<BaseRider>();
|
|
//var rider = new OnlineRiderModel()
|
|
//{
|
|
// NickName = App.CurrentUser.Nickname,
|
|
// UserId = App.CurrentUser.Id,
|
|
// WxHeadImg = App.CurrentUser.WxHeadImg + "?t=1",
|
|
// //Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1]),
|
|
// EndDistance = recorderData.EndDistance
|
|
//};
|
|
//rider.Point = _turfHelper.Along(rider.EndDistance);
|
|
|
|
//riders.Add(rider);
|
|
|
|
}
|
|
|
|
public override void Run(TargetData targetData)
|
|
{
|
|
#region 获取当前路线在线用户
|
|
riders.RemoveAll(r => r.IsSelf == false);
|
|
var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id).Where(d => d.IsSelf == false)
|
|
.ToList();
|
|
foreach (var item in onlineUsers)
|
|
{
|
|
riders.Add(new OnlineRiderModel()
|
|
{
|
|
NickName = item.Name,
|
|
UserId = item.Id,
|
|
WxHeadImg = item.HeadImage,
|
|
Point = new GeoJSON.Net.Geometry.GeographicPosition(item.Point[0], item.Point[1]),
|
|
EndDistance = item.EndDistance,
|
|
PreDistance = item.PreDistance,
|
|
WeightKg = item.WeightKg,
|
|
FrameRate = item.FrameRate,
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
base.Run(targetData);
|
|
}
|
|
}
|
|
}
|