倒计时的算法及界面调整

This commit is contained in:
lishuo 2021-07-30 15:38:40 +08:00
parent bea0e40ec1
commit 074200cb4f
16 changed files with 2714 additions and 2596 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

View File

@ -0,0 +1,104 @@
fileFormatVersion: 2
guid: b290a2043a6b220449e5e622af289c65
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -437,7 +437,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 30, y: 0} m_AnchoredPosition: {x: 30, y: 0}
m_SizeDelta: {x: 0, y: 22} m_SizeDelta: {x: 0, y: 20.036041}
m_Pivot: {x: 1, y: 1} m_Pivot: {x: 1, y: 1}
--- !u!222 &341053726653005601 --- !u!222 &341053726653005601
CanvasRenderer: CanvasRenderer:
@ -460,7 +460,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.9764706, g: 0.1882353, b: 0.5254902, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
@ -479,7 +479,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: 0 m_Text: ' 0'
--- !u!114 &341053726653005602 --- !u!114 &341053726653005602
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -639,7 +639,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 17} m_SizeDelta: {x: 16, y: 16}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &341053727548647539 --- !u!222 &341053727548647539
CanvasRenderer: CanvasRenderer:
@ -668,7 +668,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 5ca02e860670e674fbe3875814a2b1d7, type: 3} m_Sprite: {fileID: 21300000, guid: b290a2043a6b220449e5e622af289c65, type: 3}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1

View File

@ -4606,7 +4606,7 @@ MonoBehaviour:
m_Alignment: 3 m_Alignment: 3
m_AlignByGeometry: 0 m_AlignByGeometry: 0
m_RichText: 1 m_RichText: 1
m_HorizontalOverflow: 0 m_HorizontalOverflow: 1
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: 0000 - 00-00 00:00:00 m_Text: 0000 - 00-00 00:00:00

View File

@ -190,7 +190,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1} m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -41} m_AnchoredPosition: {x: 0, y: -33}
m_SizeDelta: {x: 284, y: 22} m_SizeDelta: {x: 284, y: 22}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8655198199642205030 --- !u!222 &8655198199642205030

View File

