对战初步完成

This commit is contained in:
lishuo committed 2022-05-10 19:24:07 +08:00
1 parent b0c0890ca3
commit 509c309252
55 files changed
+7079 -6748

No files matched your search

+2 -2
View File
@@ -23,9 +23,9 @@ namespace Assets.Scripts.Apis
});
}
public async Task<JsonResult<List<GameRoomModel>>> GetList(int pageIndex, int pageSize,int? id = null)
public async Task<JsonResult<GameRoomResult>> GetList(int pageIndex, int pageSize,string name = "")
{
return await GetAsync<JsonResult<List<GameRoomModel>>>($"GameRoom/GetList?pageIndex={pageIndex}&pageSize={pageSize}&id={id}");
return await GetAsync<JsonResult<GameRoomResult>>($"GameRoom/GetList?pageIndex={pageIndex}&pageSize={pageSize}&name={name}");
}
public JsonResult<GameRoomModel> GetDetail(int id)
+5
View File
@@ -130,6 +130,11 @@ namespace Assets.Scripts.Apis
}
return null;
}
public JsonResult<MapRouteBestInfo> GetMapBestInfo(int id)
{
var url = $"Map/GetMapBestInfo?routeId={ id }";
return Get<JsonResult<MapRouteBestInfo>>(url);
}
public async Task<JsonResult<List<NearRouteModel>>> GetNearRouteAsync(float lat, float lng, float zoom, string bounds)
{
+133 -1
View File
@@ -6,11 +6,18 @@ using System.Threading.Tasks;
namespace Assets.Scripts.Apis.Models
{
public class GameRoomResult
{
public int Total { get; set; }
public List<GameRoomModel> List { get; set; }
}
public class GameRoomModel
{
public int Id { get; set; }
public int RoomId { get; set; }
public string Name { get; set; }
public DateTime StartTime { get; set; }
public DateTime? StartTime { get; set; }
public DateTime? EndTime { get; set; }
public int CloseTime { get; set; }
public int MaxMembers { get; set; }
public int UserId { get; set; }
@@ -22,6 +29,7 @@ namespace Assets.Scripts.Apis.Models
public bool Enable3D { get; set; }
public bool EnableAR { get; set; }
public bool IsLock { get; set; }
public string Password { get; set; }
public string AltitudeGraph { get; set; }
public double AverageGrade { get; set; }
public double Distance { get; set; }
@@ -34,5 +42,129 @@ namespace Assets.Scripts.Apis.Models
public string BestWxHeadImg { get; set; }
public string BestTotalTime { get; set; }
public string FileUrl { get; set; }
public List<RoomRankItem> RoomRankingList { get;set;}
public List<RoomPlayerModel> RoomPlayerList { get; set; }
public static List<GameRoomModel> Parse(string s)
{
if (s.Equals("list"))
return null;
List<GameRoomModel> list = new List<GameRoomModel>();
try
{
var arr = s.Replace("list[", "").Replace("[","").Split(']');
foreach (var item in arr)
{
if (string.IsNullOrEmpty(item))
continue;
var detailIndex = item.IndexOf("detail");
var info = item.Substring(0, detailIndex - 1).Split(',');
var playerList = item.Substring(detailIndex);
DateTime? startTime = null;
if (!string.IsNullOrEmpty(info[18]))
{
startTime = Convert.ToDateTime(info[18]);
}
list.Add(new GameRoomModel()
{
RoomId = Convert.ToInt32(info[0]),
UserId = Convert.ToInt32(info[1]),
Name = info[2],
CloseTime = Convert.ToInt32(info[3]),
MaxMembers = Convert.ToInt32(info[4]),
MapRouteId = Convert.ToInt32(info[5]),
MapRouteName = info[6],
Distance = Convert.ToDouble(info[7]),
TotalClimb = Convert.ToDouble(info[8]),
AverageGrade = Convert.ToDouble(info[9]),
Enable3D = Convert.ToBoolean(info[10]),
EnableAR = Convert.ToBoolean(info[11]),
IsLock = Convert.ToBoolean(info[12]),
Password = info[13],
FileName = info[14],
FileUrl = info[15],
AltitudeGraph = info[16],
Status = Convert.ToInt32(info[17]),
StartTime = startTime,
RoomPlayerList = RoomPlayerModel.Parse(playerList)
});
}
}
catch (Exception ex)
{
}
//list[0,0,321313,30,5,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,213,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][0,0,2131,30,4,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,313,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][20,16652,3213,30,3,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 8:41:34:][19,16652,测试3d线路,30,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 1:39:57:][18,16652,测试,61,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/4/25 2:34:03:][17,16652,213,30,3,1217,翠屏山后山北向南,5.271609999999998,65.22760000000001,0.23308249282477278,False,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=1217,0,2022/4/25 2:20:13:]
return list;
}
}
public class RoomPlayerModel
{
public int RoomId { get; set; }
public string WxHeadImage { get; set; }
public string Name { get; set; }
public int Sex { get; set; }
public double Weight { get; set; }
public int FTP { get; set; }
public int UserId { get; set; }
public DateTime JoinAt { get; set; }
public int Status { get; set; }
public double Process { get; set; }
public bool IsOwner { get; set; }
public DateTime LastActiveTime { get; set; }
public override string ToString()
{
return $"{RoomId},{UserId},{JoinAt},{Status},{Process},{IsOwner}";
}
public static List<RoomPlayerModel> Parse(string s)
{
List<RoomPlayerModel> list = new List<RoomPlayerModel>();
s = s.Replace("detail{", "");
if (string.IsNullOrEmpty(s))
return list;
var arr = s.Split('|');
foreach (var item in arr)
{
var info = item.Split(',');
list.Add(new RoomPlayerModel()
{
RoomId = Convert.ToInt32(info[0]),
UserId = Convert.ToInt32(info[1]),
JoinAt = Convert.ToDateTime(info[2]).ToLocalTime(),
Status = Convert.ToInt32(info[3]),
Process = Convert.ToInt32(info[4]),
IsOwner = Convert.ToBoolean(info[5]),
});
}
if (list.Count > 0)
{
var ids = list.Select(c => c.UserId);
var userList = ConfigHelper.mapApi.GetOnlineUserInfo(ids).data;
foreach (var item in list)
{
var user = userList.Where(c => c.Id == item.UserId).FirstOrDefault();
item.WxHeadImage = user?.HeadImage;
item.FTP = user.FTP;
item.Weight = user.Weight;
item.Name = user.Name;
item.Sex = user.Sex;
}
}
return list;
}
}
public class RoomRankItem
{
public int UserId { get; set; }
public string WxHeadImg { get; set; }
public string NickName { get; set; }
public int Rank { get; set; }
public string Country { get; set; }
public string TotalTime { get; set; }
public bool IsDNF { get; set; }
}
}
@@ -108,5 +108,7 @@ namespace Assets.Scripts.Apis.Models
public string Source { get; set; }
public int? LastFrame { get; set; }
public int? RoomId { get; set; }
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Apis.Models
{
public class MapRouteBestInfo
{
public string BestNickName { get; set; }
public string BestWxHeadImg { get; set; }
public string BestTotalTime { get; set; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db87a380e3453e5468eeaf412ccbe00c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: