91 lines
3.3 KiB
C#
Raw Normal View History

2021-03-30 20:00:11 +08:00
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
using Assets.Scripts.Apis.Models;
2021-03-30 20:00:11 +08:00
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)
2021-03-30 20:00:11 +08:00
{
this.IsRecord = true;
recorderData = new RecorderDataModel()
{
2021-04-12 17:35:56 +08:00
CurrentUser = App.CurrentUser,
2021-03-30 20:00:11 +08:00
Competitionid = 0,
2022-03-10 18:32:53 +08:00
ContinueIndex = 0,
ContinueMark = Guid.NewGuid().ToString(),
2021-03-30 20:00:11 +08:00
EndDistance = 0,
IsCompleted = false,
IsNeedRanking = true,
CyclingState = CyclingStateEnum.Prepare,
CurrentRoute = route,
CurrentRouteStartDistance = 0,
2022-03-10 18:32:53 +08:00
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;
2021-03-30 20:00:11 +08:00
2021-04-12 17:35:56 +08:00
riders = new List<BaseRider>();
2021-05-08 18:36:59 +08:00
//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);
2021-03-30 20:00:11 +08:00
2021-05-08 18:36:59 +08:00
//riders.Add(rider);
2021-03-30 20:00:11 +08:00
}
2021-04-12 17:35:56 +08:00
public override void Run(TargetData targetData)
2021-03-30 20:00:11 +08:00
{
2021-05-08 18:36:59 +08:00
#region 线线
2021-04-12 17:35:56 +08:00
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,
2021-04-12 17:35:56 +08:00
});
}
2021-05-08 18:36:59 +08:00
#endregion
2021-03-30 20:00:11 +08:00
base.Run(targetData);
}
}
}