@ -119,8 +119,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5} m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 244.41, y: 0} m_AnchoredPosition: {x: 240.23004, y: 0}
m_SizeDelta: {x: 79.16922, y: 22} m_SizeDelta: {x: 87.529144, y: 22}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5946431579487976801 --- !u!222 &5946431579487976801
CanvasRenderer: CanvasRenderer:
@ -360,8 +360,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5} m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 137.41, y: 0} m_AnchoredPosition: {x: 133.23, y: 0}
m_SizeDelta: {x: 134.8265, y: 22} m_SizeDelta: {x: 126.47095, y: 22}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5549514346347886655 --- !u!222 &5549514346347886655
CanvasRenderer: CanvasRenderer:

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ using Assets.Scripts.Devices;
public static class App public static class App
{ {
public static string Host = "http://192.168.0.101:5085/"; public static string Host = "http://192.168.0.102:5082/";
public static string AppVersion = Application.version; public static string AppVersion = Application.version;

View File

@ -172,7 +172,7 @@ namespace Assets.Scenes.Ride.Scripts
//平均破度 //平均破度
slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%"; slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%";
//比赛开始时间 //比赛开始时间
StartTime.text = competition.StartTime.ToLocalTime().ToString()+"-"+ competition.EndApplyTime.ToLocalTime().ToString(); StartTime.text = competition.StartTime.ToLocalTime().ToString()+" TO "+ competition.EndApplyTime.ToLocalTime().ToString();
//比赛结束时间 //比赛结束时间
// EndTime.text = competition.EndTime.ToLocalTime().ToString(); // EndTime.text = competition.EndTime.ToLocalTime().ToString();
//比赛状态 //比赛状态
@ -282,6 +282,7 @@ namespace Assets.Scenes.Ride.Scripts
_canCancelApply = competition.CanCancelJoin; _canCancelApply = competition.CanCancelJoin;
_canWatch = competition.CanWatch; _canWatch = competition.CanWatch;
_raceStart = competition.Status == 3; _raceStart = competition.Status == 3;
_canEnter = competition.CanEnter;
Contestant.text = competition.UserList.Count.ToString() + "Riders"; Contestant.text = competition.UserList.Count.ToString() + "Riders";
ShowPlayers(competition.UserList); ShowPlayers(competition.UserList);

View File

@ -65,7 +65,7 @@ namespace Assets.Scenes.Ride.Scripts
if (rankingList == null) return; if (rankingList == null) return;
//当前参赛总人数 //当前参赛总人数
var totalCount = rankingList.Count(); var totalCount = rankingList.Count();
OnlineUserNum.text = totalCount.ToString(); OnlineUserNum.text = " "+totalCount.ToString();
//当前用户排名 //当前用户排名
var currentIndex = rankingList.Where(c => c.UserId == cyclingController.currentPlayer.UserId).FirstOrDefault()?.Index ?? 0; var currentIndex = rankingList.Where(c => c.UserId == cyclingController.currentPlayer.UserId).FirstOrDefault()?.Index ?? 0;
totalPages = (pageSize>0?totalCount / pageSize:0) + (totalCount % pageSize> 0? 1:0); totalPages = (pageSize>0?totalCount / pageSize:0) + (totalCount % pageSize> 0? 1:0);

View File

@ -16,7 +16,6 @@ namespace Assets.Scenes.Ride.Scripts
CompetitionModel competitionModel { get; set; } CompetitionModel competitionModel { get; set; }
CyclingController cyclingController { get; set; } CyclingController cyclingController { get; set; }
private void Start() private void Start()
{ {
cyclingController = FindObjectOfType<CyclingController>(); cyclingController = FindObjectOfType<CyclingController>();
@ -25,6 +24,7 @@ namespace Assets.Scenes.Ride.Scripts
TimerTitle = transform.Find("ConpetitionTimerTitle").GetComponent<Text>(); TimerTitle = transform.Find("ConpetitionTimerTitle").GetComponent<Text>();
Timer = transform.Find("ConpetitionTimer").GetComponent<Text>(); Timer = transform.Find("ConpetitionTimer").GetComponent<Text>();
competitionModel = cyclingController.cyclingController as CompetitionModel; competitionModel = cyclingController.cyclingController as CompetitionModel;
} }
GameObject competitionResultPanel { get; set; } GameObject competitionResultPanel { get; set; }
@ -46,10 +46,10 @@ namespace Assets.Scenes.Ride.Scripts
var isAutoSave = s.Item1 <= 0 && !cyclingController.cyclingController.recorderData.Saved && !cyclingController.isWatch; var isAutoSave = s.Item1 <= 0 && !cyclingController.cyclingController.recorderData.Saved && !cyclingController.isWatch;
//显示关门时间 //显示关门时间
if (s.Item2 && !isAutoSave) if (s.Item3 && !isAutoSave)
{ {
//显示倒计时面板信息 //显示倒计时面板信息
ShowCountDown(s.Item1, "Get The First Place. Time Limit"); ShowCountDown(s.Item1, "Get The First Place. Time Limit");
} }
else if (s.Item1 > 0) else if (s.Item1 > 0)
{ {
@ -60,7 +60,7 @@ namespace Assets.Scenes.Ride.Scripts
//显示当前选手骑行时间 //显示当前选手骑行时间
Timer.gameObject.SetActive(true); Timer.gameObject.SetActive(true);
TimerTitle.gameObject.SetActive(true); TimerTitle.gameObject.SetActive(true);
Timer.text = Helper.FormatTicks(cyclingController.currentPlayer.TotalTicks); Timer.text = Helper.FormatTicks(s.Item2);// Helper.FormatTicks(cyclingController.currentPlayer.TotalTicks);
} }
} }
} }

View File

@ -140,6 +140,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
HeartRate = item.HeartRate, HeartRate = item.HeartRate,
Cadence = item.Cadence, Cadence = item.Cadence,
TotalTicks = item.TotalTicks, TotalTicks = item.TotalTicks,
WeightKg = item.WeightKg,
}); });
} }
@ -367,27 +368,38 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
if (CanStart()) return 0; if (CanStart()) return 0;
return (int)Math.Floor((mapCompetition.StartTime.ToLocalTime() - Now).TotalSeconds); return (int)Math.Floor((mapCompetition.StartTime.ToLocalTime() - Now).TotalSeconds);
} }
public int RaceStartTime()
{
return (int)Math.Floor((Now - mapCompetition.StartTime.ToLocalTime() ).TotalSeconds);
}
/// <summary> /// <summary>
/// 结束倒计时,bool值为true说明倒计时是关门时间 /// 结束倒计时,bool值为true说明倒计时是关门时间
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public (int, bool) EndCountDown() public (int,int, bool) EndCountDown()
{ {
//if (CanStart() == false) return (0, false); //if (CanStart() == false) return (0, false);
//if (recorderData.IsCompleted) return 0; //if (recorderData.IsCompleted) return 0;
var end1 = (int)Math.Floor((mapCompetition.EndTime.ToLocalTime() - Now).TotalSeconds); var now = Now ;
var mi = now.Millisecond;
now = now.AddMilliseconds(-mi);
var end1 = (int)Math.Floor((mapCompetition.EndTime.ToLocalTime() - now).TotalSeconds);
var s = (int)Math.Floor((now - mapCompetition.EndTime.ToLocalTime()).TotalSeconds);
var start = (int)Math.Floor((now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
if (!FirstEndTime.HasValue) if (!FirstEndTime.HasValue)
{ {
return (end1, false); return (end1, start, false);
} }
//var end2 = (int)Math.Floor((FirstEndTime.Value - Now).TotalSeconds); //var end2 = (int)Math.Floor((FirstEndTime.Value - Now).TotalSeconds);
var end2 = (int)Math.Floor((FirstEndTime.Value.ToLocalTime().AddMinutes(mapCompetition.CloseTime) - Now).TotalSeconds); var end2 = (int)Math.Floor((FirstEndTime.Value.ToLocalTime().AddMinutes(mapCompetition.CloseTime) - Now).TotalSeconds);
if (end1 < end2) if (end1 < end2)
{ {
return (end1, false); return (end1, start, false);
} }
//return Math.Min(end1, end2); //return Math.Min(end1, end2);
return (end2, true); return (end2, start, true);
} }
} }
} }

