轨迹插件引入

This commit is contained in:
lishuo committed 2022-09-06 13:47:45 +08:00
1 parent 89b5275efd
commit 195893a1b0
1023 files changed
+378944 -18404

No files matched your search

@@ -30,6 +30,7 @@ namespace Assets.Scripts.Scenes.Scripts
var list = MapUDPService.GetOnlineUsers(App.RouteIdParam, manager.roomId).OrderByDescending(c=>c.EndDistance);
int index = 1;
num.text = list.Count().ToString();
var current = list.Where(c => c.Id == manager.currentPlayer.UserId).FirstOrDefault();
foreach (var item in list)
{
GameObject prefabItem = item.IsSelf ? nearByMajorItem : nearByItem;
@@ -47,7 +48,7 @@ namespace Assets.Scripts.Scenes.Scripts
competitionRankingItem.setHead(item.HeadImage);
var countryTexture = manager.GetCountryImageByName(item.Country);
competitionRankingItem.setCountry(countryTexture);
var near = Math.Round((item.EndDistance - manager.currentPlayer.TotalDistance) * 1000);
var near = Math.Round((item.EndDistance - current.EndDistance)*1000,0);
competitionRankingItem.setDistance(manager.currentPlayer.UserId == item.Id ? "0M" : near.ToString() + "M");
#if UNITY_IOS || UNITY_ANDROID
competitionRankingItem.transform.SetSiblingIndex(index);
@@ -64,33 +65,7 @@ namespace Assets.Scripts.Scenes.Scripts
while (timer < 0)
{
InitData();
//if (manager.currentPlayer == null)
//var totalDitance = manager.GetMapData().TotalDistance;
//var currentDistance = manager.currentPlayer.TotalDistance;
////var currenList = GetComponentsInChildren<ListItem>(true);
//var list = MapUDPService.GetOnlineUsers(App.RouteIdParam, manager.cyclingController.recorderData.RoomId);
//var currentPlayerInfo = list.Where(c => c.Id.ToString() == manager.currentPlayer.UserId.ToString()).FirstOrDefault();
//list = list.Where(c => c.Id != App.CurrentUser.Id).ToList();
//var currentPlayer = FindObjectOfType<AbstractPlayer>();
//foreach (ListItem o in currenList)
//{
// if (currentPlayer.UserId.ToString() == o.Id)
// continue;
// var needUpdate = list.Where(c => c.Id.ToString() == o.Id).FirstOrDefault();
// if (needUpdate != null && currentPlayerInfo != null)
// {
// var left = Math.Round((needUpdate.EndDistance - currentPlayerInfo.EndDistance) * 1000);
// o.UpdateItem(needUpdate.Name, left.ToString() + "M", needUpdate.Id.ToString());
// o.gameObject.SetActive(true);
// }
// else
// {
// o.gameObject.SetActive(false);
// }
//}
timer += 1f;
timer += 1f;
}
}
}
@@ -22,6 +22,7 @@ namespace Assets.Scenes.Ride.Scripts
GameObject timerIcon { get; set; }
GameModel model { get; set; }
Text gameTimerText { get; set; }
protected override void Start()
{
base.Start();
@@ -40,7 +41,9 @@ namespace Assets.Scenes.Ride.Scripts
UIManager.AddEvent(raceViewBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, ChangeView);
spilitLineH2.SetActive(false);
//timerTxt.gameObject.SetActive(false);
timerTxt.gameObject.SetActive(false);
gameTimerText = uipanel.transform.Find("ComputerPanel/GameTimer").GetComponent<Text>();
gameTimerText.gameObject.SetActive(true);
//timerTxtTitle.gameObject.SetActive(false);
//观察者模式隐藏坡度
if (mainController.isWatch)
@@ -68,11 +71,23 @@ namespace Assets.Scenes.Ride.Scripts
public void StartRide(int seconds)
{
mainController.SetCyclingModel(CyclingModel.GameRoom);
count = seconds;
startPanel.SetActive(false);
startBtn.gameObject.SetActive(false);
countDownTxt.gameObject.SetActive(true);
countDownTxt.text = count.ToString();
//如果是重新连接的话就不需要倒计时
var ss = mainController.cyclingController.recorderData.RiderDatas;
if (ss.Count > 0)
{
count = 0;
startUI(0);
countDownTxt.gameObject.SetActive(true);
countDownTxt.text = count.ToString();
}
else
{
count = seconds;
countDownTxt.gameObject.SetActive(true);
countDownTxt.text = count.ToString();
}
}
bool canStart = false;
GameObject watchPanel { get; set; }
@@ -112,26 +127,16 @@ namespace Assets.Scenes.Ride.Scripts
if (timeRemaining <= 0)//定时器
{
count--;
if (count == 0)
{
mainController.SetStart();
var canvasGroup = countDownTxt.transform.GetComponent<CanvasGroup>();
canvasGroup.DOFade(0, 1).onComplete += () => {
countDownTxt.gameObject.SetActive(false);
canvasGroup.alpha = 1;
};
}
if (count == 1 && mainController.cyclingModel == CyclingModel.Single)
{
reviewPanel.GetComponent<CanvasGroup>().DOFade(0, 1).onComplete += () => {
reviewPanel.gameObject.SetActive(false);
};
}
countDownTxt.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f), 1, 1, 1);
timeRemaining = 1.0f;
startUI(count);
timeRemaining += 1.0f;
}
}
countDownTxt.text = count == 0 ? App.GetLocalString("GO!") : count.ToString();
if (mainController.isStart)
{
var ticks = playerController.TotalTicks;
gameTimerText.text = Helper.FormatTicks(ticks);
}
countDownTxt.text = count <= 0 ? App.GetLocalString("GO!") : count.ToString();
model = mainController.cyclingController as GameModel;
//第一名诞生开始倒计时,倒计时结束自动保存
if (model != null && model.FirstEndTime.HasValue && !FirstCompleted && App.CurrentUser.Id != model.FirstUserId)
@@ -152,6 +157,28 @@ namespace Assets.Scenes.Ride.Scripts
}
}
private void startUI(int num)
{
if (num <= 0)
{
mainController.SetStart();
var canvasGroup = countDownTxt.transform.GetComponent<CanvasGroup>();
canvasGroup.DOFade(0, 1).onComplete += () => {
countDownTxt.gameObject.SetActive(false);
canvasGroup.alpha = 1;
};
}
if (num == 1 && mainController.cyclingModel == CyclingModel.Single)
{
reviewPanel.GetComponent<CanvasGroup>().DOFade(0, 1).onComplete += () => {
reviewPanel.gameObject.SetActive(false);
};
}
countDownTxt.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f), 1, 1, 1);
countDownTxt.text = num <= 0 ? App.GetLocalString("GO!") : num.ToString();
model = mainController.cyclingController as GameModel;
}
private bool FirstCompleted;
private bool Saved;
@@ -279,6 +279,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
public class TempRecordData
{
public int RoomId { get; set; }
public int CompetitionId { get; set; }
public int UserId { get; set; }
public int RouteId { get; set; }
@@ -52,7 +52,7 @@ namespace Assets.Scenes.Ride.Scripts
protected double elevation;
protected double cadance;
protected int? heartRate { get; set; }
public int ticks;
public int ticks { get; set; }
protected double totalDistance;
protected double currentSlope;
protected double nextSlope;
@@ -106,6 +106,8 @@ public class CyclingController : DeviceServiceMonoBase
void OnDestroy()
{
App.RouteIdParam = 0;
App.tempRecordData = null;
TouchKit.removeAllGestureRecognizers();
Resources.UnloadUnusedAssets();
}
@@ -882,6 +884,11 @@ public class CyclingController : DeviceServiceMonoBase
{
tick = recorderData.RiderDatas.Last().Ticks;
}
//对战模式重连秒数按照现在的日期减去对战开始的日期
if (recorderData.RoomId > 0 && recorderData.RiderDatas.Count > 0)
{
tick = (int)(UIManager.Now.GetDateTime() - startTime).TotalSeconds;
}
playerController.Init(index, recorderData.EndDistance, tick);
}
public void InitGraph(int index)
@@ -1268,6 +1275,7 @@ public BaseUIManager singleUIManager;
tempRecordData.ManufacturerName = recorderData.ManufacturerName;
tempRecordData.Mode = cyclingModel.ToString();
tempRecordData.EndDistance = recorderData.EndDistance;
tempRecordData.RoomId = roomId;
var guid = recorderData.ContinueMark;
var filePath = PFConstants.MapWorkoutRecordTempFolder + "/" + guid.ToString()+".txt";
@@ -56,10 +56,10 @@ namespace Assets.Scenes.Ride.Scripts
cadance = mainController.UpdateCadence();
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
//#if !UNITY_EDITOR
power = 100;
//#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
#if UNITY_EDITOR
power = 100;
#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
}
catch (Exception ex)
{
@@ -113,7 +113,7 @@ namespace Assets.Scenes.Ride.Scripts
//实时计算MaxAp
//mainController.ComputeMaxAP(Power, ticks);
//实时保存骑行记录
if (ticks % 60 == 0 && !(mainController.cyclingController is GameModel))
if (ticks % 60 == 0)
{
mainController.SaveRealTime();
}