部分代码重构
This commit is contained in:
parent
431d128ad8
commit
191efae2dd
@ -69,11 +69,6 @@ namespace Assets.AR
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
public void Initialize(bool male, bool timeTrialBike)
|
||||
{
|
||||
this.Initialize(male);
|
||||
@ -186,7 +181,7 @@ namespace Assets.AR
|
||||
{
|
||||
var manager = FindObjectOfType<VideoGameManager>();
|
||||
var map = manager.GetMapRoute();
|
||||
if(map.Id == 6296)
|
||||
if(map.Id == 6296)//TODO:这里写死溧阳AR骑行
|
||||
Lane = -2f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +441,8 @@
|
||||
"Next Time":"下次再说",
|
||||
"DontNeedDownload":"当前视频下载完成后,下次进入线路就不需要重复下载.",
|
||||
"Not In Use":"禁用",
|
||||
"CancelReadyToQuit":"请取消准备后再退出!"
|
||||
"CancelReadyToQuit":"请取消准备后再退出!",
|
||||
"GetCloseGate": "已产生第一名,比赛倒计时"
|
||||
},
|
||||
"en": {
|
||||
"REMAINING": "REMAINING",
|
||||
@ -878,6 +879,7 @@
|
||||
"Next Time":"Next Time",
|
||||
"DontNeedDownload":"The same AR route video does not need to be downloaded again next time",
|
||||
"Not In Use":"Not In Use",
|
||||
"CancelReadyToQuit":"please cancel ready status and click quit!"
|
||||
"CancelReadyToQuit":"please cancel ready status and click quit!",
|
||||
"GetCloseGate": "CountDown to the Competition"
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +226,8 @@ public static class App
|
||||
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
|
||||
Debug.unityLogger.logEnabled = false;
|
||||
#else
|
||||
Host = "http://pf.juze.pro/";//"http://pf.juze.pro/"; //"http://192.168.0.102:5082/";//
|
||||
Host = "http://192.168.0.98:6662/";
|
||||
// Host = "http://pf.juze.pro/";//"http://pf.juze.pro/"; //"http://192.168.0.102:5082/";//
|
||||
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||||
#endif
|
||||
|
||||
@ -142,7 +142,7 @@ namespace Assets.Scripts.Devices.Ble
|
||||
{
|
||||
discoveredDevices[device.Peripheral.Address].SignalStrength = device.Rssi;
|
||||
discoveredDevices[device.Peripheral.Address].LastActiveTime = DateTime.Now;
|
||||
Debug.Log($"设备{ device.Peripheral.Name }信号量:{ device.Rssi }");
|
||||
//Debug.Log($"设备{ device.Peripheral.Name }信号量:{ device.Rssi }");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -3,12 +3,7 @@ using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Mapbox.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Video;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -20,69 +15,79 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
Camera _minicamera;
|
||||
[SerializeField]
|
||||
GameObject _player;
|
||||
VideoGameManager cyclingCotroller;
|
||||
public AbstractVideoPlayer playerController { get; set; }
|
||||
|
||||
GameObject _mipMapRoute;
|
||||
public RectTransform RectRoot { get; set; }
|
||||
TrailRenderer trail;
|
||||
Transform uitransform { get; set; }
|
||||
void Start()
|
||||
private bool init { get; set; } = false;
|
||||
private float timer { get; set; } = 0f;
|
||||
private GameObject _mipMapPath;
|
||||
private Material pathMaterial { get; set; }
|
||||
|
||||
VideoGameManager cyclingCotroller;
|
||||
public AbstractVideoPlayer playerController { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cyclingCotroller = FindObjectOfType<VideoGameManager>();
|
||||
|
||||
if (cyclingCotroller != null)
|
||||
{
|
||||
playerController = cyclingCotroller.CurrentPlayer;
|
||||
var mapdata = cyclingCotroller.GetMapData();
|
||||
var map = cyclingCotroller.GetMapData();
|
||||
//初始化map
|
||||
//var point = cyclingCotroller.GetCenterCoordinate();
|
||||
if (_map != null && mapdata != null)
|
||||
if (_map != null && map != null)
|
||||
{
|
||||
_map.OnInitialized += _map_OnInitialized;
|
||||
_map.OnUpdated += _map_OnUpdated;
|
||||
_map.Initialize(new Vector2d(mapdata.Center[0], mapdata.Center[1]), 12);
|
||||
var bbox = mapdata.Bbox;
|
||||
var targetbounds = new Vector2dBounds(new Vector2d(bbox[1], bbox[0]), new Vector2d(bbox[3], bbox[2]));
|
||||
_map.Initialize(new Vector2d(map.Center[0], map.Center[1]), 12);
|
||||
var bbox = map.Bbox;
|
||||
var bounds = new Vector2dBounds(new Vector2d(bbox[1], bbox[0]), new Vector2d(bbox[3], bbox[2]));
|
||||
var screenBounds = GetScreenBounds();
|
||||
var z = SetZoomToFitBounds(targetbounds, screenBounds);
|
||||
var z = SetZoomToFitBounds(bounds, screenBounds);
|
||||
}
|
||||
uitransform = cyclingCotroller.GetCanvasTransform();
|
||||
RectRoot = uitransform.Find("MiniMap/MiniMap").GetComponent<RectTransform>();
|
||||
}
|
||||
pathMaterial = Resources.Load<Material>("UI/Material/2");
|
||||
SetTrailRender();
|
||||
}
|
||||
|
||||
//设置小地图上人物移动路径
|
||||
private void SetTrailRender()
|
||||
{
|
||||
trail = transform.parent.Find("Sphere").GetComponent<TrailRenderer>();
|
||||
trail.startWidth = 5f;
|
||||
trail.endWidth = 5f;
|
||||
trail.startColor = new Color(0.9764706f, 0.1882353f, 0.5254902f, 1f);
|
||||
trail.endColor = new Color(0.9764706f, 0.1882353f, 0.5254902f, 1f);
|
||||
}
|
||||
float timer = 0f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (cyclingCotroller.CurrentPlayer != null)
|
||||
if (cyclingCotroller.CurrentPlayer == null) return;
|
||||
|
||||
uitransform = cyclingCotroller.GetCanvasTransform();
|
||||
var tr = uitransform.Find("MiniMap/MiniMap/arrow");
|
||||
tr.SetSiblingIndex(9999);
|
||||
|
||||
var pos = _map.GeoToWorldPosition(cyclingCotroller.CurrentPlayer.currentlatLon);
|
||||
pos.y += 15f;
|
||||
_player.transform.localPosition = pos;
|
||||
|
||||
var vp2 = _minicamera.WorldToViewportPoint(_player.transform.localPosition);//将三维物体的世界坐标转换为视口坐标
|
||||
((RectTransform)tr.transform).anchoredPosition = new Vector2((vp2.x * RectRoot.sizeDelta.x) - (RectRoot.sizeDelta.x * 0.5f), (vp2.y * RectRoot.sizeDelta.y) - (RectRoot.sizeDelta.y * 0.5f));
|
||||
trail.enabled = cyclingCotroller.CurrentPlayer.power > 0;
|
||||
|
||||
timer += Time.deltaTime;
|
||||
while (timer >= 1)
|
||||
{
|
||||
uitransform = cyclingCotroller.GetCanvasTransform();
|
||||
var tr = uitransform.Find("MiniMap/MiniMap/arrow");
|
||||
tr.SetSiblingIndex(9999);
|
||||
var pos = _map.GeoToWorldPosition(cyclingCotroller.CurrentPlayer.currentlatLon);
|
||||
pos.y += 15f;
|
||||
_player.transform.localPosition = pos;
|
||||
Vector2 vp2 = _minicamera.WorldToViewportPoint(_player.transform.localPosition);//将三维物体的世界坐标转换为视口坐标
|
||||
((RectTransform)tr.transform).anchoredPosition = new Vector2((vp2.x * RectRoot.sizeDelta.x) - (RectRoot.sizeDelta.x * 0.5f), (vp2.y * RectRoot.sizeDelta.y) - (RectRoot.sizeDelta.y * 0.5f));
|
||||
trail.enabled = cyclingCotroller.CurrentPlayer.power > 0;
|
||||
|
||||
timer += Time.deltaTime;
|
||||
|
||||
while (timer >= 1)
|
||||
{
|
||||
CreateMiniPath();
|
||||
timer = 0;
|
||||
}
|
||||
CreateMiniPath();
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool init = false;
|
||||
private void _map_OnInitialized()
|
||||
{
|
||||
init = true;
|
||||
@ -94,10 +99,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#region Camera 自适应
|
||||
|
||||
/// <summary>
|
||||
/// https://github.com/mapbox/mapbox-unity-sdk/issues/1580
|
||||
/// </summary>
|
||||
@ -123,6 +126,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
_map.UpdateMap();
|
||||
return (int)Math.Floor(zoom);
|
||||
}
|
||||
|
||||
private Vector2dBounds GetScreenBounds()
|
||||
{
|
||||
var screenWidth = UnityEngine.Screen.width;
|
||||
@ -135,76 +139,82 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
return new Vector2dBounds(new Vector2d(sw.x, sw.y), new Vector2d(ne.x, ne.y));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建小地图路线
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
CreateMiniRoute();
|
||||
}
|
||||
void CreateMiniRoute()
|
||||
|
||||
private void CreateMiniRoute()
|
||||
{
|
||||
var dat = new List<Vector3>();
|
||||
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
if (mapData == null) return;
|
||||
|
||||
var count = mapData.List.Count;
|
||||
var interval = Math.Max(Math.Ceiling(count / 100D), 1f);
|
||||
for (var i = 0; i < mapData.List.Count; i++)
|
||||
{
|
||||
if (i % interval == 0)
|
||||
{
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
item.y += 1f;
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
//创建小地图路线
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateLineRender(feat);
|
||||
}
|
||||
|
||||
private void CreateMiniPath()
|
||||
{
|
||||
var meshData = new MeshData();
|
||||
var dat = new List<Vector3>();
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
if (mapData != null)
|
||||
if (mapData == null) return;
|
||||
|
||||
var count = mapData.List.Count;
|
||||
var interval = Math.Max(Math.Ceiling(count / 100D), 1f);
|
||||
for (int i = 0; i < mapData.List.Count; i++)
|
||||
{
|
||||
var count = mapData.List.Count;
|
||||
var interval = Math.Max(Math.Ceiling(count / 100D), 1f);
|
||||
for (int i = 0; i < mapData.List.Count; i++)
|
||||
if (i % interval == 0)
|
||||
{
|
||||
if (i % interval == 0)
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
item.y += 5f;
|
||||
if (cyclingCotroller.CurrentPlayer.currentIndex >= i)
|
||||
{
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
item.y += 1f;
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateLineRender(feat);//创建小地图路线
|
||||
}
|
||||
}
|
||||
|
||||
void CreateMiniPath()
|
||||
{
|
||||
var dat = new List<Vector3>();
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
if (mapData != null)
|
||||
{
|
||||
var count = mapData.List.Count;
|
||||
var interval = Math.Max(Math.Ceiling(count / 100D), 1f);
|
||||
for (int i = 0; i < mapData.List.Count; i++)
|
||||
{
|
||||
if (i % interval == 0)
|
||||
{
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
item.y += 5f;
|
||||
if (cyclingCotroller.CurrentPlayer.currentIndex >= i)
|
||||
{
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateRedLineRender(feat);//创建小地图路线
|
||||
}
|
||||
//创建路径
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateRedLineRender(feat);
|
||||
}
|
||||
|
||||
//创建小地图路线
|
||||
void CreateLineRender(VectorFeatureUnity feat)
|
||||
private void CreateLineRender(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapRoute != null)
|
||||
{
|
||||
_mipMapRoute.Destroy();
|
||||
}
|
||||
_mipMapRoute = new GameObject("MiniMapRoute");
|
||||
_mipMapRoute.transform.parent = transform.parent;
|
||||
|
||||
_mipMapRoute = new GameObject("MiniMapRoute")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
parent = transform.parent
|
||||
}
|
||||
};
|
||||
|
||||
var lineRender = _mipMapRoute.AddComponent<LineRenderer>();
|
||||
|
||||
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/1"));
|
||||
lineRender.material = Resources.Load<Material>("UI/Material/1");
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.white;
|
||||
lineRender.startColor = Color.white;
|
||||
@ -219,18 +229,23 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
_mipMapRoute.layer = 9;
|
||||
_map.gameObject.SetActive(false);
|
||||
}
|
||||
GameObject _mipMapPath;
|
||||
void CreateRedLineRender(VectorFeatureUnity feat)
|
||||
|
||||
private void CreateRedLineRender(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapPath != null)
|
||||
{
|
||||
_mipMapPath.Destroy();
|
||||
}
|
||||
_mipMapPath = new GameObject("MiniMapPath");
|
||||
_mipMapPath.transform.parent = transform.parent;
|
||||
_mipMapPath = new GameObject("MiniMapPath")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
parent = transform.parent
|
||||
}
|
||||
};
|
||||
var lineRender = _mipMapPath.AddComponent<LineRenderer>();
|
||||
|
||||
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/2"));
|
||||
lineRender.material = pathMaterial;
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.red;
|
||||
lineRender.startColor = Color.red;
|
||||
@ -244,6 +259,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
lineRender.loop = false;
|
||||
_mipMapPath.layer = 9;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@ -4,30 +4,17 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public class OnlineVideoPlayer : AbstractVideoPlayer
|
||||
{
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
}
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
}
|
||||
|
||||
public override void ComputeAnimator()
|
||||
{
|
||||
base.ComputeAnimator();
|
||||
}
|
||||
|
||||
public override void ComputeAnimatorSpeed()
|
||||
{
|
||||
base.ComputeAnimatorSpeed();
|
||||
}
|
||||
public override void CreateHeadImage()
|
||||
{
|
||||
base.CreateHeadImage();
|
||||
if (Diff < 0)
|
||||
((RectTransform)head.transform).anchoredPosition = new Vector2(((RectTransform)head.transform).anchoredPosition.x, -800f);
|
||||
HideHeadRectTransform();
|
||||
}
|
||||
|
||||
//隐藏其他玩家的头像
|
||||
private void HideHeadRectTransform()
|
||||
{
|
||||
((RectTransform)head.transform).anchoredPosition = new Vector2(((RectTransform)head.transform).anchoredPosition.x, -800f);
|
||||
}
|
||||
|
||||
public override void SetPlayer(string name, double speed, double preDistance, double endDistance, double cadance, double heartRate, double wkg, int userId, double power, double currentPlayerDistance, int frame)
|
||||
3
Assets/Scripts/Scenes/AR/UI.meta
Normal file
3
Assets/Scripts/Scenes/AR/UI.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdac326eaff04872bcebc003689d480b
|
||||
timeCreated: 1683888648
|
||||
@ -1,9 +1,6 @@
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -24,6 +21,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public string Id;
|
||||
public string Rank;
|
||||
public string Name;
|
||||
private float timer = 1f;
|
||||
private VideoGameManager manager { get; set; }
|
||||
|
||||
private void Start()
|
||||
@ -31,7 +29,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
GetComponent<Button>().onClick.AddListener(ButtonListener);
|
||||
}
|
||||
private float timer = 1f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
@ -42,7 +40,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
var riders = manager.cyclingController?.riders;
|
||||
if (riders != null)
|
||||
{
|
||||
var current = riders.Where(c => c.UserId.ToString() == Id).FirstOrDefault();
|
||||
var current = riders.FirstOrDefault(c => c.UserId.ToString() == Id);
|
||||
if (current == null)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
@ -50,7 +48,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
@ -66,8 +63,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
genderLabel.text = contactInfo.Gender;
|
||||
idLabel.text = contactInfo.id;
|
||||
powerLabel.text = contactInfo.Power.ToString("f0") + "W";
|
||||
//master.SetActive(manager.CurrentPlayer.UserId.ToString() == contactInfo.id);
|
||||
}
|
||||
|
||||
public void UpdateItem(string name,string gender,string id)
|
||||
{
|
||||
nameLabel.text = name;
|
||||
@ -75,6 +72,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
idLabel.text = id;
|
||||
master.SetActive(manager.CurrentPlayer?.UserId.ToString() == id);
|
||||
}
|
||||
|
||||
private void ButtonListener()
|
||||
{
|
||||
if(manager._aRMode == VideoGameManager.ARMode.INSPECT)
|
||||
@ -1,10 +1,4 @@
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
class RankingScript: MonoBehaviour
|
||||
public class RankingScript: MonoBehaviour
|
||||
{
|
||||
GameObject Hide { get; set; }
|
||||
GameObject Show { get; set; }
|
||||
@ -30,24 +25,29 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
Month = transform.Find("Head/Month").gameObject;
|
||||
Week = transform.Find("Head/Week").gameObject;
|
||||
Day = transform.Find("Head/Day").gameObject;
|
||||
|
||||
MonthTxt = transform.Find("Head/Month/Text").GetComponent<Text>();
|
||||
MonthTxt.color = Color.red;
|
||||
WeekTxt = transform.Find("Head/Week/Text").GetComponent<Text>();
|
||||
DayTxt = transform.Find("Head/Day/Text").GetComponent<Text>();
|
||||
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
Container = transform.Find("List/Viewport/Content");
|
||||
Month.GetComponent<Text>();
|
||||
|
||||
UIManager.AddEvent(Hide, UnityEngine.EventSystems.EventTriggerType.PointerClick, Hidehandler);
|
||||
UIManager.AddEvent(Show, UnityEngine.EventSystems.EventTriggerType.PointerClick, Showhandler);
|
||||
UIManager.AddEvent(Month, UnityEngine.EventSystems.EventTriggerType.PointerClick, MonthClick);
|
||||
UIManager.AddEvent(Week, UnityEngine.EventSystems.EventTriggerType.PointerClick, WeekClick);
|
||||
UIManager.AddEvent(Day, UnityEngine.EventSystems.EventTriggerType.PointerClick, DayClick);
|
||||
Container = transform.Find("List/Viewport/Content");
|
||||
Month.GetComponent<Text>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UIManager.InitNow();//重置当前时间
|
||||
#endif
|
||||
Refresh();
|
||||
}
|
||||
|
||||
//TODO: 重构
|
||||
private void Refresh(string type = "month")
|
||||
{
|
||||
return;
|
||||
@ -1,5 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -8,10 +7,11 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public Slider PowerSlider;
|
||||
public Text PowerText;
|
||||
private VideoGameManager manager;
|
||||
// Start is called before the first frame update
|
||||
|
||||
void Start()
|
||||
{
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
//设置模拟功率
|
||||
PowerSlider.onValueChanged.AddListener(e =>
|
||||
{
|
||||
PowerText.text = e.ToString("f0") + "W";
|
||||
@ -1,6 +1,4 @@
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -36,5 +34,4 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,14 +13,19 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public class VideoUIManager : MonoBehaviour
|
||||
{
|
||||
private const float MAXPOWER = 450f;
|
||||
private const float MAXPOWER_RATE = 600f;
|
||||
private const float MAXHEARRATE = 200f;
|
||||
private const float MAXWKG = 6f;
|
||||
private const float MAX_HEART_RATIO = 0.9f;
|
||||
GameObject ComputerPanel { get; set; }
|
||||
GameObject WatchPanel { get; set; }
|
||||
GameObject explosive { get; set; }
|
||||
GameObject button;
|
||||
GameObject remainTime;
|
||||
VideoGameManager manager;
|
||||
VideoPlayer videoPlayer;
|
||||
const float MAXPOWER = 450f;
|
||||
const float MAXPOWER_RATE = 600f;
|
||||
const float MAXHEARRATE = 200f;
|
||||
const float MAXWKG = 6f;
|
||||
|
||||
Text infoText { get; set; }
|
||||
//ComputerPanel
|
||||
Text power { get; set; }
|
||||
@ -54,19 +59,17 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
Image ftpImage { get; set; }
|
||||
Text wkg { get; set; }
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
UIManager.SetModalPanel(transform.Find("ModalPanel").GetComponent<PFUIPanel>());
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
Init();
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (manager != null)
|
||||
{
|
||||
|
||||
mapName.text = manager.GetMapRoute().Name;
|
||||
if (manager.CurrentPlayer != null)
|
||||
{
|
||||
@ -81,19 +84,25 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
SetSlopePanel();
|
||||
ftpImage.fillAmount = (float)(manager.CurrentPlayer.wkg / MAXWKG);
|
||||
wkg.text = $"{manager.CurrentPlayer.wkg}w/kg";
|
||||
//心率过高的时候显示
|
||||
if (manager.CurrentPlayer.UserId == App.CurrentUser.Id)
|
||||
{
|
||||
explosive.SetActive(ComputeHearRateRatio(manager.CurrentPlayer.heartRate ?? 0) > MAX_HEART_RATIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
explosive.SetActive(false);
|
||||
}
|
||||
SetHeartRateAlert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//心率过高的时候显示
|
||||
private void SetHeartRateAlert()
|
||||
{
|
||||
if (manager.CurrentPlayer.UserId == App.CurrentUser.Id)
|
||||
{
|
||||
explosive.SetActive(ComputeHearRateRatio(manager.CurrentPlayer.heartRate ?? 0) > MAX_HEART_RATIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
explosive.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
//距离终点
|
||||
public void ShowUpRemainTime(double remain)
|
||||
{
|
||||
if (remain > 110) return;
|
||||
@ -116,10 +125,9 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
|
||||
private const float MAX_HEART_RATIO = 0.9f;
|
||||
// 220 - 年龄= 最大心率 ratio = heartRate /最大心率
|
||||
private float ComputeHearRateRatio(int heartRate)
|
||||
{
|
||||
// 220 - 年龄= 最大心率 ratio = heartRate /最大心率
|
||||
var age = DateTime.Now.Year - App.CurrentUser.Birthday?.Year;
|
||||
if (DateTime.Now.Month - App.CurrentUser.Birthday?.Month > 0 && DateTime.Now.Day - App.CurrentUser.Birthday?.Day > 0)
|
||||
{
|
||||
@ -143,9 +151,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
ComputerPanel.SetActive(true);
|
||||
}
|
||||
}
|
||||
GameObject ComputerPanel { get; set; }
|
||||
GameObject WatchPanel { get; set; }
|
||||
GameObject explosive { get; set; }
|
||||
|
||||
private void Init()
|
||||
{
|
||||
remainTime = transform.Find("Panel/Remain").gameObject;
|
||||
@ -242,7 +248,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
manager._viewMode = manager._viewMode == ViewMode.THIRD ? ViewMode.FIRST : ViewMode.THIRD;
|
||||
if (manager._viewMode == ViewMode.FIRST)
|
||||
{
|
||||
ftpPanel.SetActive(true);
|
||||
ftpPanel.SetActive(manager._aRMode != ARMode.INSPECT);
|
||||
nearByScript.Hidehandler(null);
|
||||
rankingScript.Hidehandler(null);
|
||||
cameraImage.SetActive(true);
|
||||
@ -3,10 +3,10 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
class WatchPanelScript:MonoBehaviour
|
||||
public class WatchPanelScript:MonoBehaviour
|
||||
{
|
||||
VideoGameManager manager { get; set; }
|
||||
Text userName { get; set; }
|
||||
private VideoGameManager manager { get; set; }
|
||||
private Text userName { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
@ -37,26 +37,16 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public CyclingModel cyclingModel { get; set; }
|
||||
public BaseCycling cyclingController { get; set; }
|
||||
private double endDistance { get; set; }
|
||||
GameObject infoPanel;
|
||||
GameObject Player;
|
||||
GameObject Player_NV;
|
||||
GameObject OnlinePlayer;
|
||||
GameObject OnlinePlayer_NV;
|
||||
private GameObject infoPanel;
|
||||
private GameObject Player;
|
||||
private GameObject Player_NV;
|
||||
private GameObject OnlinePlayer;
|
||||
private GameObject OnlinePlayer_NV;
|
||||
|
||||
private bool isStop { get; set; }
|
||||
public enum ARMode
|
||||
{
|
||||
RIDE,
|
||||
INSPECT
|
||||
}
|
||||
|
||||
public enum ViewMode
|
||||
{
|
||||
THIRD,
|
||||
FIRST,
|
||||
}
|
||||
|
||||
VideoLoading videoLoading { get; set; }
|
||||
|
||||
//当前是第一人称还是第三人称
|
||||
public ViewMode _viewMode { get; set; }
|
||||
//当前是观察者视角还是骑行者视角
|
||||
@ -436,20 +426,24 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
if (cyclingController.recorderData == null || cyclingController.recorderData.Saved)
|
||||
return;
|
||||
|
||||
Quit();
|
||||
|
||||
cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
|
||||
var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId;
|
||||
Assets.Scenes.Ride.Scripts.Helper.CreateDirectoryIfNotExsit(path);
|
||||
string imageFileName = path + "/" + Guid.NewGuid().ToString() + ".png";
|
||||
Helper.CreateDirectoryIfNotExsit(path);
|
||||
var imageFileName = path + "/" + Guid.NewGuid().ToString() + ".png";
|
||||
Helper.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;
|
||||
cyclingController.recorderData.EndDistance = totalDistance;
|
||||
cyclingController.recorderData.EndDistance = cyclingController.recorderData.IsCompleted ? mapData.TotalDistance : totalDistance;
|
||||
cyclingController.recorderData.AntModelId = AntModelId;
|
||||
cyclingController.recorderData.ManufacturerId = ManufacturerId;
|
||||
cyclingController.recorderData.ManufacturerName = ManufacturerName;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
cyclingController.recorderData.LastFrame = GetCurrentFrame();
|
||||
|
||||
RankingId = cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
}
|
||||
public void AddEvent(GameObject sender, EventTriggerType eventType, UnityAction<BaseEventData> unityAction)
|
||||
@ -483,5 +477,17 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
App.gameRoomDetail = null;
|
||||
}
|
||||
|
||||
public enum ARMode
|
||||
{
|
||||
RIDE,
|
||||
INSPECT
|
||||
}
|
||||
|
||||
public enum ViewMode
|
||||
{
|
||||
THIRD,
|
||||
FIRST,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
private bool isSingle = true;
|
||||
VideoUIManager _uimanager;
|
||||
private bool gameRoomHandled { get; set; }
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
@ -62,7 +64,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
//比人先完成触发关门时间
|
||||
HandleForGameRoom();
|
||||
}
|
||||
private bool gameRoomHandled { get; set; }
|
||||
|
||||
//房间倒计时保存
|
||||
private void HandleForGameRoom()
|
||||
{
|
||||
@ -1,10 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Scenes
|
||||
@ -13,11 +9,11 @@ namespace Assets.Scripts.Scenes
|
||||
{
|
||||
UnityEngine.Ping ping;
|
||||
bool isNetWorkLose = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Debug.Log("base scene awake");
|
||||
Application.logMessageReceived += Application_logMessageReceived;
|
||||
StopCoroutine("Ping");
|
||||
StopCoroutine(Ping());
|
||||
StartCoroutine(Ping());
|
||||
}
|
||||
|
||||
@ -32,7 +28,6 @@ namespace Assets.Scripts.Scenes
|
||||
|
||||
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
||||
{
|
||||
//Debug.Log("application log");
|
||||
if (type == LogType.Error || type == LogType.Exception)
|
||||
{
|
||||
string log = $"time:{ System.DateTime.Now.ToString() }\r\n";
|
||||
@ -40,8 +35,6 @@ namespace Assets.Scripts.Scenes
|
||||
log += $"msg:{ condition }\r\n";
|
||||
log += $"stack trace:{ stackTrace }\r\n";
|
||||
System.IO.File.AppendAllText($"{PFConstants.LogFolder}\\{ System.DateTime.Now.ToString("yyyy-MM-dd") }.txt", log);
|
||||
|
||||
//Debug.Log(PFConstants.LogFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +45,12 @@ namespace Assets.Scripts.Scenes
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
//释放资源
|
||||
private void Release()
|
||||
{
|
||||
var objAry = Resources.FindObjectsOfTypeAll<Material>();
|
||||
|
||||
@ -79,6 +78,7 @@ namespace Assets.Scripts.Scenes
|
||||
UIManager.InitNow();//重置当前时间
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
@ -90,7 +90,6 @@ namespace Assets.Scripts.Scenes
|
||||
{
|
||||
isNetWorkLose = false;
|
||||
App.delayTime = ping.time;
|
||||
//Debug.Log(App.delayTime);
|
||||
ping.DestroyPing();
|
||||
ping = null;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//显示倒计时面板信息
|
||||
ShowCountDown(s.Item1, App.GetLocalString("Close Gate"));
|
||||
#else
|
||||
ShowCountDown(s.Item1, App.GetLocalString("Get The First Place. Close Gate"));
|
||||
ShowCountDown(s.Item1, App.GetLocalString("GetCloseGate"));
|
||||
#endif
|
||||
}
|
||||
else if (s.Item1 >= 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user