优化赛事人数多卡的问题&解决蓝牙连接133错误码

This commit is contained in:
lishuo committed 2021-09-24 19:16:40 +08:00
1 parent 1c73701e73
commit 65e7d9c4f4
272 files changed
+19674 -44

No files matched your search

@@ -71,7 +71,6 @@ namespace Assets.Scenes.Ride.Scripts
int index = 0;
protected override void CreateList()
{
index = 0;
CompetitionModel s = cyclingController.cyclingController as CompetitionModel;
var ss = s?.competitionRankingModel;
rankingList = ss?.Sorts;
@@ -97,6 +96,10 @@ namespace Assets.Scenes.Ride.Scripts
//当前用户在第几页
pageIndex = (pageSize > 0 ? currentIndex / pageSize : 1) + (currentIndex % pageSize > 0 ? 1 : 0);
}
var p = pageIndex > 0 ? pageIndex : 1;
index = (p - 1) * pageSize;
Rank.text = $"{pageIndex}/{totalPages}";
var pagedList = rankingList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
//删除
@@ -126,21 +126,6 @@ namespace Assets.Scenes.Ride.Scripts
cyclingExcutor = mainController.cyclingController;
ComputeNextSlope();//计算下一个坡度相关数据
}
IEnumerator TestExcute()
{
while (true)
{
yield return new WaitForSeconds(1);
//CamControl();
timer -= Time.deltaTime;
if (timer <= 0)//定时器 一秒执行一次
{
BeforeRun();
Run();
timer = 1.0f;
}
}
}
protected virtual void Excute()
{
@@ -180,7 +165,7 @@ namespace Assets.Scenes.Ride.Scripts
characterAnimator.SetBool("ReachEnd", true);//到达终点
}
}
Compute();//接受蓝牙设备数据计算
//开始骑行
if (GetStart())
{
@@ -188,7 +173,8 @@ namespace Assets.Scenes.Ride.Scripts
{
ticks++;
}
Compute();//接受蓝牙设备数据计算
totalDistance += distance;
if (totalDistance >= mapData.TotalDistance)
{
@@ -197,8 +183,8 @@ namespace Assets.Scenes.Ride.Scripts
}
ComputeNextSlope();//计算下一个坡度相关数据和累计爬升
Record();
//数据处理
Record();//数据处理
if (totalDistance >= mapData.TotalDistance)
{
stopRecord = true;
@@ -106,6 +106,48 @@ public class CyclingController : DeviceServiceMonoBase
Transform uiParent;
GameObject uipanel { get; set; }
GameObject onlineUserPrefab3d { get; set; }
GameObject OnlineHeadPanel { get; set; }
public GameObject GetOnlineheadPanel()
{
if (OnlineHeadPanel == null)
{
OnlineHeadPanel = Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel");
}
return OnlineHeadPanel;
}
Material Graph3d { get; set; }
public Material Get3dGraph2()
{
if (Graph3d == null)
{
Graph3d = Resources.Load<Material>("UI/Material/3dGraph2");
}
return Graph3d;
}
Image CompetitionArrow { get; set; }
public Image GetCompetitionArrow()
{
if (CompetitionArrow == null)
{
CompetitionArrow = Resources.Load<Image>("UI/Prefab/Match/CompetitionArrow");
}
return CompetitionArrow;
}
Image CompetitionMobileArrow { get; set; }
public Image GetCompetitionMobileArrow()
{
if (CompetitionMobileArrow == null)
{
CompetitionMobileArrow = Resources.Load<Image>("UI/Prefab/Match/Mobile/CompetitionArrow");
}
return CompetitionMobileArrow;
}
private void Start()
{
var uicanvasScaler = UIObject.GetComponent<CanvasScaler>();
@@ -130,7 +172,8 @@ public class CyclingController : DeviceServiceMonoBase
UIManager.Instance.MainPanel = uipanel.GetComponent<PFUIPanel>();
UIManager.Instance.ModalsPanel = this.transform.Find("UI/ModalPanel").GetComponent<PFUIPanel>();
onlineUserPrefab = Resources.Load<GameObject>("UI/Prefab/Match/OnlinePlayer");
onlineUserPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/EmptyOnlinePlayer");
onlineUserPrefab3d = Resources.Load<GameObject>("UI/Prefab/Match/onlinePlayerNoScript");
miniMapPlayerPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/MiniMapPlayer");
watcher = Resources.Load<GameObject>("UI/Prefab/Match/Watcher");
target = transform.Find("Target");
@@ -381,7 +424,7 @@ public class CyclingController : DeviceServiceMonoBase
private GameObject onlinePlayer { get; set; }
Vector3 MAX_SIZE = new Vector3(3f, 3f, 3f);
Vector3 MIN_SIZE = new Vector3(0.01f, 0.01f, 0.01f);
Vector3 MIN_SIZE = new Vector3(1f, 1f, 1f);
public void ChangeCurrentPlayer(int userId)
{
var coll = FindObjectsOfType<AbstractPlayer>();
@@ -389,13 +432,25 @@ public class CyclingController : DeviceServiceMonoBase
if (selectedPlayer != null)
{
currentPlayer = selectedPlayer;
selectedPlayer.transform.localScale = Is3dView? MAX_SIZE : MIN_SIZE;
if (selectedPlayer is PlayerController)
{
selectedPlayer.transform.localScale = Is3dView ? MAX_SIZE : MIN_SIZE;
}
else
{
var ss = Instantiate(onlineUserPrefab3d, selectedPlayer.transform);
ss.transform.localScale = Is3dView ? MAX_SIZE : MIN_SIZE;
}
}
var unselectedPlayers = coll.Where(c => c.UserId != userId).ToList();
foreach (var item in unselectedPlayers)
{
item.transform.localScale = MIN_SIZE;
if (item.transform.childCount > 0)
{
Utils.DestroyChildren(item.transform);
}
}
//重置海拔图进度
var currentIndex = currentPlayer.CurrentIndex;
@@ -421,6 +476,8 @@ public class CyclingController : DeviceServiceMonoBase
currentPos.y += 1f;
player.transform.position = currentPos;
playerController.currentPos = currentPos;
var trail = FindObjectOfType<TrailRenderer>();
trail.enabled = true;
Vector2d nextLatLon = Along(recorderData.EndDistance + 0.1);
//设定人物方向
@@ -531,7 +588,6 @@ public class CyclingController : DeviceServiceMonoBase
{
item.RemoveSelf();
}
var s = playerController.TotalDistance - item.TotalDistance;
}
//显示面板信息
var others = FindObjectsOfType<AbstractPlayer>();
@@ -33,9 +33,11 @@ namespace Assets.Scenes.Ride.Scripts
if (mainController.cyclingController.Mode == CyclingModel.Competition)
{
#if UNITY_IOS || UNITY_ANDROID
arrowImage = Instantiate(Resources.Load<Image>("UI/Prefab/Match/Mobile/CompetitionArrow"), uiObject);
var CompetitionArrow = mainController.GetCompetitionMobileArrow();
arrowImage = Instantiate(CompetitionArrow, uiObject);
#else
arrowImage = Instantiate(Resources.Load<Image>("UI/Prefab/Match/CompetitionArrow"), uiObject);
var CompetitionArrow = mainController.GetCompetitionArrow();
arrowImage = Instantiate(CompetitionArrow, uiObject);
#endif
//比赛模式
if (!string.IsNullOrEmpty(headUrl))
@@ -57,7 +59,6 @@ namespace Assets.Scenes.Ride.Scripts
}
protected override void Compute()
{
currentlatlong = mainController.Along(totalDistance);//下一个坐标
if (mainController.currentPlayer != null)
{
diff = Math.Round((totalDistance - mainController.currentPlayer.TotalDistance) * 1000, 0);
@@ -168,7 +169,7 @@ namespace Assets.Scenes.Ride.Scripts
trailRenderer = gameObject.AddComponent<TrailRenderer>();
trailRenderer = FindObjectOfType<TrailRenderer>();
//var color7 = Resources.Load<Material>("UI/Material/color7");
var Graph2 = Resources.Load<Material>("UI/Material/3dGraph2");
var Graph2 = mainController.Get3dGraph2(); //Resources.Load<Material>("UI/Material/3dGraph2");
trailRenderer.materials = new Material[] { Graph2 };
trailRenderer.time = 30;
trailRenderer.startWidth = 1f;
@@ -259,7 +260,8 @@ namespace Assets.Scenes.Ride.Scripts
if (headPanel == null)
{
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel"));
var onlineHeadPanel = mainController.GetOnlineheadPanel();
headPanel = Instantiate(onlineHeadPanel);
headPanel.transform.SetParent(graph.transform);
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
headPanel.transform.position = itemPosition;
@@ -43,7 +43,9 @@ namespace Assets.Scenes.Ride.Scripts
{
if (tickOffset + ticks < record.Length)
{
var data = TargetData.Read(record[tickOffset + ticks - 1]);
var t = tickOffset + ticks - 1;
t = t < 0 ? 0 : t;
var data = TargetData.Read(record[t]);
power = data._Power;
speed = data._Speed;
distance = data._Speed / 3600;
@@ -40,6 +40,7 @@ namespace Assets.Scenes.Ride.Scripts
trail.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion;
trail.receiveShadows = false;
trail.rayTracingMode = UnityEngine.Experimental.Rendering.RayTracingMode.Off;
trail.enabled = false;
headPanel = uipanel.transform.Find("GraphChart/HeadPanel").gameObject;
}
@@ -75,7 +76,7 @@ namespace Assets.Scenes.Ride.Scripts
{
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
distance = mainController.UpdateDistance(speed);
totalDistance += distance;
//totalDistance += distance;
}
else
{
@@ -31,8 +31,6 @@ namespace Assets.Scenes.Ride.Scripts
CyclingController cyclingCotroller;
private bool initComplete = false;
private List<Vector3> vector3s = new List<Vector3>();
protected virtual void Awake()
{
if (_map == null)
@@ -44,11 +42,6 @@ namespace Assets.Scenes.Ride.Scripts
}
private void Update()
{
if(!vector3s.Contains(cyclingCotroller.currentPlayer.currentPos))
vector3s.Add(cyclingCotroller.currentPlayer.currentPos);
}
private void _map_OnUpdated()