赛事loading页面状态实时变化和一些微调

This commit is contained in:
lishuo committed 2021-07-27 19:34:33 +08:00
1 parent ea79b6cfc5
commit 0eb399be9a
16 files changed
+4074 -2881

No files matched your search

@@ -63,7 +63,11 @@ namespace Assets.Scenes.Ride.Scripts
GetReadyTitle.gameObject.SetActive(false);
GetReady.gameObject.SetActive(false);
}
var applyCount = (int)(competition.StartApplyTime.ToLocalTime() - UIManager.Now.GetDateTime()).TotalSeconds;
if (count == 0 || applyCount == 0)
{
UpdateCompetition();
}
//1.报名按钮
Apply.SetActive(_canJoin);
//2.观看按钮
@@ -141,7 +145,7 @@ namespace Assets.Scenes.Ride.Scripts
//比赛开始时间
StartTime.text = competition.StartTime.ToLongTimeString();
//比赛状态
CompetitionStatus.text = GetENStatus(competition.StatusVlaue.ToString());
CompetitionStatus.text = competition.StatusVlaue.ToString();
//参赛选手
Contestant.text = competition.UserList.Count.ToString() + "Players";
ShowPlayers(competition.UserList);
@@ -191,17 +195,6 @@ namespace Assets.Scenes.Ride.Scripts
}
}
}
private string GetENStatus(string status)
{
switch (status)
{
case "已结束": return "DONE";
case "未开始": return "APPLIED";
case "报名中": return "APPLLYING";
case "比赛中": return "RACING";
}
return "";
}
#region 事件
//查看赛事详情
@@ -221,6 +214,24 @@ namespace Assets.Scenes.Ride.Scripts
{
Application.OpenURL(App.CurrentUser.WebHost + $"#/Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}");
}
private void UpdateCompetition()
{
MapCompetitionApi s = ConfigHelper.mapCompetitionApi;
var result = s.GetById(cyclingController.competitionId);
if (result.result == false || result.data == null)
{
Utils.showToast(gameObject, "error when get competition information");
return;
}
else
{
competition = result.data;
_canStart = competition.CanStart;
_canJoin = competition.CanJoin;
_canCancelApply = competition.applyed;
}
}
protected void ApplyRace(BaseEventData baseEvent)
{
UIManager.ShowConfirm("Apply", "Are your want to Apply this race?", async () =>
@@ -229,22 +240,9 @@ namespace Assets.Scenes.Ride.Scripts
var rrr = s.ApplyMapCompetition(cyclingController.competitionId);
if (rrr.result)
{
var result = s.GetById(cyclingController.competitionId);
if (result.result == false || result.data == null)
{
Utils.showToast(gameObject, "error when get competition information");
return;
}
else
{
competition = result.data;
_canStart = competition.CanStart;
_canJoin = competition.CanJoin;
_canCancelApply = competition.applyed;
UIManager.UpdateJoinCompetition();
Utils.showToast(gameObject, "success", 2, 1);
}
UpdateCompetition();
UIManager.UpdateJoinCompetition();
Utils.showToast(gameObject, "success", 2, 1);
}
else
{
@@ -268,22 +266,9 @@ namespace Assets.Scenes.Ride.Scripts
var data = api.CancelMapCompetition(cyclingController.competition.Id);
if (data.result)
{
var result = api.GetById(cyclingController.competitionId);
if (result.result == false || result.data == null)
{
Utils.showToast(gameObject, "error when get competition information");
return;
}
else
{
competition = result.data;
_canStart = competition.CanStart;
_canJoin = competition.CanJoin;
_canCancelApply = competition.applyed;
UIManager.UpdateJoinCompetition();
Utils.showToast(gameObject, "success", 2, 1);
}
UpdateCompetition();
UIManager.UpdateJoinCompetition();
Utils.showToast(gameObject, "success", 2, 1);
}
else
{
@@ -23,6 +23,11 @@ namespace Assets.Scenes.Ride.Scripts
reviewPanel.SetActive(false);
//隐藏单人骑行时间
var spilitLineH2 = transform.Find("Panel/ComputerPanel/SpilitLineH2").gameObject;
var raceViewBtn = transform.Find("Panel/RaceViewButton").gameObject;
raceViewBtn.SetActive(true);
viewButton.gameObject.SetActive(false);
UIManager.AddEvent(raceViewBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, ChangeView);
spilitLineH2.SetActive(false);
timerTxt.gameObject.SetActive(false);
timerTxtTitle.gameObject.SetActive(false);
@@ -55,7 +60,6 @@ namespace Assets.Scenes.Ride.Scripts
public override void StartRide()
{
competitionModel = mainController.cyclingController as CompetitionModel;
countDownPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/CountDownPanel"), transform.Find("Panel"));
title = countDownPanel.transform.Find("Title").GetComponent<Text>();
timer = countDownPanel.transform.Find("Timer").GetComponent<Text>();
@@ -61,11 +61,13 @@ namespace Assets.Scenes.Ride.Scripts
competitionRankingItem = rankingList.OrderByDescending(c => c.rank).FirstOrDefault();
}
}
competitionRankingItem.setHead(item.Head);
competitionRankingItem.setTimer(item.TripTime);
competitionRankingItem.SetRank(item.Index);
competitionRankingItem.setName(item.Name);
competitionRankingItem.setUserId(item.UserId);
competitionRankingItem.setCountry(item.Country);
var countryTexture = cyclingController.GetCountryImageByName(item.Country);
competitionRankingItem.setCountry(countryTexture);
competitionRankingItem.transform.SetSiblingIndex(item.Index);
}
}
@@ -56,12 +56,9 @@ namespace Assets.Scenes.Ride.Scripts
}
}
public void setCountry(string url)
public void setCountry(Texture texture)
{
if (!string.IsNullOrEmpty(url))
{
Utils.DisplayImage(Country, url, true);
}
Country.texture = texture;
}
public void setName(string name)
{
@@ -94,6 +94,10 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
{
try
{
if (recorderData.Saved)
{
return;
}
if (recorderData.RiderDatas.Any())
{
var lastData = recorderData.RiderDatas.Last();
@@ -223,7 +223,8 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
TripTime = item.TripTime,
Country = item.Country,
Name = item.Name,
UserId = item.UserId
UserId = item.UserId,
Head = item.WxHeadImg,
});
}
@@ -238,7 +239,8 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
TripTime = "———",
Country = item.CountryImg,
Name = item.Name,
UserId = item.UserId
UserId = item.UserId,
Head = item.Headimage,
});
}
}
@@ -85,6 +85,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
public string Country { get; set; }
public string Head { get; set; }
public string TripTime { get; set; }
}
@@ -43,7 +43,7 @@ public class CyclingController : DeviceServiceMonoBase
public List<MapRouteRanking> mapRouteRankingList { get; set; }
private Vector2d coordiantes;//当前地图中心
public bool isStart;//当前游戏是否开始
public bool isStart { get; set; }//当前游戏是否开始
public CyclingModel cyclingModel { get; set; }//当前骑行模式
public BaseCycling cyclingController { get; set; }
private int routeId;
@@ -684,7 +684,6 @@ public class CyclingController : DeviceServiceMonoBase
string imageFileName = path +"/"+ Guid.NewGuid().ToString() + ".png";
CaptureCamera(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f), imageFileName);
cyclingController.recorderData.StartTime = startTime;
cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
cyclingController.recorderData.IsCompleted = totalDistance == mapData.TotalDistance;