103 lines
3.8 KiB
C#
103 lines
3.8 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 GameModel : BaseCycling
|
|
{
|
|
/// <summary>
|
|
/// 第一个到终点的时间
|
|
/// </summary>
|
|
public DateTime? FirstEndTime { get; private set; }
|
|
public GameRoomModel GameRoom { get; private set; }
|
|
|
|
public GameModel(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,
|
|
RoomId = App.gameRoomDetail.RoomId,
|
|
};
|
|
GameRoom = App.gameRoomDetail;
|
|
App.gameRoomDetail = null;
|
|
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>();
|
|
}
|
|
|
|
public override void Run(TargetData targetData)
|
|
{
|
|
#region 获取当前路线在线用户
|
|
riders.RemoveAll(r => r.IsSelf == false);
|
|
var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id, recorderData.RoomId).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,
|
|
Sex = item.Sex,
|
|
FrameRate = item.FrameRate,
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
base.Run(targetData);
|
|
}
|
|
|
|
protected override void BeforeRunAfterPakcData()
|
|
{
|
|
base.BeforeRunAfterPakcData();
|
|
|
|
var userList = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id,recorderData.RoomId).Where(c=>c.IsSelf == false).OrderByDescending(u => u.Saved).ThenBy(d => d.CreateTime).ThenByDescending(d => d.EndDistance);
|
|
if (userList.Any())
|
|
{
|
|
foreach (var item in userList)
|
|
{
|
|
if(!FirstEndTime.HasValue && item.IsCompleted)
|
|
FirstEndTime = Now.AddMinutes(GameRoom.CloseTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|