View File

@ -224,6 +224,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
} }
catch (Exception ex) catch (Exception ex)
{ {
Helper.DelectDir(path);
Debug.Log(ex.Message); Debug.Log(ex.Message);
} }
recordData.Add(interruptRecord, files); recordData.Add(interruptRecord, files);
@ -249,7 +250,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
{ {
if (result.result && Directory.Exists(path)) if (result.result && Directory.Exists(path))
{ {
Helper.DelectDir(path); //Helper.DelectDir(path);
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -650,7 +650,6 @@ public class CyclingController : DeviceServiceMonoBase
//} //}
isStart = false; isStart = false;
isQuit = true; isQuit = true;
recorderData.EndTime = UIManager.Now.GetDateTime();
} }
#endregion #endregion
@ -677,7 +676,7 @@ public class CyclingController : DeviceServiceMonoBase
public void Save(double totalDistance) public void Save(double totalDistance)
{ {
//cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime(); cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
isQuit = true; isQuit = true;
isStart = false; isStart = false;
string recordId = Guid.NewGuid().ToString(); string recordId = Guid.NewGuid().ToString();

View File

@ -48,6 +48,7 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
UIManager.AddEvent(uploadBtn.gameObject, EventTriggerType.PointerClick, (b) => GoUplaod()); UIManager.AddEvent(uploadBtn.gameObject, EventTriggerType.PointerClick, (b) => GoUplaod());
UIManager.AddEvent(deleteBtn.gameObject, EventTriggerType.PointerClick, (b) => GoDelete()); UIManager.AddEvent(deleteBtn.gameObject, EventTriggerType.PointerClick, (b) => GoDelete());
var fileList = Directory.GetFiles(path); var fileList = Directory.GetFiles(path);
foreach (var item in fileList) foreach (var item in fileList)
{ {
var fileInfo = new FileInfo(item); var fileInfo = new FileInfo(item);
@ -75,6 +76,7 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
{ {
this.gameObject.SetActive(false); this.gameObject.SetActive(false);
} }
Name.text = record.RouteName; Name.text = record.RouteName;
Time.text = record.StartTime.ToString(); Time.text = record.StartTime.ToString();
RidingTime.text = $"<color={titleColor}>Riding time:</color>{record.Ticks}"; RidingTime.text = $"<color={titleColor}>Riding time:</color>{record.Ticks}";

View File

@ -127,6 +127,7 @@ public class ResultListController : MonoBehaviour
isEnd[scrollIndex] = false; isEnd[scrollIndex] = false;
pageIndex[scrollIndex] = 0; pageIndex[scrollIndex] = 0;
GetList(); GetList();
DisplayLocalRouteResult(contents[0], 0);//显示本地未上传成功的记录
} }
public void Reset() public void Reset()
@ -176,7 +177,6 @@ public class ResultListController : MonoBehaviour
{ {
isEnd[index] = false; isEnd[index] = false;
DisplayRouteResult(r.data, contents[index],index); DisplayRouteResult(r.data, contents[index],index);
DisplayLocalRouteResult(contents[index], index);//显示本地未上传成功的记录
scroll.transform.Find("Error").gameObject.SetActive(false); scroll.transform.Find("Error").gameObject.SetActive(false);
//DisplayRouteResult(r.data, matchContent); //DisplayRouteResult(r.data, matchContent);