倒计时的算法及界面调整
This commit is contained in:
1 parent
bea0e40ec1
commit
074200cb4f
16 files changed
+2714
-2596
No files matched your search
@@ -11,7 +11,7 @@ using Assets.Scripts.Devices;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//平均破度
|
||||
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();
|
||||
//比赛状态
|
||||
@@ -282,6 +282,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
_canCancelApply = competition.CanCancelJoin;
|
||||
_canWatch = competition.CanWatch;
|
||||
_raceStart = competition.Status == 3;
|
||||
_canEnter = competition.CanEnter;
|
||||
|
||||
Contestant.text = competition.UserList.Count.ToString() + "Riders";
|
||||
ShowPlayers(competition.UserList);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
if (rankingList == null) return;
|
||||
//当前参赛总人数
|
||||
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;
|
||||
totalPages = (pageSize>0?totalCount / pageSize:0) + (totalCount % pageSize> 0? 1:0);
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
CompetitionModel competitionModel { get; set; }
|
||||
CyclingController cyclingController { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cyclingController = FindObjectOfType<CyclingController>();
|
||||
@@ -25,6 +24,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
TimerTitle = transform.Find("ConpetitionTimerTitle").GetComponent<Text>();
|
||||
Timer = transform.Find("ConpetitionTimer").GetComponent<Text>();
|
||||
competitionModel = cyclingController.cyclingController as CompetitionModel;
|
||||
|
||||
}
|
||||
GameObject competitionResultPanel { get; set; }
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
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)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//显示当前选手骑行时间
|
||||
Timer.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
HeartRate = item.HeartRate,
|
||||
Cadence = item.Cadence,
|
||||
TotalTicks = item.TotalTicks,
|
||||
WeightKg = item.WeightKg,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -367,27 +368,38 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
if (CanStart()) return 0;
|
||||
return (int)Math.Floor((mapCompetition.StartTime.ToLocalTime() - Now).TotalSeconds);
|
||||
}
|
||||
|
||||
public int RaceStartTime()
|
||||
{
|
||||
return (int)Math.Floor((Now - mapCompetition.StartTime.ToLocalTime() ).TotalSeconds);
|
||||
}
|
||||
/// <summary>
|
||||
/// 结束倒计时,bool值为true说明倒计时是关门时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (int, bool) EndCountDown()
|
||||
public (int,int, bool) EndCountDown()
|
||||
{
|
||||
//if (CanStart() == false) return (0, false);
|
||||
//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)
|
||||
{
|
||||
return (end1, false);
|
||||
return (end1, start, false);
|
||||
}
|
||||
//var end2 = (int)Math.Floor((FirstEndTime.Value - Now).TotalSeconds);
|
||||
var end2 = (int)Math.Floor((FirstEndTime.Value.ToLocalTime().AddMinutes(mapCompetition.CloseTime) - Now).TotalSeconds);
|
||||
if (end1 < end2)
|
||||
{
|
||||
return (end1, false);
|
||||
return (end1, start, false);
|
||||
}
|
||||
//return Math.Min(end1, end2);
|
||||
return (end2, true);
|
||||
return (end2, start, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Helper.DelectDir(path);
|
||||
Debug.Log(ex.Message);
|
||||
}
|
||||
recordData.Add(interruptRecord, files);
|
||||
@@ -249,7 +250,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
{
|
||||
if (result.result && Directory.Exists(path))
|
||||
{
|
||||
Helper.DelectDir(path);
|
||||
//Helper.DelectDir(path);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -650,7 +650,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//}
|
||||
isStart = false;
|
||||
isQuit = true;
|
||||
recorderData.EndTime = UIManager.Now.GetDateTime();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -677,7 +676,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
public void Save(double totalDistance)
|
||||
{
|
||||
//cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
|
||||
cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
|
||||
isQuit = true;
|
||||
isStart = false;
|
||||
string recordId = Guid.NewGuid().ToString();
|
||||
|
||||
@@ -48,6 +48,7 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
UIManager.AddEvent(uploadBtn.gameObject, EventTriggerType.PointerClick, (b) => GoUplaod());
|
||||
UIManager.AddEvent(deleteBtn.gameObject, EventTriggerType.PointerClick, (b) => GoDelete());
|
||||
var fileList = Directory.GetFiles(path);
|
||||
|
||||
foreach (var item in fileList)
|
||||
{
|
||||
var fileInfo = new FileInfo(item);
|
||||
@@ -73,8 +74,9 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
var isself = record.UserId == App.CurrentUser.Id;
|
||||
if (!isself)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
Name.text = record.RouteName;
|
||||
Time.text = record.StartTime.ToString();
|
||||
RidingTime.text = $"<color={titleColor}>Riding time:</color>{record.Ticks}";
|
||||
|
||||
@@ -127,6 +127,7 @@ public class ResultListController : MonoBehaviour
|
||||
isEnd[scrollIndex] = false;
|
||||
pageIndex[scrollIndex] = 0;
|
||||
GetList();
|
||||
DisplayLocalRouteResult(contents[0], 0);//显示本地未上传成功的记录
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -176,7 +177,6 @@ public class ResultListController : MonoBehaviour
|
||||
{
|
||||
isEnd[index] = false;
|
||||
DisplayRouteResult(r.data, contents[index],index);
|
||||
DisplayLocalRouteResult(contents[index], index);//显示本地未上传成功的记录
|
||||
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||
//DisplayRouteResult(r.data, matchContent);
|
||||
|
||||
|
||||
Reference in new issue
Block a user