赛事loading页面按钮可用性调整
This commit is contained in:
parent
d4ae01cd32
commit
c9b5520331
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
cyclingController = controller;
|
cyclingController = controller;
|
||||||
//渲染比赛界面
|
//渲染比赛界面
|
||||||
panel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/CompetitonPanel"), transform);
|
panel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/CompetitonPanel"), transform);
|
||||||
|
panel.transform.SetAsFirstSibling();
|
||||||
PFUIPanel mainPanel = panel.GetComponent<PFUIPanel>();
|
PFUIPanel mainPanel = panel.GetComponent<PFUIPanel>();
|
||||||
PFUIPanel modelPanel = transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
PFUIPanel modelPanel = transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
||||||
CompetitionDesc = panel.transform.Find("CompetitionDesc").GetComponent<RawImage>();
|
CompetitionDesc = panel.transform.Find("CompetitionDesc").GetComponent<RawImage>();
|
||||||
@ -62,6 +63,18 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
GetReadyTitle.gameObject.SetActive(false);
|
GetReadyTitle.gameObject.SetActive(false);
|
||||||
GetReady.gameObject.SetActive(false);
|
GetReady.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//1.报名按钮
|
||||||
|
Apply.SetActive(_canJoin);
|
||||||
|
//2.观看按钮
|
||||||
|
var showWatch = !_canJoin && !_canStart && !_canCancelApply && _raceStart;
|
||||||
|
Watch.SetActive(showWatch);
|
||||||
|
//3.开始按钮
|
||||||
|
rideNow.gameObject.SetActive(_canStart);
|
||||||
|
//4.详情按钮
|
||||||
|
Detail.SetActive(!_canStart);
|
||||||
|
//5.取消报名按钮 (比赛开始前可以取消报名)
|
||||||
|
CancelJoin.SetActive(_canCancelApply && count > 0);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -76,6 +89,8 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
InitGameObject();
|
InitGameObject();
|
||||||
InitGameObjectData();
|
InitGameObjectData();
|
||||||
}
|
}
|
||||||
|
GameObject Detail { get; set; }
|
||||||
|
GameObject Apply { get; set; }
|
||||||
//构建赛事界面
|
//构建赛事界面
|
||||||
protected override void InitGameObject()
|
protected override void InitGameObject()
|
||||||
{
|
{
|
||||||
@ -85,6 +100,8 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
Contestant = panel.transform.Find("Contestant").GetComponent<Text>();
|
Contestant = panel.transform.Find("Contestant").GetComponent<Text>();
|
||||||
Watch = panel.transform.Find("Watch").gameObject;
|
Watch = panel.transform.Find("Watch").gameObject;
|
||||||
CancelJoin = panel.transform.Find("CancelJoin").gameObject;
|
CancelJoin = panel.transform.Find("CancelJoin").gameObject;
|
||||||
|
Detail = panel.transform.Find("Detail").gameObject;
|
||||||
|
Apply = panel.transform.Find("Apply").gameObject;
|
||||||
PlayersPanel = panel.transform.Find("PlayersPanel/List/Viewport/Content");
|
PlayersPanel = panel.transform.Find("PlayersPanel/List/Viewport/Content");
|
||||||
LeftBack = panel.transform.Find("LeftBack").gameObject;
|
LeftBack = panel.transform.Find("LeftBack").gameObject;
|
||||||
MiddleBack = panel.transform.Find("MiddleBack").gameObject;
|
MiddleBack = panel.transform.Find("MiddleBack").gameObject;
|
||||||
@ -95,10 +112,13 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
|
|
||||||
UIManager.AddEvent(ReadMore, EventTriggerType.PointerClick, ReadCompetitionPreview);
|
UIManager.AddEvent(ReadMore, EventTriggerType.PointerClick, ReadCompetitionPreview);
|
||||||
UIManager.AddEvent(Watch, EventTriggerType.PointerClick, StartWatch);
|
UIManager.AddEvent(Watch, EventTriggerType.PointerClick, StartWatch);
|
||||||
|
UIManager.AddEvent(Apply, EventTriggerType.PointerClick, ApplyRace);
|
||||||
UIManager.AddEvent(CancelJoin, EventTriggerType.PointerClick, CancelReserve);
|
UIManager.AddEvent(CancelJoin, EventTriggerType.PointerClick, CancelReserve);
|
||||||
|
UIManager.AddEvent(Detail, EventTriggerType.PointerClick, GoDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _canCancelApply = false;
|
private bool _canCancelApply = false;
|
||||||
|
private bool _raceStart = false;
|
||||||
//查询赛事相关数据
|
//查询赛事相关数据
|
||||||
protected override void InitGameObjectData()
|
protected override void InitGameObjectData()
|
||||||
{
|
{
|
||||||
@ -108,22 +128,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
_canJoin = competition.CanJoin;
|
_canJoin = competition.CanJoin;
|
||||||
_canStart = competition.CanStart;
|
_canStart = competition.CanStart;
|
||||||
_canCancelApply = competition.applyed;//可以取消预约
|
_canCancelApply = competition.applyed;//可以取消预约
|
||||||
//报名或者开始比赛
|
_raceStart = competition.Status == 3;
|
||||||
rideNowText.text = _canJoin ? "Apply" : "RideNow";
|
|
||||||
//观战
|
|
||||||
var showWatch = !_canJoin && !_canStart && !_canCancelApply;
|
|
||||||
Watch.SetActive(showWatch);
|
|
||||||
rideNow.gameObject.SetActive(!showWatch);
|
|
||||||
//取消预约
|
|
||||||
CancelJoin.SetActive(_canCancelApply);
|
|
||||||
//比赛结束
|
|
||||||
if (competition.Status == 4)
|
|
||||||
{
|
|
||||||
rideNow.gameObject.SetActive(false);
|
|
||||||
Watch.SetActive(false);
|
|
||||||
CancelJoin.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 赛事基本信息
|
#region 赛事基本信息
|
||||||
//赛事名称
|
//赛事名称
|
||||||
mapName.text = competition.Title;
|
mapName.text = competition.Title;
|
||||||
@ -186,12 +191,6 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//显示比赛详情图片:如果没有比赛详情图则显示地图
|
|
||||||
private void ShowCompetitionDescImage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetENStatus(string status)
|
private string GetENStatus(string status)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
@ -204,40 +203,6 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
#region 事件
|
#region 事件
|
||||||
//先报名后开始
|
|
||||||
protected override void StartRide(BaseEventData baseEvent)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//先报名
|
|
||||||
if (_canJoin)
|
|
||||||
{
|
|
||||||
MapCompetitionApi s = new MapCompetitionApi();
|
|
||||||
var rrr = s.ApplyMapCompetition(cyclingController.competitionId);
|
|
||||||
if (rrr.result)
|
|
||||||
{
|
|
||||||
//var competition = s.GetById(cyclingController.competitionId).data;
|
|
||||||
//_canStart = competition.CanStart;
|
|
||||||
_canJoin = false;
|
|
||||||
//取消预约
|
|
||||||
CancelJoin.SetActive(true);
|
|
||||||
}
|
|
||||||
//if (_canStart)
|
|
||||||
{
|
|
||||||
rideNowText.text = "RideNow";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
base.StartRide(baseEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//查看赛事详情
|
//查看赛事详情
|
||||||
protected void ReadCompetitionPreview(BaseEventData baseEvent)
|
protected void ReadCompetitionPreview(BaseEventData baseEvent)
|
||||||
@ -252,32 +217,100 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
cyclingController.player.SetActive(false);
|
cyclingController.player.SetActive(false);
|
||||||
base.StartRide(baseEvent);
|
base.StartRide(baseEvent);
|
||||||
}
|
}
|
||||||
|
protected void GoDetail(BaseEventData baseEvent)
|
||||||
|
{
|
||||||
|
Application.OpenURL(App.CurrentUser.WebHost + $"#/Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}");
|
||||||
|
}
|
||||||
|
protected void ApplyRace(BaseEventData baseEvent)
|
||||||
|
{
|
||||||
|
UIManager.ShowConfirm("Apply", "Are your want to Apply this race?", async () =>
|
||||||
|
{
|
||||||
|
MapCompetitionApi s = ConfigHelper.mapCompetitionApi;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.showToast(gameObject, rrr.errMsg);
|
||||||
|
}
|
||||||
|
rideNow.gameObject.SetActive(_canStart);
|
||||||
|
Detail.SetActive(!_canStart);
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
//取消预约
|
//取消预约
|
||||||
protected void CancelReserve(BaseEventData baseEvent)
|
protected void CancelReserve(BaseEventData baseEvent)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MapCompetitionApi api = new MapCompetitionApi();
|
UIManager.ShowConfirm("Canel Application", "Are you want to cancel this application?", async () =>
|
||||||
var result = api.CancelMapCompetition(cyclingController.competition.Id);
|
|
||||||
if (result.result)
|
|
||||||
{
|
{
|
||||||
rideNowText.text = "Apply";
|
MapCompetitionApi api = ConfigHelper.mapCompetitionApi;
|
||||||
CancelJoin.SetActive(false);
|
var data = api.CancelMapCompetition(cyclingController.competition.Id);
|
||||||
_canJoin = true;
|
if (data.result)
|
||||||
Debug.Log(result);
|
{
|
||||||
//SHOW Alert
|
var result = api.GetById(cyclingController.competitionId);
|
||||||
}
|
if (result.result == false || result.data == null)
|
||||||
else
|
{
|
||||||
{
|
Utils.showToast(gameObject, "error when get competition information");
|
||||||
Debug.Log(result);
|
return;
|
||||||
//SHOW Alert
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
competition = result.data;
|
||||||
|
_canStart = competition.CanStart;
|
||||||
|
_canJoin = competition.CanJoin;
|
||||||
|
_canCancelApply = competition.applyed;
|
||||||
|
|
||||||
|
UIManager.UpdateJoinCompetition();
|
||||||
|
Utils.showToast(gameObject, "success", 2, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.showToast(gameObject, data.errMsg);
|
||||||
|
}
|
||||||
|
UIManager.CloseConfirm();
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Log(ex);
|
Debug.Log(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Cancel(BaseEventData baseEvent)
|
||||||
|
{
|
||||||
|
if (App.MainSceneParam.ContainsKey("Name"))
|
||||||
|
{
|
||||||
|
App.MainSceneParam["Name"] = "RaceHomePanel";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
App.MainSceneParam.Add("Name", "RaceHomePanel");
|
||||||
|
}
|
||||||
|
base.Cancel(baseEvent);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,8 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
competitionRankingItem.setRatio(item.KGWeight + "W/KG");
|
competitionRankingItem.setRatio(item.KGWeight + "W/KG");
|
||||||
competitionRankingItem.setSpeed(item.Speed.ToString() + "KM/H");
|
competitionRankingItem.setSpeed(item.Speed.ToString() + "KM/H");
|
||||||
competitionRankingItem.setHead(item.Headimage);
|
competitionRankingItem.setHead(item.Headimage);
|
||||||
competitionRankingItem.setCountry(item.CountryImg);
|
var countryTexture = cyclingController.GetCountryImageByName(item.CountryImg);
|
||||||
|
competitionRankingItem.setCountry(countryTexture);
|
||||||
competitionRankingItem.setDistance(currentPlayer.UserId == item.UserId?"0KM": item.Near.ToString() + "KM");
|
competitionRankingItem.setDistance(currentPlayer.UserId == item.UserId?"0KM": item.Near.ToString() + "KM");
|
||||||
competitionRankingItem.transform.SetSiblingIndex(item.Index);
|
competitionRankingItem.transform.SetSiblingIndex(item.Index);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,9 +96,9 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountry(string url)
|
public void setCountry(Texture texture)
|
||||||
{
|
{
|
||||||
Utils.DisplayImage(Country, url, true);
|
Country.texture = texture;
|
||||||
}
|
}
|
||||||
public void setName(string name)
|
public void setName(string name)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -164,19 +164,26 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
|
|
||||||
protected override void StopRide(BaseEventData baseEventData)
|
protected override void StopRide(BaseEventData baseEventData)
|
||||||
{
|
{
|
||||||
//观察者
|
if (!App.MainSceneParam.ContainsKey("Name"))
|
||||||
|
{
|
||||||
|
App.MainSceneParam.Add("Name", "RaceHomePanel");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
App.MainSceneParam["Name"] = "RaceHomePanel";
|
||||||
|
}
|
||||||
if (mainController.isWatch)
|
if (mainController.isWatch)
|
||||||
{
|
{
|
||||||
quitPanel.SetActive(true);
|
UIManager.ShowConfirm("Quit", "Are you want to quit?", async () =>
|
||||||
var content=quitPanel.transform.Find("Content").GetComponent<Text>();
|
{
|
||||||
content.text = "Do you want to quit?";
|
SceneManager.LoadScene("MainScene");
|
||||||
quitPanel.transform.Find("AbandonButton").gameObject.SetActive(false);
|
UIManager.CloseConfirm();
|
||||||
quitPanel.transform.Find("SaveButton/Text").GetComponent<Text>().text = "OK";
|
});
|
||||||
}
|
}
|
||||||
//参赛者:提醒是否退出并保存赛事结果
|
//参赛者:提醒是否退出并保存赛事结果
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
quitPanel.SetActive(true);
|
base.StopRide(baseEventData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,7 +153,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
|||||||
Near = near,
|
Near = near,
|
||||||
KGWeight = Math.Round(item.WeightKg, 2).ToString(),
|
KGWeight = Math.Round(item.WeightKg, 2).ToString(),
|
||||||
Speed = Math.Round(item.Speed, 1),
|
Speed = Math.Round(item.Speed, 1),
|
||||||
CountryImg = ConfigHelper.Host + $"User/GetCountryImg?userid={ item.Id }",
|
CountryImg = item.Country,//ConfigHelper.Host + $"User/GetCountryImg?userid={ item.Id }",
|
||||||
UserId = item.Id,
|
UserId = item.Id,
|
||||||
IsSelf = item.IsSelf,
|
IsSelf = item.IsSelf,
|
||||||
Headimage =item.HeadImage
|
Headimage =item.HeadImage
|
||||||
|
|||||||
@ -187,7 +187,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
depressFlag = true;
|
depressFlag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void Cancel(BaseEventData baseEvent)
|
protected virtual void Cancel(BaseEventData baseEvent)
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene("MainScene");
|
SceneManager.LoadScene("MainScene");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public class RaceButtonGroupScript : MonoBehaviour
|
|||||||
parent.GetComponent<RaceItemScript>().Join();
|
parent.GetComponent<RaceItemScript>().Join();
|
||||||
}
|
}
|
||||||
App.RouteIdParam = map.RouteId;
|
App.RouteIdParam = map.RouteId;
|
||||||
|
UIManager.UpdateJoinCompetition();
|
||||||
UIManager.CloseConfirm();
|
UIManager.CloseConfirm();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -58,6 +59,7 @@ public class RaceButtonGroupScript : MonoBehaviour
|
|||||||
if (map.HasJoin)
|
if (map.HasJoin)
|
||||||
{
|
{
|
||||||
parent.GetComponent<RaceItemScript>().CancelJoin();
|
parent.GetComponent<RaceItemScript>().CancelJoin();
|
||||||
|
UIManager.UpdateJoinCompetition();
|
||||||
}
|
}
|
||||||
UIManager.CloseConfirm();
|
UIManager.CloseConfirm();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user