骑行界面&赛事界面调整&设备断开功能

This commit is contained in:
lishuo committed 2021-09-07 16:11:15 +08:00
1 parent 467a6f3810
commit 99081519bb
43 files changed
+3658 -697

No files matched your search

+9 -6
View File
@@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Apis
{
internal class MapCompetitionApi : ApiBase
@@ -24,9 +26,9 @@ namespace Assets.Scripts.Apis
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public JsonResult<List<CompetitionRankingResultModel>> GetRankingList(int id)
public JsonResult<List<CompetitionRankingResultModel>> GetRankingListAsync(int id)
{
var list = Get<JsonResult<dynamic>>($"/MapRecord/GetCompetitionRanking?id={ id }&pageIndex=0&pageSize=999");
var list = Get<JsonResult<CompetitionRankingResultListModel>>($"/MapRecord/GetCompetitionRanking?id={ id }&pageIndex=0&pageSize=999");
return new JsonResult<List<CompetitionRankingResultModel>>
{
@@ -38,7 +40,7 @@ namespace Assets.Scripts.Apis
//查询我参与的比赛列表
public JsonResult<List<JoinedCompetitionModel>> GetMyCompetitionList()
{
var list = Get<JsonResult<dynamic>>($"/MapCompetition/v0/GetMyList");
var list = Get<JsonResult<List<JoinedCompetitionModel>>>($"/MapCompetition/v0/GetMyList");
return new JsonResult<List<JoinedCompetitionModel>>
{
@@ -50,7 +52,7 @@ namespace Assets.Scripts.Apis
//查询比赛列表
public JsonResult<List<MapCompetitionModel>> GetCompetitionList(string name,int pageIndex,int pageSize,int status=0)
{
var list = Get<JsonResult<dynamic>>($"/MapCompetition/v1/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }");
var list = Get<JsonResult<List<MapCompetitionModel>>>($"/MapCompetition/v1/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }");
return new JsonResult<List<MapCompetitionModel>>
{
@@ -61,7 +63,8 @@ namespace Assets.Scripts.Apis
}
public async Task<JsonResult<List<MapCompetition>>> GetCompetitionListV2(string name, int pageIndex, int pageSize, string status = "", int order = 1, bool self = false, int activity = 0)
{
var list = await GetAsync<JsonResult<dynamic>>($"/MapCompetition/v2/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }&order={order}&self={self}&activity={activity}");
var list = await GetAsync<JsonResult<List<MapCompetition>>>($"/MapCompetition/v2/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }&order={order}&self={self}&activity={activity}");
Debug.Log("67");
return new JsonResult<List<MapCompetition>>
{
result = list.result,
@@ -72,7 +75,7 @@ namespace Assets.Scripts.Apis
//查询比赛详情
public JsonResult<MapCompetitionDetailModel> GetCompetitionDetail(int id)
{
var list = Get<JsonResult<dynamic>>($"/MapRouteGlobalCycling/Get?id={ id }");
var list = Get<JsonResult<MapCompetitionDetailModel>>($"/MapRouteGlobalCycling/Get?id={ id }");
return new JsonResult<MapCompetitionDetailModel>
{
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace Assets.Scripts.Apis.Models
{
@@ -34,4 +35,9 @@ namespace Assets.Scripts.Apis.Models
public string Gap { get; set; }
public string WxHeadImg { get; set; }
}
public class CompetitionRankingResultListModel
{
public List<CompetitionRankingResultModel> list { get; set; }
}
}
@@ -0,0 +1,129 @@
using System;
public class MapCompetitionListItem
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
///
/// </summary>
public string CoverImage { get; set; }
/// <summary>
///
/// </summary>
public int Status { get; set; }
/// <summary>
///
/// </summary>
public string StatusVlaue { get; set; }
/// <summary>
///
/// </summary>
public string Area { get; set; }
/// <summary>
///
/// </summary>
public DateTime StartApplyTime { get; set; }
/// <summary>
///
/// </summary>
public DateTime EndApplyTime { get; set; }
/// <summary>
///
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
///
/// </summary>
public int CloseTime { get; set; }
/// <summary>
///
/// </summary>
public int MaxMembers { get; set; }
/// <summary>
///
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
///
/// </summary>
public DateTime EndTime { get; set; }
/// <summary>
/// 阳澄湖绕圈赛
/// </summary>
public string Title { get; set; }
/// <summary>
/// 周一赛事
/// </summary>
public string Dec { get; set; }
/// <summary>
///
/// </summary>
public int RouteId { get; set; }
/// <summary>
///
/// </summary>
public int ApplyCount { get; set; }
/// <summary>
///
/// </summary>
public bool HasJoin { get; set; }
/// <summary>
///
/// </summary>
public string CanCancelJoin { get; set; }
/// <summary>
///
/// </summary>
public bool CanJoin { get; set; }
/// <summary>
///
/// </summary>
public bool CanEnter { get; set; }
/// <summary>
///
/// </summary>
public int MapCompetitionType { get; set; }
/// <summary>
///
/// </summary>
public bool CanWatch { get; set; }
/// <summary>
///
/// </summary>
public double Distance { get; set; }
/// <summary>
///
/// </summary>
public double AverageGrade { get; set; }
/// <summary>
///
/// </summary>
public double EleDifference { get; set; }
/// <summary>
///
/// </summary>
public double TotalClimb { get; set; }
/// <summary>
///
/// </summary>
public double MaxElevation { get; set; }
/// <summary>
///
/// </summary>
public string RouteCover { get; set; }
/// <summary>
///
/// </summary>
public string AltitudeGraph { get; set; }
/// <summary>
///
/// </summary>
public string SponsorCoverage { get; set; }
/// <summary>
///
/// </summary>
public string BannerPreview { get; set; }
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dfee8082eae2f2948b4c9022d38ae383
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts.Devices
{
class MobileInfo : MonoBehaviour
{
Text BatteryText { get; set; }
Text TimeText { get; set; }
private void Start()
{
BatteryText = transform.Find("BatteryText").GetComponent<Text>();
TimeText = transform.Find("TimeText").GetComponent<Text>();
}
private void Update()
{
BatteryText.text = $"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%";
TimeText.text = DateTime.Now.ToString("HH:mm");
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43faa658bc3cc36499ad4687b54e8608
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -174,9 +174,9 @@ namespace Assets.Scenes.Ride.Scripts
_canEnter = competition.CanEnter;
#region 赛事基本信息
//赛事名称
CompetitionTitle.text = GetMaxString(competition.Title,40);
CompetitionTitle.text = GetMaxString(competition.Title, 35);
//线路名称
mapName.text = GetMaxString(route.Name, 68);
mapName.text = GetMaxString(route.Name, 45);
//距离
distance.text = route.Distance.ToString("f1") + "KM";
//海拔
@@ -193,7 +193,7 @@ namespace Assets.Scenes.Ride.Scripts
Contestant.text = competition.UserList.Count.ToString() + "Riders";
ShowPlayers(competition.UserList);
//路书描述
mapDescText.text = competition.Dec;
mapDescText.text = GetMaxString(competition.Dec, 400);
//线路编号
MapId.text = route.Id.ToString();
@@ -24,7 +24,11 @@ namespace Assets.Scenes.Ride.Scripts
protected override void Awake()
{
//base.Awake();
#if UNITY_IOS || UNITY_ANDROID
pageSize = 7;
#else
pageSize = 4;
#endif
scroll = transform.Find("List").gameObject;
if (scroll != null)
{
@@ -48,8 +48,12 @@ namespace Assets.Scenes.Ride.Scripts
//显示关门时间
if (s.Item3 && !isAutoSave)
{
#if UNITY_IOS || UNITY_ANDROID
//显示倒计时面板信息
ShowCountDown(s.Item1, "Time Limit");
#else
ShowCountDown(s.Item1, "Get The First Place. Time Limit");
#endif
}
else if (s.Item1 >= 0)
{
@@ -173,7 +173,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
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);
var rrr = mapCompetitionApi.GetRankingListAsync(recorderData.Competitionid);
if (rrr.result)
{
mapWorkoutRecordRankings = rrr.data;
@@ -115,7 +115,9 @@ namespace Assets.Scenes.Ride.Scripts
InitData();//初始
RenderChart();//渲染海拔图
}
Text totalDistanceCompetition { get; set; }
GameObject distanceIconCompetition { get; set; }
GameObject totalDistanceIcon { get; set; }
private void InitGameObject()
{
#region 控件获取与事件绑定
@@ -130,6 +132,8 @@ namespace Assets.Scenes.Ride.Scripts
ditance = uipanel.transform.Find("ComputerPanel/Distance").GetComponent<Text>();
titlePanel = uipanel.transform.Find("TitlePanel").gameObject;
totalDistance = uipanel.transform.Find("TitlePanel/TotalDistance").GetComponent<Text>();
totalDistanceIcon = uipanel.transform.Find("TitlePanel/DistanceIcon").gameObject;
candance = uipanel.transform.Find("PowerPanel/Cadance").GetComponent<Text>();
heartRate = uipanel.transform.Find("PowerPanel/Hrv").GetComponent<Text>();
nextSlopePanel = uipanel.transform.Find("NextSlopePanel").gameObject;
@@ -137,6 +141,11 @@ namespace Assets.Scenes.Ride.Scripts
nextSlopeText = uipanel.transform.Find("NextSlopePanel/NextSlopeText").GetComponent<Text>();
nextSlopeDistanceText = uipanel.transform.Find("NextSlopePanel/NextSlopeDistance").GetComponent<Text>();
currentSlopeText = uipanel.transform.Find("CurrentSlopePanel/CurrentSlopeText").GetComponent<Text>();
#if UNITY_IOS || UNITY_ANDROID
totalDistanceCompetition = uipanel.transform.Find("TitlePanel/TotalDistanceCompetition").GetComponent<Text>();
distanceIconCompetition = uipanel.transform.Find("TitlePanel/DistanceIconCompetition").gameObject;
nextSlopeText = uipanel.transform.Find("CurrentSlopePanel/NextSlopeText").GetComponent<Text>();
#endif
currentSlopeDistanceText = uipanel.transform.Find("CurrentSlopePanel/CurrentSlopeDistance").GetComponent<Text>();
currentSlopeToatalDistanceText = uipanel.transform.Find("CurrentSlopePanel/TotalSlopeDistance").GetComponent<Text>();
currentSlopeProcess = uipanel.transform.Find("CurrentSlopePanel/Process").GetComponent<Image>();
@@ -226,7 +235,7 @@ namespace Assets.Scenes.Ride.Scripts
UIManager.AddEvent(singleButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, OnPointExit);
UIManager.AddEvent(shadowButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, OnPointExit);
#endregion
#endregion
}
protected virtual void Update()
{
@@ -273,6 +282,7 @@ namespace Assets.Scenes.Ride.Scripts
//开发者视角调整
cameraSlider = uipanel.transform.Find("CameraSlider").GetComponent<Slider>();
Text CameraText = uipanel.transform.Find("CameraSlider/Text").GetComponent<Text>();
#if !(UNITY_IOS || UNITY_ANDROID)
string[] phoneList = new string[] { "18120141032", "15651831367", "18120141031", "15261826280", "18662240319" };
if (phoneList.Contains(App.CurrentUser.Phone))
{
@@ -285,9 +295,24 @@ namespace Assets.Scenes.Ride.Scripts
CameraText.text = f.ToString("f0");
});
}
#endif
//路书基本信息绑定
mapName.text = routeInstance.Name;
totalDistance.text = Math.Round(mainController.GetMapData().TotalDistance, 1).ToString() + "KM";//总里程
#if UNITY_IOS || UNITY_ANDROID
totalDistanceCompetition.text = Math.Round(mainController.GetMapData().TotalDistance, 1).ToString() + "KM";//总里程
var watchList = mainController.GetWatcherList();
if (mainController.competitionId > 0)
{
var showLeft = watchList.Count > 0;
distanceIconCompetition.SetActive(!showLeft);
totalDistanceCompetition.gameObject.SetActive(!showLeft);
totalDistance.gameObject.SetActive(showLeft);
totalDistanceIcon.gameObject.SetActive(showLeft);
}
#endif
Utils.DisplayImage(altitudeGraph, route.RouteInstance.AltitudeGraph);//渲染海拔图
//影子骑行按钮控制
if (mainController.mapRouteRankingList == null || mainController.mapRouteRankingList.Count == 0)
@@ -76,7 +76,7 @@ namespace Assets.Scenes.Ride.Scripts
slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%";
rideNum.text = route.TheHeat.ToString();
distance.text = route.Distance.ToString("f1") + "KM";
mapDescText.text = route.Dec;
mapDescText.text = GetMaxString(route.Dec, 255);
mapId.text = route.Id.ToString();
var userList = ConfigHelper.mapApi.GetOnlineUserInfo(new int[] { route.UserId }).data;
if (userList.Count > 0)
@@ -29,7 +29,7 @@ namespace Assets.Scenes.Ride.Scripts
#endif
Title = transform.Find("Title").GetComponent<Text>();
OnlineUserNum = transform.Find("NearByView/OnlineUserNum").GetComponent<Text>();
pageSize = 5;//开启无线下拉
pageSize = 7;//开启无线下拉
}
protected override void CreateList()
{
@@ -96,7 +96,17 @@ namespace Assets.Scenes.Ride.Scripts
{
if (infoPanel == null)
{
if(mainController.cyclingModel == CyclingModel.Competition)
#if UNITY_IOS || UNITY_ANDROID
if (mainController.cyclingModel == CyclingModel.Competition)
{
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/Mobile/OnlineRaceInfoPanel"), uiObject);
}
else
{
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/Mobile/OnlineInfoPanel"), uiObject);
}
#else
if (mainController.cyclingModel == CyclingModel.Competition)
{
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineRaceInfoPanel"), uiObject);
}
@@ -104,6 +114,7 @@ namespace Assets.Scenes.Ride.Scripts
{
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineInfoPanel"), uiObject);
}
#endif
}
var headPos = infoPanel.transform.Find("Head").position;
var infoPos = playerScreenPos + new Vector3(150f, 60f, 0f);
@@ -72,7 +72,11 @@ namespace Assets.Scenes.Ride.Scripts
{
if (infoPanel == null)
{
#if UNITY_IOS || UNITY_ANDROID
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/Mobile/OnlineInfoPanel"), uiObject);
#else
infoPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineInfoPanel"), uiObject);
#endif
}
var headPos = infoPanel.transform.Find("Head").position;
var infoPos = playerScreenPos + new Vector3(150f, 60f, 0f);
@@ -92,6 +92,9 @@ namespace Assets.Scenes.Ride.Scripts
gameObjects.Add(transform.Find("Panel/Player3").gameObject);
gameObjects.Add(transform.Find("Panel/Player4").gameObject);
gameObjects.Add(transform.Find("Panel/Player5").gameObject);
#if UNITY_IOS || UNITY_ANDROID
gameObjects.Add(transform.Find("Panel/Player6").gameObject);
#endif
//功体比默认条件
//var currentUserWkg = Math.Round((App.CurrentUser.FTP / App.CurrentUser.Weight),2);
//_startValue = currentUserWkg - 0.5<0?0 : currentUserWkg - 0.5;
@@ -41,6 +41,7 @@ public class ConnectDeviceModal : PFUIPanel
private UnityEngine.Object deviceItem;
private VerticalLayoutGroup content;
private PfUIButton connectBtn;
private Text connectBtnText;
private Dictionary<string, DeviceItem> deviceList;
private Text noDevice,Title;
private RectTransform searchIconRect;
@@ -75,34 +76,54 @@ public class ConnectDeviceModal : PFUIPanel
deviceItem = Resources.Load("UI/Prefab/Device/DeviceItem");
connectBtn = container.Find("ConnectBtn").GetComponent<PfUIButton>();
connectBtnText = connectBtn.transform.Find("Text").GetComponent<Text>();
UIManager.AddEvent(connectBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
foreach (var item in deviceList)
if (!connectBtnText.text.Equals("DISCONNECT"))
{
if (item.Value.GetStatus() == false)
foreach (var item in deviceList)
{
if (SensorType == SensorType.SpeedCadence)
if (item.Value.GetStatus() == false)
{
if (item.Value.DeviceInfo.Sensor == SensorType.SpeedCadence || item.Value.DeviceInfo.Sensor == SensorType.Cadence)
if (SensorType == SensorType.SpeedCadence)
{
if (item.Value.DeviceInfo.Sensor == SensorType.SpeedCadence || item.Value.DeviceInfo.Sensor == SensorType.Cadence)
{
//Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
item.Value.DeviceInfo.Disconnect();
DeviceCache.Remove(item.Value.DeviceInfo);
}
}
else if (item.Value.DeviceInfo.Sensor == SensorType)
{
//Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
item.Value.DeviceInfo.Disconnect();
DeviceCache.Remove(item.Value.DeviceInfo);
}
}
else if (item.Value.DeviceInfo.Sensor == SensorType)
{
item.Value.DeviceInfo.Disconnect();
DeviceCache.Remove(item.Value.DeviceInfo);
}
}
var dd = deviceList.Select(d => d.Value).Where(d => d.GetStatus()).FirstOrDefault();
if (dd != null)
{
dd.DeviceInfo.Connect();
DeviceCache.Add(dd.DeviceInfo);
}
}
var dd = deviceList.Select(d => d.Value).Where(d => d.GetStatus()).FirstOrDefault();
if (dd != null)
else
{
dd.DeviceInfo.Connect();
DeviceCache.Add(dd.DeviceInfo);
foreach (var item in deviceList)
{
Debug.Log("116" + item.Value.DeviceInfo.Name+ item.Value.GetStatus().ToString());
if (item.Value.GetStatus())
{
if (item.Value.DeviceInfo.Sensor == SensorType)
{
item.Value.DeviceInfo.Disconnect();
Debug.Log("121" + item.Value.DeviceInfo.Name + "断开");
DeviceCache.Remove(item.Value.DeviceInfo);
}
}
}
}
this.Close();
}));
@@ -172,10 +193,18 @@ public class ConnectDeviceModal : PFUIPanel
gameObject.transform.localScale = new Vector3(1, 1, 1);
var deviceItemObj = gameObject.GetComponent<DeviceItem>();
deviceItemObj.DeviceInfo = device;
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
deviceItemObj.Set(true);
if (deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected)
{
connectBtnText.text = "DISCONNECT";
}
else
{
connectBtnText.text = "CONNECT";
}
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.Id)
@@ -197,13 +226,20 @@ public class ConnectDeviceModal : PFUIPanel
deviceList.Add(device.Id, deviceItemObj);
}
if(deviceList.All(d=>d.Value.GetStatus() == false))
if(deviceList.All(d=>d.Value.GetStatus() == false))
{
var firstDevice = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected).OrderByDescending(d => d.DeviceInfo.Priority).FirstOrDefault();
if (firstDevice != null)
{
firstDevice.Set(true);
if (firstDevice.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && firstDevice.DeviceInfo.State == DeviceState.Connected)
{
connectBtnText.text = "DISCONNECT";
}
else
{
connectBtnText.text = "CONNECT";
}
//connectBtn.text.text = "DISCOUNECT";
noDevice.text = firstDevice.DeviceInfo.Name;
}