loading页&结果页面&代码结构微调
This commit is contained in:
1 parent
eb1803c9ef
commit
eed2d13624
99 files changed
+14567
-7299
No files matched your search
@@ -0,0 +1,135 @@
|
||||
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));
|
||||
}
|
||||
|
||||
public virtual DateTime Now
|
||||
{
|
||||
get
|
||||
{
|
||||
return UIManager.Now.GetDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string ShowTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return Helper.FormatTicks(Ticks);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 骑行函数(如果此方法不满足,可以在子类中重写此方法)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public virtual void Run(TargetData targetData)
|
||||
{
|
||||
//将当前用户的位置发送到udf服务
|
||||
SendUserPositionToServer();
|
||||
//OutModel outData = GetSelfTargetData(targetData);
|
||||
BeforeRunAfterPakcData();//执行前的函数
|
||||
}
|
||||
|
||||
/// <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);
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId, new double[] { point.Latitude, point.Longitude }, endDistance:recorderData.EndDistance,preDistance: recorderData.EndDistance, competitionId: recorderData.Competitionid);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId, route.Point.First().Reverse().ToArray(), competitionId: recorderData.Competitionid);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行前,数据打包后
|
||||
/// </summary>
|
||||
/// <param name="outData"></param>
|
||||
protected virtual void BeforeRunAfterPakcData() { }
|
||||
protected double SpeedToDistance(double speed)
|
||||
{
|
||||
return Math.Round(speed / 3600, 5, MidpointRounding.AwayFromZero);
|
||||
//return 0.08;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89d63056e2fd43e41b30635a0036ba33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,333 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Mapbox.Utils;
|
||||
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 CompetitionModel : BaseCycling
|
||||
{
|
||||
private Vector2d firstPoint { get; set; }
|
||||
public CompetitionRankingModel competitionRankingModel { get; set; }
|
||||
|
||||
private MapCompetitionApi mapCompetitionApi;
|
||||
|
||||
public MapCompetition mapCompetition;
|
||||
|
||||
private List<CompetitionRankingResultModel> mapWorkoutRecordRankings = new List<CompetitionRankingResultModel>();
|
||||
/// <summary>
|
||||
/// 第一个到终点的时间
|
||||
/// </summary>
|
||||
private DateTime? FirstEndTime { get; set; }
|
||||
|
||||
public override bool CanPause => false;
|
||||
|
||||
public override string ShowTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CanStart())
|
||||
{
|
||||
var second = Math.Ceiling((Now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
|
||||
|
||||
var ts = TimeSpan.FromSeconds(second);
|
||||
return $"{ (int)ts.TotalHours }:{ts:mm}:{ts:ss}";
|
||||
}
|
||||
return "00:00:00";
|
||||
}
|
||||
}
|
||||
AbstractPlayer currentPlayer;
|
||||
public CompetitionModel(Route route1, RouteResultParam param,AbstractPlayer player)
|
||||
: base(route1, CyclingModel.Competition)
|
||||
{
|
||||
currentPlayer = player;//当前选中用户
|
||||
mapCompetitionApi = new MapCompetitionApi();
|
||||
//param.EndDistance = 18;
|
||||
recorderData = new RecorderDataModel()
|
||||
{
|
||||
CurrentUser = App.CurrentUser,
|
||||
//BelongUserId = PubCommData.CurrentUser.Id,
|
||||
Competitionid = param.CompetitionId??0,
|
||||
ContinueIndex = param.ContinueIndex == null ? 0 : (int)param.ContinueIndex + 1,
|
||||
ContinueMark = string.IsNullOrEmpty(param.ContinueMark) ? Guid.NewGuid().ToString() : param.ContinueMark,
|
||||
EndDistance = param.EndDistance == 0 ? 0 : param.EndDistance,
|
||||
IsCompleted = false,
|
||||
IsNeedRanking = true,
|
||||
CyclingState = CyclingStateEnum.Prepare,
|
||||
//ManufacturerId = ManufacturerId,
|
||||
CurrentRoute = route,
|
||||
CurrentRouteStartDistance = param.EndDistance == 0 ? 0 : param.EndDistance,
|
||||
//DeviceNumber = DeviceNumber,
|
||||
//AntModelId = antModelId
|
||||
};
|
||||
|
||||
IsRecord = true;
|
||||
|
||||
riders = new List<BaseRider>();
|
||||
var rider = new OnlineRiderModel()
|
||||
{
|
||||
NickName = App.CurrentUser.Nickname,
|
||||
UserId = App.CurrentUser.Id,
|
||||
WxHeadImg = App.CurrentUser.WxHeadImg,
|
||||
EndDistance = param.EndDistance == 0 ? 0 : param.EndDistance
|
||||
};
|
||||
if (recorderData.CurrentRouteStartDistance > 0)
|
||||
{
|
||||
rider.Point = _turfHelper.Along(param.EndDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
rider.Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1]);
|
||||
}
|
||||
//riders.Add(rider);//剔除自己
|
||||
|
||||
var result = mapCompetitionApi.GetById(param.CompetitionId??0);
|
||||
if (result.result == false || result.data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mapCompetition = result.data;
|
||||
FirstEndTime = mapCompetition.FirstEndTime;
|
||||
}
|
||||
|
||||
protected override void BeforeRunAfterPakcData()
|
||||
{
|
||||
//#region 设置第一名的坐标
|
||||
//if (!FirstEndTime.HasValue)
|
||||
//{
|
||||
// var firstItem = base.realRiders.OrderByDescending(w => w.NextDistance).FirstOrDefault();
|
||||
// if (firstItem != null)
|
||||
// {
|
||||
// firstPoint = new Vector2d(firstItem.Point.Latitude, firstItem.Point.Longitude);
|
||||
// }
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
var userList = MapUDPService.GetCompetitionOnlineUsers(recorderData.Competitionid).OrderByDescending(u => u.IsCompleted).ThenByDescending(d => d.EndDistance);
|
||||
riders.RemoveAll(r => r.IsSelf == false);
|
||||
int index = 0;
|
||||
List<CompetitionRankingSortModel> sort = new List<CompetitionRankingSortModel>();
|
||||
|
||||
if (userList.Any())
|
||||
{
|
||||
var currentDistance = currentPlayer.TotalDistance;
|
||||
foreach (var item in userList)
|
||||
{
|
||||
#region 记录第一个冲线的时间
|
||||
if (item.IsCompleted && !FirstEndTime.HasValue)
|
||||
{
|
||||
FirstEndTime = Now;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (item.IsSelf == false)
|
||||
{
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
index++;
|
||||
double near = Math.Round(item.EndDistance - currentDistance,2); //Math.Round(TurfHelper.GetDistances(point, item.Point), 2);
|
||||
|
||||
sort.Add(new CompetitionRankingSortModel
|
||||
{
|
||||
Index = index,
|
||||
Name = item.Name,
|
||||
Near = near,
|
||||
KGWeight = Math.Round(item.WeightKg, 2).ToString(),
|
||||
Speed = Math.Round(item.Speed, 1),
|
||||
CountryImg = ConfigHelper.Host + $"User/GetCountryImg?userid={ item.Id }",
|
||||
UserId = item.Id,
|
||||
IsSelf = item.IsSelf,
|
||||
Headimage =item.HeadImage
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 骑行结束,比赛结果展示数据
|
||||
var results = new List<CompetitionResultModel>();
|
||||
if (recorderData.IsCompleted || recorderData.Saved || mapCompetition.HasRecord)
|
||||
{
|
||||
var users1 = userList.Where(d => d.IsCompleted || d.Saved);
|
||||
if ((users1.Any() && users1.Any(d => mapWorkoutRecordRankings.All(u => u.UserId != d.Id)))
|
||||
|| mapWorkoutRecordRankings.All(u => u.UserId != recorderData.BelongUserId))
|
||||
{
|
||||
var rrr = mapCompetitionApi.GetRankingList(recorderData.Competitionid);
|
||||
if (rrr.result)
|
||||
{
|
||||
mapWorkoutRecordRankings = rrr.data;
|
||||
}
|
||||
}
|
||||
foreach (var ranking in mapWorkoutRecordRankings)
|
||||
{
|
||||
//var ranking = mapWorkoutRecordRankings.SingleOrDefault(r => r.UserId == item.Id);
|
||||
|
||||
var createTime = "";
|
||||
if (ranking != null)
|
||||
{
|
||||
createTime = ranking.CreateTime; //.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
results.Add(new CompetitionResultModel
|
||||
{
|
||||
Index = ranking.Index,
|
||||
Name = ranking.NickName,
|
||||
UserId = ranking.UserId,
|
||||
Weight = ranking?.Weight ?? 0,
|
||||
WeightKg = ranking?.WeightKg ?? 0,
|
||||
//Time = ranking?.TotalTime ?? "",
|
||||
Power = ranking?.AveragePower ?? 0,
|
||||
BicycleWeight = ranking?.BicycleWeight ?? 0,
|
||||
HeartRate = ranking?.AverageHeartRate ?? 0,
|
||||
DeviceType = ranking?.DeviceType ?? "",
|
||||
CreateTime = createTime,
|
||||
TripTime = ranking?.TripTime ?? "",
|
||||
CompleteTime = ranking?.CompleteTime,
|
||||
Gap = ranking?.Gap ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
competitionRankingModel = new CompetitionRankingModel
|
||||
{
|
||||
Sorts = sort,//骑行实时排名
|
||||
MyRanking = sort.FindIndex(n => n.UserId == currentPlayer.UserId) + 1,//切换人物显示对应人物的排名
|
||||
Total = sort.Count,//总人数
|
||||
Results = results//比赛结果列表
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 赛事模式有继续骑行,重写执行方法
|
||||
/// </summary>
|
||||
/// <param name="targetData"></param>
|
||||
public override void Run(TargetData targetData)
|
||||
{
|
||||
|
||||
#region 获取当前路线在线用户
|
||||
riders.RemoveAll(r => r.IsSelf == false);
|
||||
var onlineUsers = MapUDPService.GetCompetitionOnlineUsers(mapCompetition.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,
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
//TODO:接力赛
|
||||
////base.BeforeRun(targetData);
|
||||
//if (recorderData.CyclingState == CyclingStateEnum.Prepare)
|
||||
//{
|
||||
// if (recorderData.EndDistance != 0)
|
||||
// {
|
||||
// currentDistance = recorderData.EndDistance;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// currentDistance = 0;
|
||||
// }
|
||||
//}
|
||||
//else if (recorderData.CyclingState == CyclingStateEnum.Cycling)
|
||||
//{
|
||||
// currentDistance = recorderData.EndDistance + SpeedToDistance(targetData._Speed);
|
||||
//}
|
||||
base.Run(targetData);
|
||||
}
|
||||
|
||||
//显示结果当前用户保存或者产生第一名
|
||||
public bool CanShowResult()
|
||||
{
|
||||
return mapCompetition?.HasRecord ?? false || mapCompetition ?.FirstEndTime != null;
|
||||
}
|
||||
//关门时间到了退出骑行场景
|
||||
public bool CanQuit()
|
||||
{
|
||||
if (mapCompetition?.FirstEndTime.HasValue??false)
|
||||
{
|
||||
var closeDateTime = mapCompetition?.FirstEndTime.Value.ToLocalTime().AddMinutes(mapCompetition?.CloseTime??0 );
|
||||
return Now >= closeDateTime;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanStart()
|
||||
{
|
||||
if (mapCompetition == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if (mapCompetition.CanStart)
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
if (mapCompetition.HasRecord)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//已结束
|
||||
if (mapCompetition.Status == 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (mapCompetition.StartTime.ToLocalTime() <= Now && mapCompetition.EndTime.ToLocalTime() > Now)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int StartCountdown()
|
||||
{
|
||||
if (CanStart()) return 0;
|
||||
return (int)Math.Floor((mapCompetition.StartTime.ToLocalTime() - Now).TotalSeconds);
|
||||
}
|
||||
/// <summary>
|
||||
/// 结束倒计时,bool值为true说明倒计时是关门时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (int, bool) EndCountDown()
|
||||
{
|
||||
if (CanStart() == false) return (0, false);
|
||||
//if (recorderData.IsCompleted) return 0;
|
||||
var end1 = (int)Math.Floor((mapCompetition.EndTime.ToLocalTime() - Now).TotalSeconds);
|
||||
if (!FirstEndTime.HasValue)
|
||||
{
|
||||
return (end1, false);
|
||||
}
|
||||
//var end2 = (int)Math.Floor((FirstEndTime.Value - Now).TotalSeconds);
|
||||
var end2 = (int)Math.Floor((FirstEndTime.Value.AddMinutes(mapCompetition.CloseTime) - Now).TotalSeconds);
|
||||
if (end1 < end2)
|
||||
{
|
||||
return (end1, false);
|
||||
}
|
||||
//return Math.Min(end1, end2);
|
||||
return (end2, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44b357cbe9541fa448708b42ff5bf3d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,90 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using Assets.Scripts;
|
||||
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 ReviewModel : BaseCycling
|
||||
{
|
||||
public List<MapRecordRanking> rankings;
|
||||
|
||||
public ReviewModel(Route route1, RouteResultParam param)
|
||||
: base(route1, CyclingModel.Review)
|
||||
{
|
||||
//rankings = service.GetMapRecordRankingsFromServe(param.RankingsId);
|
||||
riders = new List<BaseRider>();
|
||||
//riders.Add(new OnlineRiderModel()
|
||||
//{
|
||||
// NickName = App.CurrentUser.Nickname,
|
||||
// UserId = App.CurrentUser.Id,
|
||||
// WxHeadImg = App.CurrentUser.WxHeadImg,
|
||||
// Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1])
|
||||
//});
|
||||
//foreach (var item in rankings)
|
||||
//{
|
||||
// riders.Add(new ReviewRiderModel()
|
||||
// {
|
||||
// NickName = item.NickName,
|
||||
// UserId = item.UserId,
|
||||
// WxHeadImg = item.WxHeadImg,
|
||||
// record = item.record,
|
||||
// Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1])
|
||||
// });
|
||||
//}
|
||||
recorderData = new RecorderDataModel()
|
||||
{
|
||||
CurrentUser = App.CurrentUser,
|
||||
//BelongUserId = PubCommData.CurrentUser.Id,
|
||||
Competitionid = 0,
|
||||
ContinueIndex = 0,
|
||||
ContinueMark = Guid.NewGuid().ToString(),
|
||||
EndDistance = 0,
|
||||
PreDistance = 0,
|
||||
IsCompleted = false,
|
||||
IsNeedRanking = true,
|
||||
CyclingState = CyclingStateEnum.Prepare,
|
||||
//ManufacturerId = ManufacturerId,
|
||||
CurrentRoute = route,
|
||||
CurrentRouteStartDistance = 0,
|
||||
//DeviceNumber = DeviceNumber,
|
||||
//AntModelId = antModelId
|
||||
};
|
||||
|
||||
//recorderData = recorderData1;
|
||||
this.IsRecord = true;
|
||||
//riders = riders1;
|
||||
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
base.Run(targetData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 363f64631c874c84198aa481f8899911
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
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 = UIManager.Now.GetDateTime(),//DateTime.Now
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
base.Run(targetData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1057f786065eded488dd73a935cc1b93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user