AR以及对战房间部分代码重构
This commit is contained in:
parent
fb4da81ce2
commit
a149a7c08e
@ -100,15 +100,14 @@ namespace Assets.AR
|
||||
if (arObject.TimeTransforms != null && arObject.TimeTransforms.Length > 1)
|
||||
arObject.UpdateByTimeDefinitions(videoFrame);
|
||||
arObject.UpdateVisibility(videoFrame, visibilityRear, visibilityFront, this.IsMultilap);
|
||||
bool flag = this.IsObjectActive(arObject);
|
||||
var flag = this.IsObjectActive(arObject);
|
||||
arObject.gameObject.SetActive(flag);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsObjectActive(ARGameObject arObject) => (double)arObject.VisibilityLevel > 0.0 ;
|
||||
|
||||
|
||||
protected virtual Material GetTrajectoryMaterial() => this.matShadow;
|
||||
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
|
||||
@ -390,6 +390,7 @@ namespace Assets.AR
|
||||
}
|
||||
if (index1 + 1 == this.ShadowIntensities.Length)
|
||||
return this.ShadowIntensities[this.ShadowIntensities.Length - 1];
|
||||
|
||||
float t = Mathf.InverseLerp(this.ShadowIntensityFrames[index1], this.ShadowIntensityFrames[index1 + 1], distance);
|
||||
return Mathf.Lerp(this.ShadowIntensities[index1], this.ShadowIntensities[index1 + 1], t);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using UnityEngine;
|
||||
using RenderHeads.Media.AVProVideo;
|
||||
using Assets.Scripts.Scenes.VideoRide;
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace Assets.AR
|
||||
{
|
||||
@ -27,6 +28,7 @@ namespace Assets.AR
|
||||
private VideoGameManager manager;
|
||||
public int VisibleModels { get; private set; }
|
||||
private int visibleModelsLimit = 20;
|
||||
public int VisibleRiderTitlesLimit => this.VisibleModelsLimit + 10;
|
||||
public int VisibleModelsLimit
|
||||
{
|
||||
get => this.visibleModelsLimit;
|
||||
@ -83,77 +85,104 @@ namespace Assets.AR
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (this.videoPlayer == null)
|
||||
return;
|
||||
if (videoPlayer == null ) return;
|
||||
|
||||
timers -= Time.deltaTime;
|
||||
while (timers <= 0)
|
||||
{
|
||||
foreach (var dic in manager.rideObjs)
|
||||
{
|
||||
var item = dic.Value;
|
||||
if (!this.arObjects.Contains(item))
|
||||
this.arObjects.Add(item);
|
||||
if (!this.riderObjects.ContainsKey(item.UserId))
|
||||
this.riderObjects.Add(item.UserId, item);
|
||||
|
||||
item.PreSpeed = item.Speed;
|
||||
item.Speed = (float)dic.Key.OnlineSpeed;
|
||||
item.DeltaDistance = (float)(dic.Key.EndDistance - dic.Key.PreDistance);
|
||||
item.Route = Route;
|
||||
item.VideoSync = videoPointsSync;
|
||||
item.IsAtFinish = dic.Key.EndDistance >= manager.GetMapRoute().Distance*1000f;
|
||||
|
||||
if (dic.Key.UserId == manager.CurrentUserId)
|
||||
{
|
||||
mainRiderObject = item;
|
||||
//如果速度为0就停止播放视频
|
||||
if (item.DeltaDistance == 0 || item.Speed == 0)
|
||||
{
|
||||
item.DeltaDistance = 0;
|
||||
videoPlayer.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPlayer.Resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.arObjects.RemoveAll(c => !manager.rideObjs.Select(m => m.Key.UserId.ToString()).Contains(c.UserId.ToString()));
|
||||
|
||||
var keys = riderObjects.Keys.ToList();
|
||||
foreach (var item in keys)
|
||||
{
|
||||
if (!manager.rideObjs.Keys.Where(c => c.UserId == item).Any())
|
||||
{
|
||||
riderObjects.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateRiders();
|
||||
RemoveRiders();
|
||||
timers += 0.2f;
|
||||
}
|
||||
|
||||
|
||||
if (mainRiderObject == null || Route == null)
|
||||
{
|
||||
videoPlayer?.Pause();
|
||||
videoPlayer.Pause();
|
||||
return;
|
||||
}
|
||||
var delta = Time.deltaTime;
|
||||
foreach (var obj in this.riderObjects.Values)
|
||||
{
|
||||
if(obj.DeltaDistance == 0 )continue;
|
||||
obj.Distance = Mathf.Lerp(obj.Distance, obj.Distance + obj.DeltaDistance, delta);
|
||||
obj.RouteDistance = Mathf.Lerp(obj.RouteDistance, obj.RouteDistance + obj.DeltaDistance, delta);
|
||||
}
|
||||
|
||||
this.PlayFrameDistance();
|
||||
VideoPlayerControl.UpdateVideoPlayRate(mainRiderObject.PreSpeed, mainRiderObject.Distance);
|
||||
|
||||
this.FrameIndexDistanceCorrection = this.VideoPlayerControl.FrameIndexDistanceCorrection;
|
||||
//this.FollowedRiderId = mainObject.Id;
|
||||
this.UpdateCameraFollowDistance();
|
||||
|
||||
base.Update();
|
||||
this.UpdateRidersVisibility();
|
||||
this.UpdateRidersLean();
|
||||
this.UpdateBackLight();
|
||||
this.SetUpVideoControlMode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新骑行者的实时数据
|
||||
/// </summary>
|
||||
private void UpdateRiders()
|
||||
{
|
||||
foreach (var dic in manager.rideObjs)
|
||||
{
|
||||
var item = dic.Value;
|
||||
if (!this.arObjects.Contains(item))
|
||||
this.arObjects.Add(item);
|
||||
if (!this.riderObjects.ContainsKey(item.UserId))
|
||||
this.riderObjects.Add(item.UserId, item);
|
||||
|
||||
item.PreSpeed = item.Speed;
|
||||
item.Speed = (float)dic.Key.OnlineSpeed;
|
||||
item.DeltaDistance = (float)(dic.Key.EndDistance - dic.Key.PreDistance);
|
||||
item.Route = Route;
|
||||
item.VideoSync = videoPointsSync;
|
||||
item.IsAtFinish = dic.Key.EndDistance >= manager.GetMapRoute().Distance*1000f;
|
||||
|
||||
if (dic.Key.UserId != manager.CurrentUserId) continue;
|
||||
mainRiderObject = item;
|
||||
//如果速度为0就停止播放视频
|
||||
if (item.DeltaDistance == 0 || item.Speed == 0)
|
||||
{
|
||||
item.DeltaDistance = 0;
|
||||
videoPlayer.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPlayer.Resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除不可见的骑行者
|
||||
/// </summary>
|
||||
private void RemoveRiders()
|
||||
{
|
||||
this.arObjects.RemoveAll(c => !manager.rideObjs.Select(m => m.Key.UserId.ToString()).Contains(c.UserId.ToString()));
|
||||
|
||||
var keys = riderObjects.Keys.ToList();
|
||||
foreach (var item in keys)
|
||||
{
|
||||
if (!manager.rideObjs.Keys.Where(c => c.UserId == item).Any())
|
||||
{
|
||||
riderObjects.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将每秒的距离转换为每帧的距离
|
||||
/// </summary>
|
||||
private void PlayFrameDistance()
|
||||
{
|
||||
var delta = Time.deltaTime;
|
||||
foreach (var obj in this.riderObjects.Values.Where(obj => obj.DeltaDistance != 0))
|
||||
{
|
||||
obj.Distance = Mathf.Lerp(obj.Distance, obj.Distance + obj.DeltaDistance, delta);
|
||||
obj.RouteDistance = Mathf.Lerp(obj.RouteDistance, obj.RouteDistance + obj.DeltaDistance, delta);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置camera的跟随距离
|
||||
/// </summary>
|
||||
private void SetUpVideoControlMode()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
this.SetVideoControlMode(VideoPlayMode.Front);
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
@ -162,7 +191,10 @@ namespace Assets.AR
|
||||
return;
|
||||
this.SetVideoControlMode(VideoPlayMode.Rear);
|
||||
}
|
||||
//创建
|
||||
|
||||
/// <summary>
|
||||
/// 设置光线
|
||||
/// </summary>
|
||||
private void SetUpLight()
|
||||
{
|
||||
this.arLight.type = LightType.Directional;
|
||||
@ -170,7 +202,7 @@ namespace Assets.AR
|
||||
this.arLight.shadows = LightShadows.Soft;
|
||||
this.arLight.shadowStrength = 1f;
|
||||
|
||||
GameObject gameObject2 = new GameObject("ARBackLight");
|
||||
var gameObject2 = new GameObject("ARBackLight");
|
||||
gameObject2.layer = this.gameObject.layer;
|
||||
gameObject2.transform.SetParent(this.transform);
|
||||
this.arBackLight = gameObject2.AddComponent<Light>();
|
||||
@ -178,9 +210,8 @@ namespace Assets.AR
|
||||
this.arBackLight.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
|
||||
this.arBackLight.shadows = LightShadows.None;
|
||||
this.arBackLight.intensity = 0.5f;
|
||||
//this.arBackLight.cullingMask = 512;
|
||||
}
|
||||
//设置video显示模式
|
||||
|
||||
public void SetVideoControlMode(VideoPlayMode mode)
|
||||
{
|
||||
if (mode == this.VideoControlMode)
|
||||
@ -196,7 +227,6 @@ namespace Assets.AR
|
||||
//更新摄像机的位置
|
||||
private void UpdateCameraFollowDistance()
|
||||
{
|
||||
//this.NearViewMode = this.RiderCameraDistance == AR.CameraDistance.Near;
|
||||
var cameraFollowDistance = GetCameraFollowDistance(this.RiderCameraDistance);
|
||||
this.VideoPlayerControl.CameraFollowDistance = cameraFollowDistance;
|
||||
}
|
||||
@ -442,7 +472,6 @@ namespace Assets.AR
|
||||
}
|
||||
}
|
||||
}
|
||||
public int VisibleRiderTitlesLimit => this.VisibleModelsLimit + 10;
|
||||
private void UpdateVisibleRiders()
|
||||
{
|
||||
var visibilityModels = ARGameObject.MaxDistanceVisibilityModels;
|
||||
|
||||
@ -18,7 +18,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &994686065624044129
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -78,7 +78,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 1
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: 6
|
||||
m_Text:
|
||||
--- !u!114 &994686065624044124
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -126,9 +126,8 @@ namespace Assets.Scripts.Apis.Models
|
||||
}
|
||||
else
|
||||
{
|
||||
_List[i].Grade = Math.Round(a / b * 100, 4);
|
||||
_List[i].Grade = Math.Min(Math.Round(a / b * 100, 4),12);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void CalcCenter()
|
||||
|
||||
@ -392,14 +392,8 @@ public class MainController : BaseScene
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//UIManager.ShowNewRouteOverviewPanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowEditUserPanel();
|
||||
//UIManager.ShowBigMapPanel();
|
||||
//UIManager.ShowEarthPanel();
|
||||
}
|
||||
ShowGameRoomInviteConfirm();
|
||||
|
||||
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
||||
//await GetDeviceListAsync(); PC品牌
|
||||
//显示首页的3d小人
|
||||
@ -430,6 +424,134 @@ public class MainController : BaseScene
|
||||
{
|
||||
base.Update();
|
||||
|
||||
HandleGameRoom();
|
||||
|
||||
CanvasSizeChanged();
|
||||
|
||||
t -= Time.deltaTime;
|
||||
while (t <= 0)
|
||||
{
|
||||
App.CurrentScene = "Main";
|
||||
UIManager.SendCompetitionStartMessage("Main");
|
||||
t = 1;
|
||||
scanTicks++;
|
||||
emptyt++;
|
||||
if (emptyt >= 10)
|
||||
{
|
||||
emptyt = 0;
|
||||
if (App.currentPageIsHome)
|
||||
{
|
||||
FinishMessageLeft();
|
||||
}
|
||||
}
|
||||
if (scanTicks == 10)
|
||||
{
|
||||
//App.MainDeviceAdapter.StopScan();
|
||||
//Debug.Log("StopScan");
|
||||
}
|
||||
MapUDPService.Send(0, App.CurrentUser.Id, new double[]{ 0d,0d}, competitionId: 0,model:App.Model);
|
||||
HandleCompetition();
|
||||
}
|
||||
}
|
||||
|
||||
private void CanvasSizeChanged()
|
||||
{
|
||||
if (App.canvasWidth != transform.GetComponent<RectTransform>().sizeDelta.x)
|
||||
{
|
||||
App.canvasWidth = transform.GetComponent<RectTransform>().sizeDelta.x;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCompetition()
|
||||
{
|
||||
var list = MapUDPService.GetAllOnlineUserList();
|
||||
var lang = App.GetLocalLanguage();
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item.Point != null && item.Point.Length > 0 && item.Point[0] == -1d)
|
||||
{
|
||||
var message = lang == "zh" ? $"{item.Name}进入了 运动地球" : "entered PowerFun";
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(-1, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.Id}{item.LastActiveTime}{item.Point}");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.RouteName))
|
||||
continue;
|
||||
if (item.RouteId > 0)
|
||||
{
|
||||
var message = "";
|
||||
if (item.TotalTicks == 0 && item.PreDistance == 0)
|
||||
{
|
||||
var routeName = string.IsNullOrEmpty(item.RouteName) ? $"#{item.RouteId}" : item.RouteName;
|
||||
message = lang == "zh"
|
||||
? $"发起了对<color=#f93086>{routeName}</color>的挑战!"
|
||||
: $"started riding <color=#f93086>{item.RouteName}</color>!";
|
||||
}
|
||||
|
||||
if (item.IsCompleted)
|
||||
{
|
||||
message = lang == "zh"
|
||||
? $"完成了<color=#f93086>{item.RouteName}</color>的挑战!"
|
||||
: $"completed <color=#f93086>{item.RouteName}</color> ride!";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.RouteId}{item.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
//距离50
|
||||
if (item.EndDistance >= 50 && item.EndDistance < 100)
|
||||
{
|
||||
var message = lang == "zh"
|
||||
? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"50KM"}</color>!"
|
||||
: $"riding distance reaches <color=#e3d427>{"50KM"}</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.RouteId}{item.Name}50KM");
|
||||
}
|
||||
|
||||
//距离100
|
||||
if (item.EndDistance >= 100)
|
||||
{
|
||||
var message = lang == "zh"
|
||||
? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"100KM"}</color>!"
|
||||
: $"riding distance reaches <color=#e3d427>{"100KM"}</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.RouteId}{item.Name}100KM");
|
||||
}
|
||||
|
||||
//速度50
|
||||
if (item.Speed >= 50)
|
||||
{
|
||||
var message = lang == "zh"
|
||||
? $"在<color=#f93086>{item.RouteName}</color>中骑行速度达到<color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color>!"
|
||||
: $"riding speed reaches <color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.RouteId}{item.Name}50KM/H");
|
||||
}
|
||||
|
||||
//功体比
|
||||
if (item.WeightKg >= 4)
|
||||
{
|
||||
var message = lang == "zh"
|
||||
? $"在<color=#f93086>{item.RouteName}</color>中功体比达到<color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color>!"
|
||||
: $" riding PWR reaches <color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(
|
||||
new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName),
|
||||
$"{item.RouteId}{item.Name}3WeightKg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleGameRoom()
|
||||
{
|
||||
if (DataSorceChanged)
|
||||
{
|
||||
DataSorceChanged = false;
|
||||
@ -456,108 +578,10 @@ public class MainController : BaseScene
|
||||
gameRoomProcessing = false;
|
||||
SceneManager.LoadScene("Ride");
|
||||
}
|
||||
clearcachet -= Time.deltaTime;
|
||||
if (clearcachet <= 0)
|
||||
{
|
||||
Debug.Log("清一次");
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
clearcachet = 30;
|
||||
}
|
||||
if (App.canvasWidth != transform.GetComponent<RectTransform>().sizeDelta.x)
|
||||
{
|
||||
App.canvasWidth = transform.GetComponent<RectTransform>().sizeDelta.x;
|
||||
//Debug.Log(App.canvasWidth);
|
||||
}
|
||||
//Debug.Log(transform.GetComponent<RectTransform>().sizeDelta.x);
|
||||
t -= Time.deltaTime;
|
||||
while (t <= 0)
|
||||
{
|
||||
App.CurrentScene = "Main";
|
||||
UIManager.SendCompetitionStartMessage("Main");
|
||||
t = 1;
|
||||
scanTicks++;
|
||||
emptyt++;
|
||||
if (emptyt >= 10)
|
||||
{
|
||||
emptyt = 0;
|
||||
if (App.currentPageIsHome)
|
||||
{
|
||||
FinishMessageLeft();
|
||||
}
|
||||
}
|
||||
if (scanTicks == 10)
|
||||
{
|
||||
//App.MainDeviceAdapter.StopScan();
|
||||
//Debug.Log("StopScan");
|
||||
}
|
||||
MapUDPService.Send(0, App.CurrentUser.Id, new double[]{ 0d,0d}, competitionId: 0,model:App.Model);
|
||||
//发送消息
|
||||
|
||||
var list = MapUDPService.GetAllOnlineUserList();
|
||||
var lang = App.GetLocalLanguage();
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item.Point != null && item.Point.Length > 0 && item.Point[0] == -1d)
|
||||
{
|
||||
var message = lang == "zh" ? $"{item.Name}进入了 运动地球" : "entered PowerFun";
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(-1, message, item.HeadImage, item.Name, item.RouteName), $"{item.Id}{item.LastActiveTime}{item.Point}");
|
||||
}
|
||||
if (string.IsNullOrEmpty(item.RouteName))
|
||||
continue;
|
||||
if (item.RouteId > 0)
|
||||
{
|
||||
var message = "";
|
||||
if (item.TotalTicks == 0 && item.PreDistance == 0)
|
||||
{
|
||||
var routeName = string.IsNullOrEmpty(item.RouteName) ? $"#{item.RouteId}" : item.RouteName;
|
||||
message = lang=="zh"?$"发起了对<color=#f93086>{routeName}</color>的挑战!" : $"started riding <color=#f93086>{item.RouteName}</color>!";
|
||||
}
|
||||
if (item.IsCompleted)
|
||||
{
|
||||
message = lang == "zh" ? $"完成了<color=#f93086>{item.RouteName}</color>的挑战!" : $"completed <color=#f93086>{item.RouteName}</color> ride!";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name,item.RouteName), $"{item.RouteId}{item.Name}");
|
||||
}
|
||||
}
|
||||
//距离50
|
||||
if (item.EndDistance >= 50 && item.EndDistance < 100)
|
||||
{
|
||||
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"50KM"}</color>!" : $"riding distance reaches <color=#e3d427>{"50KM"}</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}50KM");
|
||||
}
|
||||
//距离100
|
||||
if (item.EndDistance >= 100)
|
||||
{
|
||||
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"100KM"}</color>!" : $"riding distance reaches <color=#e3d427>{"100KM"}</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}100KM");
|
||||
}
|
||||
////速度35
|
||||
//if (item.Speed >= 35)
|
||||
//{
|
||||
// var message = lang == "zh" ? $"骑行速度突破<color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color>!" : $"riding speed reaches <color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color>!";
|
||||
// EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}35KM/H");
|
||||
//}
|
||||
//速度50
|
||||
if (item.Speed >= 50)
|
||||
{
|
||||
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行速度达到<color=#e3d427>{Math.Round(item.Speed,2)}KM/H</color>!" : $"riding speed reaches <color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}50KM/H");
|
||||
}
|
||||
//功体比
|
||||
if (item.WeightKg >= 4)
|
||||
{
|
||||
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中功体比达到<color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color>!" : $" riding PWR reaches <color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color> in <color=#f93086>{item.RouteName}</color>!";
|
||||
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}3WeightKg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShowGameRoomInviteConfirm();
|
||||
}
|
||||
|
||||
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
|
||||
@ -519,17 +519,20 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
SendQuit4GameRoom();
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
}
|
||||
private void SendQuit4GameRoom()
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
//如果在对战房间内,发送退出房间的命令
|
||||
if (mainController.roomId > 0)
|
||||
{
|
||||
MapUDPService.SendGameRoomKick(mainController.roomId, App.CurrentUser.Id, App.CurrentUser.Id);
|
||||
}
|
||||
QuitGameRoom();
|
||||
}
|
||||
|
||||
//如果在对战房间内,发送退出房间的命令
|
||||
private void QuitGameRoom()
|
||||
{
|
||||
if (mainController.roomId == 0) return;
|
||||
MapUDPService.SendGameRoomKick(mainController.roomId, App.CurrentUser.Id, App.CurrentUser.Id);
|
||||
}
|
||||
//不保存退出
|
||||
public virtual void CancelQuit(BaseEventData baseEventData)
|
||||
@ -537,7 +540,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
modalPanel.SetActive(false);
|
||||
quitPanel.SetActive(false);
|
||||
mainController.ClearTempFile();
|
||||
SendQuit4GameRoom();
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
//取消退出
|
||||
@ -556,8 +558,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
protected virtual void StopShortRide(BaseEventData baseEventData)
|
||||
{
|
||||
//发送退出房间的命令
|
||||
SendQuit4GameRoom();
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
protected virtual void CancelStopShortRide(BaseEventData baseEventData)
|
||||
|
||||
@ -1293,7 +1293,7 @@ public BaseUIManager singleUIManager;
|
||||
var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId;
|
||||
Helper.CreateDirectoryIfNotExsit(path);
|
||||
|
||||
string imageFileName = path +"/"+ Guid.NewGuid().ToString() + ".png";
|
||||
var imageFileName = path +"/"+ Guid.NewGuid().ToString() + ".png";
|
||||
CaptureCamera(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f), imageFileName);
|
||||
cyclingController.recorderData.StartTime = startTime;
|
||||
cyclingController.recorderData.IsCompleted = totalDistance >= mapData.TotalDistance;
|
||||
|
||||
@ -118,7 +118,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetFloat(PreSpeed, (float)preSpeed);
|
||||
animator.SetFloat(AnimatorSpeed, (float)speed);
|
||||
animator.SetFloat(AnimatorSpeed, (float)OnlineSpeed);
|
||||
animator.SetFloat(Grade, (float)currentSlope);
|
||||
animator.SetFloat(Power, (float)power);
|
||||
}
|
||||
@ -172,6 +172,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
public virtual void ComputeRecord() { }
|
||||
|
||||
private const double DoubleDelta = 1E-6;
|
||||
|
||||
private const double GradeFactor = 0.5f;
|
||||
//计算当前区段属性下一个区段属性
|
||||
public void ComputeNextSlope()
|
||||
{
|
||||
@ -194,19 +198,20 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
break;
|
||||
}
|
||||
}
|
||||
var DOUBLE_DELTA = 1E-6;
|
||||
if (Math.Abs(totalDistance - mapData.TotalDistance) < DOUBLE_DELTA)
|
||||
|
||||
if (Math.Abs(totalDistance - mapData.TotalDistance) < DoubleDelta)
|
||||
{
|
||||
currentIndex = pointList.Count - 1;
|
||||
}
|
||||
Debug.Log(currentIndex);
|
||||
preIndex = currentIndex > 0 ? currentIndex - 1 : 0;//前一个索引
|
||||
int nextIndex = currentIndex == pointList.Count - 1 ? currentIndex : currentIndex + 1; //计算下一个点的坡度和距离
|
||||
|
||||
elevation = pointList[currentIndex].Elevation;
|
||||
currentSlope = pointList[currentIndex].Grade;
|
||||
currentSlope = pointList[currentIndex].Grade * GradeFactor;
|
||||
//CurrentDistance = pointList[currentIndex].Distance;
|
||||
//计算下一个海拔和坡度&当前区间距离
|
||||
nextSlope = pointList[nextIndex].Grade;
|
||||
nextSlope = pointList[nextIndex].Grade * GradeFactor;
|
||||
nextSlopeDistance = sumDistance - totalDistance * 1000;
|
||||
//NextSlopeTotalDistance = pointList[nextIndex].Distance;
|
||||
currentSlopeDistance = (totalDistance * 1000 - (sumDistance - pointList[currentIndex].Distance));
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scenes.Ride.Scripts.Model.CyclingModels;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -16,11 +15,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
userName = App.CurrentUser.Nickname;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
}
|
||||
|
||||
public void SetEndDistance(double distance)
|
||||
{
|
||||
this.totalDistance = distance;
|
||||
@ -39,11 +33,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
|
||||
public override void ComputeAnimator()
|
||||
{
|
||||
base.ComputeAnimator();
|
||||
}
|
||||
|
||||
public override void ComputePlayer()
|
||||
{
|
||||
heartRate = manager.UpDateHeart();
|
||||
@ -77,7 +66,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
gameRoomHandled = true;
|
||||
var gap = model.FirstEndTime.Value - UIManager.Now.GetDateTime();
|
||||
var seconds = Math.Floor(gap.TotalSeconds);
|
||||
UIManager.ShowGameRoomCountDownPanel((int)seconds, () => {
|
||||
UIManager.ShowGameRoomCountDownPanel((int)seconds, () =>
|
||||
{
|
||||
Upload();
|
||||
var uiManager = FindObjectOfType<VideoUIManager>();
|
||||
uiManager.ShowResultPanel();
|
||||
@ -85,10 +75,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
|
||||
public override void ComputeAnimatorSpeed()
|
||||
{
|
||||
base.ComputeAnimatorSpeed();
|
||||
}
|
||||
public override void ComputeRecord()
|
||||
{
|
||||
var mapData = manager.GetMapData();
|
||||
|
||||
@ -10,67 +10,48 @@ public class GameRoomCountDownController : PFUIPanel
|
||||
public Text endCount;
|
||||
|
||||
private int Seconds { get; set; }
|
||||
|
||||
public GameRoomModel GameRoom { get; set; }
|
||||
|
||||
private Action Callback { get; set; }
|
||||
|
||||
protected override void Awake()
|
||||
private bool simple { get; set; }
|
||||
public void Init(int seconds,Action action,bool isEnd = false,bool simple = false)
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
}
|
||||
private bool isSimple { get; set; }
|
||||
public void Init(int seconds,Action action,bool isEnd = false,bool isSimple = false)
|
||||
{
|
||||
stopped = false;
|
||||
_stopped = false;
|
||||
Seconds = seconds;
|
||||
Callback = action;
|
||||
this.simple = simple;
|
||||
endCount.gameObject.SetActive(false);
|
||||
this.isSimple = isSimple;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
private bool stopped;
|
||||
private bool _stopped;
|
||||
public void Stop()
|
||||
{
|
||||
this.stopped = true;
|
||||
this._stopped = true;
|
||||
}
|
||||
|
||||
float timer = 0f;
|
||||
private float _timer = 0f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
_timer -= Time.deltaTime;
|
||||
while (_timer < 0)
|
||||
{
|
||||
if (Seconds == 0)
|
||||
{
|
||||
Callback?.Invoke();
|
||||
}
|
||||
if (Seconds < 0 || stopped)
|
||||
|
||||
if (Seconds <= 0 || _stopped)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isSimple)
|
||||
{
|
||||
count.text = Seconds.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
count.text = Helper.FormatTicks(Seconds);
|
||||
}
|
||||
endCount.text = Helper.FormatTicks(Seconds);
|
||||
}
|
||||
|
||||
count.gameObject.SetActive(Seconds >0);
|
||||
count.text = simple ? Seconds.ToString() : Helper.FormatTicks(Seconds);
|
||||
endCount.text = Helper.FormatTicks(Seconds);
|
||||
Seconds--;
|
||||
timer += 1f;
|
||||
_timer += 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,30 +105,24 @@ public class GameRoomDetailController : PFUIPanel
|
||||
private void ListenerHandler(List<ReceiveMsgModel> message)
|
||||
{
|
||||
var detail = message.FirstOrDefault();
|
||||
if (detail != null)
|
||||
if (detail == null || message.Count > 1) return;
|
||||
|
||||
if (detail.RoomList == null)
|
||||
{
|
||||
if (detail.RoomList == null)
|
||||
{
|
||||
DataSourceChanged = true;
|
||||
GameRoom = null;
|
||||
return;
|
||||
}
|
||||
GameRoom = detail.RoomList.Where(c => c.RoomId == GameRoom.RoomId).FirstOrDefault();
|
||||
if (GameRoom != null)
|
||||
{
|
||||
DataSourceChanged = true;
|
||||
}
|
||||
DataSourceChanged = true;
|
||||
GameRoom = null;
|
||||
return;
|
||||
}
|
||||
GameRoom = detail.RoomList.Where(c => c.RoomId == GameRoom.RoomId).FirstOrDefault();
|
||||
if (GameRoom != null)
|
||||
{
|
||||
DataSourceChanged = true;
|
||||
}
|
||||
}
|
||||
float timer = 0f;
|
||||
private void Update()
|
||||
{
|
||||
TcpHandler();
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
|
||||
@ -197,11 +197,11 @@ QualitySettings:
|
||||
shadowNearPlaneOffset: 3
|
||||
shadowCascade2Split: 0.33333334
|
||||
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
|
||||
shadowmaskMode: 1
|
||||
shadowmaskMode: 0
|
||||
skinWeights: 255
|
||||
textureQuality: 0
|
||||
anisotropicTextures: 2
|
||||
antiAliasing: 4
|
||||
antiAliasing: 8
|
||||
softParticles: 1
|
||||
softVegetation: 1
|
||||
realtimeReflectionProbes: 1
|
||||
@ -232,7 +232,7 @@ QualitySettings:
|
||||
PS4: 5
|
||||
PS5: 5
|
||||
Stadia: 5
|
||||
Standalone: 2
|
||||
Standalone: 3
|
||||
WebGL: 3
|
||||
Windows Store Apps: 2
|
||||
XboxOne: 5
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user