消息通知bug&赛事界面调整
This commit is contained in:
1 parent
50fd9c3af6
commit
9ab8165630
15 files changed
+182
-93
No files matched your search
@@ -80,6 +80,7 @@ public class MainController : BaseScene
|
||||
t -= Time.deltaTime;
|
||||
while (t <= 0)
|
||||
{
|
||||
App.CurrentScene = "Main";
|
||||
UIManager.SendCompetitionStartMessage("Main");
|
||||
t = 1;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
private bool _canJoin = false;
|
||||
private bool _canStart = false;
|
||||
private bool _canWatch = false;
|
||||
private bool _canEnter = false;
|
||||
private RawImage CompetitionDesc { get; set; }
|
||||
private RawImage SponsorLogoImage { get; set; }
|
||||
private Text StartTime { get; set; }
|
||||
@@ -65,7 +66,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
GetReady.gameObject.SetActive(false);
|
||||
}
|
||||
var applyCount = (int)(competition.StartApplyTime.ToLocalTime() - UIManager.Now.GetDateTime()).TotalSeconds;
|
||||
if (count == 0 || applyCount == 0)
|
||||
var endApplyCount = (int)(competition.EndApplyTime.ToLocalTime() - UIManager.Now.GetDateTime()).TotalSeconds;
|
||||
|
||||
if (count == 0 || applyCount == 0 || endApplyCount == 0)
|
||||
{
|
||||
UpdateCompetition();
|
||||
}
|
||||
@@ -74,9 +77,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//2.观看按钮
|
||||
Watch.SetActive(_canWatch);
|
||||
//3.开始按钮
|
||||
rideNow.gameObject.SetActive(_canStart);
|
||||
rideNow.gameObject.SetActive(_canEnter);
|
||||
//4.详情按钮
|
||||
Detail.SetActive(!_canStart);
|
||||
Detail.SetActive(!_canEnter);
|
||||
//5.取消报名按钮 (比赛开始前可以取消报名)
|
||||
CancelJoin.SetActive(_canCancelApply);
|
||||
|
||||
@@ -118,8 +121,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
CompetitionTitle = panel.transform.Find("CompetitionName").GetComponent<Text>();
|
||||
CompetitionDesc = panel.transform.Find("CompetitionDesc").GetComponent<RawImage>();
|
||||
StartTime = panel.transform.Find("Time").GetComponent<Text>();
|
||||
EndTime = panel.transform.Find("EndTime").GetComponent<Text>();
|
||||
Contestant = panel.transform.Find("Contestant").GetComponent<Text>();
|
||||
//EndTime = panel.transform.Find("EndTime").GetComponent<Text>();
|
||||
Contestant = panel.transform.Find("ContestantTile").GetComponent<Text>();
|
||||
Watch = panel.transform.Find("Watch").gameObject;
|
||||
CancelJoin = panel.transform.Find("CancelJoin").gameObject;
|
||||
Detail = panel.transform.Find("Detail").gameObject;
|
||||
@@ -152,10 +155,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
competition = cyclingController.competition;
|
||||
//赛事状态按钮控制
|
||||
_canJoin = competition.CanJoin;
|
||||
_canStart = competition.CanStart;
|
||||
_canStart = competition.CanExit;
|
||||
_canCancelApply = competition.CanCancelJoin;//可以取消预约
|
||||
_raceStart = competition.Status == 3;
|
||||
_canWatch = competition.CanWatch;
|
||||
_canEnter = competition.CanEnter;
|
||||
#region 赛事基本信息
|
||||
//赛事名称
|
||||
CompetitionTitle.text = competition.Title;
|
||||
@@ -168,9 +172,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//平均破度
|
||||
slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%";
|
||||
//比赛开始时间
|
||||
StartTime.text = competition.StartTime.ToLocalTime().ToString();
|
||||
StartTime.text = competition.StartTime.ToLocalTime().ToString()+"-"+ competition.EndApplyTime.ToLocalTime().ToString();
|
||||
//比赛结束时间
|
||||
EndTime.text = competition.EndTime.ToLocalTime().ToString();
|
||||
// EndTime.text = competition.EndTime.ToLocalTime().ToString();
|
||||
//比赛状态
|
||||
CompetitionStatus.text = competition.StatusVlaue.ToString();
|
||||
//参赛选手
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
if (s.Item2 && !isAutoSave)
|
||||
{
|
||||
//显示倒计时面板信息
|
||||
ShowCountDown(s.Item1, "get the winner,end tance remains");
|
||||
ShowCountDown(s.Item1, "Get The First Place. Time Limit:");
|
||||
}
|
||||
else if (s.Item1 > 0)
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public void setUserId(int userId,string WxHeadImg)
|
||||
{
|
||||
_userId = userId;
|
||||
var isself = userId == cyclingController.currentPlayer.UserId;
|
||||
var isself = userId == cyclingController.currentPlayer.UserId && !cyclingController.isWatch;
|
||||
//头像根据是否是自己显示
|
||||
if (isself)
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Head.gameObject.SetActive(isself);
|
||||
//边框样式
|
||||
var color = isself ? WHITE : TRANSPARENT;
|
||||
outline.effectColor = color;
|
||||
//outline.effectColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scenes.Ride.Scripts.Model.CyclingModels;
|
||||
using Assets.Scripts;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -34,18 +35,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
rankingList = ss?.TopList;
|
||||
if (rankingList == null) return;
|
||||
|
||||
//删除
|
||||
var currentTopRankingList = FindObjectsOfType<TopRankingItem>();
|
||||
foreach (var o in currentTopRankingList)
|
||||
{
|
||||
var e = rankingList.Where(c => c.UserId == o.UserId).FirstOrDefault();
|
||||
if (e == null)
|
||||
{
|
||||
o.transform.gameObject.SetActive(false);//TODO:这里暂时不删除,删除对应的图片和脚本依赖这个对象;脚本提供一个dispose
|
||||
bufferSize--;
|
||||
}
|
||||
}
|
||||
|
||||
////删除
|
||||
//var currentTopRankingList = FindObjectsOfType<TopRankingItem>();
|
||||
//foreach (var o in currentTopRankingList)
|
||||
//{
|
||||
// var e = rankingList.Where(c => c.UserId == o.UserId).FirstOrDefault();
|
||||
// if (e == null)
|
||||
// {
|
||||
// o.transform.gameObject.SetActive(false);//TODO:这里暂时不删除,删除对应的图片和脚本依赖这个对象;脚本提供一个dispose
|
||||
// bufferSize--;
|
||||
// }
|
||||
//}
|
||||
Utils.DestroyChildren(parent);
|
||||
for (int i = 0; i < rankingList.Count(); i++)
|
||||
{
|
||||
Create(rankingList[i]);
|
||||
@@ -53,27 +54,30 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
private void Create(CompetitionTopModel item)
|
||||
{
|
||||
var rankingList = FindObjectsOfType<TopRankingItem>();
|
||||
var competitionRankingItem = rankingList.Where(c => c.rank == item.Index).FirstOrDefault();
|
||||
//如果当前有这个用户则更新没有则创建并setslibingindex
|
||||
if (competitionRankingItem == null)
|
||||
{
|
||||
//创建
|
||||
if (bufferSize < pageSize)
|
||||
{
|
||||
//情况一:还有足够的buffer,直接创建
|
||||
GameObject prefabItem = nearByItem;
|
||||
GameObject newObj = (GameObject)Instantiate(prefabItem, parent);
|
||||
competitionRankingItem = newObj.GetComponent<TopRankingItem>();
|
||||
bufferSize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//情况二:没有足够的buffer,找到要被淘汰的buffer()最后一名
|
||||
competitionRankingItem = rankingList.OrderByDescending(c => c.rank).FirstOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
//var rankingList = FindObjectsOfType<TopRankingItem>();
|
||||
//var competitionRankingItem = rankingList.Where(c => c.rank == item.Index).FirstOrDefault();
|
||||
////如果当前有这个用户则更新没有则创建并setslibingindex
|
||||
//if (competitionRankingItem == null)
|
||||
//{
|
||||
// //创建
|
||||
// if (bufferSize < pageSize)
|
||||
// {
|
||||
// //情况一:还有足够的buffer,直接创建
|
||||
// GameObject prefabItem = nearByItem;
|
||||
// GameObject newObj = (GameObject)Instantiate(prefabItem, parent);
|
||||
// competitionRankingItem = newObj.GetComponent<TopRankingItem>();
|
||||
// bufferSize++;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //情况二:没有足够的buffer,找到要被淘汰的buffer()最后一名
|
||||
// competitionRankingItem = rankingList.OrderByDescending(c => c.rank).FirstOrDefault();
|
||||
// }
|
||||
|
||||
//}
|
||||
GameObject newObj = (GameObject)Instantiate(nearByItem, parent);
|
||||
var competitionRankingItem = newObj.GetComponent<TopRankingItem>();
|
||||
|
||||
competitionRankingItem.setHead(item.Head);
|
||||
competitionRankingItem.setTimer(item.TripTime);
|
||||
competitionRankingItem.SetRank(item.Index);
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
|
||||
#region 骑行结束,比赛结果展示数据
|
||||
var results = new List<CompetitionResultModel>();
|
||||
if (recorderData.IsCompleted || recorderData.Saved || mapCompetition.HasRecord || CanQuit())
|
||||
if (recorderData.IsCompleted || recorderData.Saved || mapCompetition.HasRecord || CanShowTopList())
|
||||
{
|
||||
var users1 = userList.Where(d => d.IsCompleted || d.Saved);
|
||||
if ((users1.Any() && users1.Any(d => mapWorkoutRecordRankings.All(u => u.UserId != d.Id)))
|
||||
@@ -212,7 +212,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
|
||||
List<CompetitionTopModel> CompetitionTopList = new List<CompetitionTopModel>();
|
||||
|
||||
var resultList =results.Take(6);
|
||||
var resultList = results.Take(6);
|
||||
var count = 6 - resultList.Count();
|
||||
//先取比赛结果
|
||||
foreach (var item in resultList)
|
||||
@@ -321,6 +321,18 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
return end2 <= 0;
|
||||
}
|
||||
|
||||
public bool CanShowTopList()
|
||||
{
|
||||
var end1 = (int)Math.Floor((mapCompetition.EndTime.ToLocalTime() - Now).TotalSeconds);
|
||||
if (!FirstEndTime.HasValue)
|
||||
{
|
||||
return end1 <= 0;
|
||||
}
|
||||
|
||||
var end2 = (int)Math.Floor((FirstEndTime.Value.ToLocalTime() - Now).TotalSeconds);
|
||||
return end2 <= 0;
|
||||
}
|
||||
|
||||
public bool CanStart()
|
||||
{
|
||||
if (mapCompetition == null)
|
||||
|
||||
@@ -149,6 +149,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
if (timer <= 0)//定时器 一秒执行一次
|
||||
{
|
||||
TcpHandler();
|
||||
App.CurrentScene = "Ride";
|
||||
if (competitionId == 0)
|
||||
{
|
||||
UIManager.SendCompetitionStartMessage("Ride");
|
||||
|
||||
Reference in new issue
Block a user