赛事功能完善
创建比赛按钮;loading页面more按钮等
This commit is contained in:
1 parent
eed2d13624
commit
e76b5c443f
55 files changed
+7805
-3376
No files matched your search
@@ -51,7 +51,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
protected double elevation;
|
||||
protected double cadance;
|
||||
protected int heartRate;
|
||||
protected int ticks;
|
||||
public int ticks;
|
||||
protected double totalDistance;
|
||||
protected double currentSlope;
|
||||
protected double nextSlope;
|
||||
@@ -166,7 +166,19 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
ticks++;
|
||||
Compute();//接受蓝牙设备数据计算
|
||||
|
||||
//计算累计爬升
|
||||
if (CurrentIndex > 0)
|
||||
{
|
||||
totalClimb = 0;
|
||||
for (int i = 1; i <= CurrentIndex; i++)
|
||||
{
|
||||
var diff = mapData.List[i].Elevation - mapData.List[i - 1].Elevation;
|
||||
if (diff > 0)
|
||||
{
|
||||
totalClimb += diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalDistance > mapData.TotalDistance)
|
||||
{
|
||||
distance = totalDistance - mapData.TotalDistance;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
protected int totalPages = 0;
|
||||
protected int bufferSize = 0;
|
||||
protected int pageIndex = 1;
|
||||
protected int pageSize = 7;
|
||||
protected int pageSize = 5;
|
||||
private int preNum = 0;//前面的数量
|
||||
private int offset = 8;//显示区域的数量
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
protected Text speedTxt;//当前速度
|
||||
protected Text powerTxt;//功率
|
||||
protected Text timerTxt;//计时器
|
||||
protected Text timerTxtTitle;//计时器标题
|
||||
protected Text ditance;//当前骑行距离
|
||||
protected Text totalDistance;//当前骑行距离
|
||||
protected Text candance;//踏频
|
||||
@@ -132,6 +133,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
speedTxt = transform.Find("Panel/ComputerPanel/Speed").GetComponent<Text>();
|
||||
powerTxt = transform.Find("Panel/PowerPanel/Power").GetComponent<Text>();
|
||||
timerTxt = transform.Find("Panel/ComputerPanel/Timer").GetComponent<Text>();
|
||||
timerTxtTitle = transform.Find("Panel/ComputerPanel/TimerTitle").GetComponent<Text>();
|
||||
countDownTxt = transform.Find("Panel/CountDown").GetComponent<Text>();
|
||||
mapName = transform.Find("Panel/TitlePanel/MapName").GetComponent<Text>();
|
||||
totalClimb = transform.Find("Panel/ComputerPanel/TotalClimb").GetComponent<Text>();
|
||||
@@ -159,10 +161,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
singleArea = transform.Find("Panel/ReviewPanel/SingleArea").gameObject;
|
||||
addButton = transform.Find("Panel/ReviewPanel/SingleArea/AddButton").GetComponent<Button>();
|
||||
|
||||
saveButton = transform.Find("Panel/QuitPanel/QuitPanel/SaveButton").GetComponent<Button>();
|
||||
cancelQuitButton = transform.Find("Panel/QuitPanel/QuitPanel/CancelButton").GetComponent<Button>();
|
||||
closeQuitButton = transform.Find("Panel/QuitPanel/QuitPanel/CloseButton").GetComponent<Button>();
|
||||
abandonButton = transform.Find("Panel/QuitPanel/QuitPanel/AbandonButton").GetComponent<Button>();
|
||||
saveButton = transform.Find("Panel/QuitPanel/SaveButton").GetComponent<Button>();
|
||||
cancelQuitButton = transform.Find("Panel/QuitPanel/CancelButton").GetComponent<Button>();
|
||||
closeQuitButton = transform.Find("Panel/QuitPanel/CloseButton").GetComponent<Button>();
|
||||
abandonButton = transform.Find("Panel/QuitPanel/AbandonButton").GetComponent<Button>();
|
||||
|
||||
viewButton = transform.Find("Panel/ViewButton").GetComponent<Button>();
|
||||
altitudeGraph = transform.Find("Panel/TitlePanel/AltitudeGraph").GetComponent<RawImage>();
|
||||
@@ -436,7 +438,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
mainController.ChangeMapImageStyle(arrow.gameObject);
|
||||
}
|
||||
//结束游戏
|
||||
public virtual void StopRide(BaseEventData baseEventData)
|
||||
protected virtual void StopRide(BaseEventData baseEventData)
|
||||
{
|
||||
if (playerController?.TotalTicks > 0)
|
||||
{
|
||||
@@ -458,9 +460,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
settingPanel.SetActive(true);
|
||||
}
|
||||
//进入简约模式
|
||||
int isSimple = 1;
|
||||
private bool clearLock = true;
|
||||
public void ClearPanel(BaseEventData baseEventData)
|
||||
protected int isSimple = 1;
|
||||
protected bool clearLock = true;
|
||||
protected virtual void ClearPanel(BaseEventData baseEventData)
|
||||
{
|
||||
if (clearLock)
|
||||
{
|
||||
@@ -486,7 +488,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
//初始化海拔图
|
||||
GraphChartBase graph;
|
||||
ChartDataSourceScript chartDataSourceScript;
|
||||
protected ChartDataSourceScript chartDataSourceScript;
|
||||
public void RenderChart()
|
||||
{
|
||||
var mapData = mainController.GetMapData();
|
||||
|
||||
@@ -30,6 +30,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
return graph.HorizontalScrolling / mData.Count();
|
||||
}
|
||||
|
||||
public double GetCurrentStart(int currentIndex)
|
||||
{
|
||||
int i = currentIndex / targetPoints;
|
||||
int max = mData.Count() - targetPoints;
|
||||
var current = i * targetPoints;
|
||||
if (current >= max)
|
||||
{
|
||||
return current - targetPoints > 0? current - targetPoints : 0;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public double GetRealTimeEnd()
|
||||
{
|
||||
return (graph.HorizontalScrolling+ graph.DataSource.HorizontalViewSize) / mData.Count();
|
||||
|
||||
@@ -306,7 +306,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
case CyclingModel.Review:
|
||||
cyclingController = new ReviewModel(route, selectParamModel);
|
||||
break;
|
||||
//TODO:比赛模式
|
||||
case CyclingModel.Competition:
|
||||
cyclingController = new CompetitionModel(route, selectParamModel, currentPlayer);
|
||||
break;
|
||||
@@ -337,7 +336,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
item.transform.localScale = MIN_SIZE;
|
||||
}
|
||||
//重置海拔图进度
|
||||
graph.HorizontalScrolling = 0;
|
||||
var currentIndex = currentPlayer.CurrentIndex;
|
||||
graph.HorizontalScrolling = chartDataSourceScript.GetCurrentStart(currentIndex);
|
||||
}
|
||||
public void ChangeRandomPlayer()
|
||||
{
|
||||
@@ -398,7 +398,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController.Run(null);
|
||||
//在线人物或比赛人物渲染
|
||||
ShowOnlineUsers();
|
||||
ShowWatchers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +429,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
onlinePlayerController.UserId = onlineRider.UserId;
|
||||
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude),index);
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude),index);
|
||||
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
||||
//小地图人物
|
||||
GameObject miniPlayer = (GameObject)Instantiate(miniMapPlayerPrefab, transform);
|
||||
@@ -443,7 +442,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index);
|
||||
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index);
|
||||
}
|
||||
//如果是观察者且当前第一此进入场景(TODO:这样切换会闪一下待解决)
|
||||
if (isWatch && currentPlayer is PlayerController)
|
||||
@@ -478,16 +477,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
if (bakePlayer != null)
|
||||
bakePlayer.IsShowInfo = true;
|
||||
}
|
||||
GameObject watcherList { get; set; }
|
||||
//当前比赛观看者
|
||||
private void ShowWatchers()
|
||||
{
|
||||
if (watcherList == null)
|
||||
{
|
||||
watcherList = Resources.Load<GameObject>("UI/Prefab/Match/WatcherPanel");
|
||||
watcherList = Instantiate(watcherList, uiParent);
|
||||
}
|
||||
}
|
||||
|
||||
//查询赛事观看者列表(取前5)
|
||||
public List<OnlineUser> GetWatcherList()
|
||||
{
|
||||
@@ -575,6 +565,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
arrowGameObj.SetActive(true);
|
||||
Is3dView = false;
|
||||
}
|
||||
|
||||
ChangeCurrentPlayer(currentPlayer.UserId);
|
||||
}
|
||||
private bool lockView = false;
|
||||
private void Map_OnTileFinished(Mapbox.Unity.MeshGeneration.Data.UnityTile obj)
|
||||
@@ -642,11 +634,14 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//退出或者完成骑行
|
||||
public void SetQuit()
|
||||
{
|
||||
//耗时巨大的代码
|
||||
sw.Stop();
|
||||
TimeSpan ts2 = sw.Elapsed;
|
||||
UnityEngine.Debug.Log(string.Format("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds));
|
||||
//TODO后算接口需要增加累计毫秒字段
|
||||
//耗时巨大的代码
|
||||
if (sw != null)
|
||||
{
|
||||
sw.Stop();
|
||||
TimeSpan ts2 = (TimeSpan)(sw.Elapsed);
|
||||
UnityEngine.Debug.Log(string.Format("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds));
|
||||
//TODO后算接口需要增加累计毫秒字段
|
||||
}
|
||||
isStart = false;
|
||||
isQuit = true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
double diff = 0;
|
||||
public void SetDataSource(double _totalDistance, double _distance,string Name,double weightKg,Vector2d point,int index=0)
|
||||
public void SetDataSource(double _totalDistance, double _distance, double _power, double _heartRate, double _cadence,int _totalTicks, string Name,double weightKg,Vector2d point,int index=0)
|
||||
{
|
||||
totalDistance = _totalDistance;
|
||||
distance = _distance;
|
||||
@@ -73,6 +73,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
CurrentIndex = index;
|
||||
//Point = point;
|
||||
currentlatlong = point;
|
||||
heartRate = Convert.ToInt32( _heartRate);
|
||||
power = Convert.ToInt32(_power);
|
||||
cadance = _cadence;
|
||||
ticks = _totalTicks;
|
||||
}
|
||||
|
||||
public Vector2d Point { get; set; }
|
||||
@@ -281,7 +285,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color transparent = new Color(0.1529412f, 0.8745098f, 0.8901961f, 0);
|
||||
Color blue = new Color(0.1529412f, 0.8745098f, 0.8901961f, 1);
|
||||
private void MoveGraghHead4Race()
|
||||
{
|
||||
MoveHead();
|
||||
@@ -289,12 +294,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//如果切换到当前用户,当前用户头像变大,并且只显示当前用户
|
||||
if (mainController.currentPlayer.UserId == UserId)
|
||||
{
|
||||
headPanel.SetActive(true);
|
||||
head.gameObject.SetActive(true);
|
||||
headPanel.GetComponent<Image>().color = blue;
|
||||
rect.DOScale(new Vector3(1.5f, 1.5f, 1.5f), 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.SetActive(false);
|
||||
head.gameObject.SetActive(false);
|
||||
headPanel.GetComponent<Image>().color = transparent;
|
||||
rect.DOScale(new Vector3(1f, 1f, 1f), 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user