ui调整
This commit is contained in:
parent
57940568c9
commit
bf48989a9c
BIN
Assets/Resources/UI/Prefab/AR/icon_paihang_PC.png
Normal file
BIN
Assets/Resources/UI/Prefab/AR/icon_paihang_PC.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 392 B |
128
Assets/Resources/UI/Prefab/AR/icon_paihang_PC.png.meta
Normal file
128
Assets/Resources/UI/Prefab/AR/icon_paihang_PC.png.meta
Normal file
@ -0,0 +1,128 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1659a9a675563e40b537157235848b1
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Resources/UI/Prefab/AR/icon_watching_PC.png
Normal file
BIN
Assets/Resources/UI/Prefab/AR/icon_watching_PC.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 922 B |
128
Assets/Resources/UI/Prefab/AR/icon_watching_PC.png.meta
Normal file
128
Assets/Resources/UI/Prefab/AR/icon_watching_PC.png.meta
Normal file
@ -0,0 +1,128 @@
|
||||
fileFormatVersion: 2
|
||||
guid: caf04fd9a81864c4883a7191f385d949
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@ -119,5 +119,9 @@ namespace Assets.Scripts.Apis.Models
|
||||
public int[] RouteIds { get; set; }
|
||||
//最近骑行列表使用
|
||||
public RouteResult RecentRecord { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public int FileSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using ChartAndGraph;
|
||||
using DG.Tweening;
|
||||
using Mapbox.Utils;
|
||||
using System;
|
||||
@ -18,8 +19,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public double speed;
|
||||
public double power;
|
||||
protected double elevation;
|
||||
protected double cadance;
|
||||
protected int? heartRate { get; set; }
|
||||
public double cadance;
|
||||
public int? heartRate { get; set; }
|
||||
public int ticks;
|
||||
public double totalDistance;
|
||||
protected double currentSlope;
|
||||
@ -29,8 +30,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
protected double currentSlopeDistance;
|
||||
protected double lastEndDistance;
|
||||
public double totalClimb;
|
||||
protected Vector2d currentlatLon;
|
||||
protected int currentIndex;
|
||||
public Vector2d currentlatLon;
|
||||
public int currentIndex;
|
||||
protected float bearing = 0f;
|
||||
protected MapDataModel mapData;
|
||||
protected bool isHit = false;
|
||||
@ -40,6 +41,11 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
protected VideoGameManager manager { get; set; }
|
||||
Camera camera;
|
||||
float currenPlayerHeight;
|
||||
|
||||
//UI对象
|
||||
protected GameObject headPanel;
|
||||
protected GraphChartBase graph;
|
||||
protected ChartDataSourceScript chartDataSourceScript;
|
||||
protected virtual void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
@ -48,15 +54,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
ComputeNextSlope();//初始化坡度等
|
||||
animator.Play("idle");
|
||||
camera = Camera.main;
|
||||
|
||||
//注解1
|
||||
//得到模型原始高度
|
||||
float size_y = GetComponent<Collider>().bounds.size.y;
|
||||
//得到模型缩放比例
|
||||
float scal_y = transform.localScale.y;
|
||||
//它们的乘积就是高度
|
||||
currenPlayerHeight = (size_y * scal_y);
|
||||
|
||||
|
||||
var GraphChart = manager.GetCanvasTransform().Find("GraphChart").gameObject;
|
||||
chartDataSourceScript = GraphChart.GetComponent<ChartDataSourceScript>();
|
||||
graph = GraphChart.GetComponent<GraphChartBase>();
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
@ -68,12 +69,13 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
try
|
||||
{
|
||||
ComputeNextSlope();//计算下一个坡度
|
||||
ComputePlayer();//计算人物属性
|
||||
//animator.Play("touchHead");
|
||||
if (manager.IsStart())
|
||||
{
|
||||
ticks++;
|
||||
ComputeNextSlope();//计算下一个坡度
|
||||
ComputePlayer();//计算人物属性
|
||||
Forward();
|
||||
ComputeRecord();
|
||||
ComputeVideo();
|
||||
RayCastHit();
|
||||
@ -187,9 +189,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
preSpeed = speed;
|
||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||
distance = Math.Round(speed / 3600, 5, MidpointRounding.AwayFromZero);
|
||||
totalDistance += distance;
|
||||
currentlatLon = manager.Along(totalDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,6 +197,13 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
|
||||
private void Forward()
|
||||
{
|
||||
distance = Math.Round(speed / 3600, 5, MidpointRounding.AwayFromZero);
|
||||
totalDistance += distance;
|
||||
currentlatLon = manager.Along(totalDistance);
|
||||
}
|
||||
|
||||
protected virtual void ComputeVideo(){ }
|
||||
|
||||
protected virtual void ComputeRecord() { }
|
||||
@ -265,6 +271,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
head.transform.position = playerScreenPos;
|
||||
}
|
||||
}
|
||||
protected virtual void MoveGraphHead(bool init = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
|
||||
245
Assets/Scripts/Scenes/VideoRide/InitMiniMapScript.cs
Normal file
245
Assets/Scripts/Scenes/VideoRide/InitMiniMapScript.cs
Normal file
@ -0,0 +1,245 @@
|
||||
using Mapbox.Unity.Map;
|
||||
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
|
||||
{
|
||||
public class InitMiniMapScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
AbstractMap _map;
|
||||
[SerializeField]
|
||||
Camera _minicamera;
|
||||
[SerializeField]
|
||||
GameObject _player;
|
||||
VideoGameManager cyclingCotroller;
|
||||
public VideoPlayer playerController;
|
||||
GameObject _mipMapRoute;
|
||||
public RectTransform RectRoot;//rawImage
|
||||
TrailRenderer trail;
|
||||
Transform uitransform { get; set; }
|
||||
void Start()
|
||||
{
|
||||
cyclingCotroller = FindObjectOfType<VideoGameManager>();
|
||||
|
||||
if (cyclingCotroller != null)
|
||||
{
|
||||
var mapdata = cyclingCotroller.GetMapData();
|
||||
//初始化map
|
||||
//var point = cyclingCotroller.GetCenterCoordinate();
|
||||
if (_map != null && mapdata != 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]));
|
||||
var screenBounds = GetScreenBounds();
|
||||
var z = SetZoomToFitBounds(targetbounds, screenBounds);
|
||||
}
|
||||
uitransform = cyclingCotroller.GetCanvasTransform();
|
||||
RectRoot = uitransform.Find("MiniMap/MiniMap").GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
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 = 0;
|
||||
private void Update()
|
||||
{
|
||||
if (playerController != null)
|
||||
{
|
||||
var tr = uitransform.Find("MiniMap/MiniMap/arrow");
|
||||
tr.SetSiblingIndex(9999);
|
||||
var pos = _map.GeoToWorldPosition(playerController.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 = playerController.power > 0;
|
||||
}
|
||||
timer += Time.deltaTime;
|
||||
|
||||
while (timer >= 1)
|
||||
{
|
||||
CreateMiniPath();
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
void CreateMiniPath()
|
||||
{
|
||||
if (playerController == null)
|
||||
return;
|
||||
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 (playerController.currentIndex >= i)
|
||||
{
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateRedLineRender(feat);//创建小地图路线
|
||||
}
|
||||
}
|
||||
|
||||
private bool init = false;
|
||||
private void _map_OnInitialized()
|
||||
{
|
||||
init = true;
|
||||
var visualizer = _map.MapVisualizer;
|
||||
visualizer.OnMapVisualizerStateChanged += (s) =>
|
||||
{
|
||||
if (s == ModuleState.Finished)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#region Camera 自适应
|
||||
/// <summary>
|
||||
/// https://github.com/mapbox/mapbox-unity-sdk/issues/1580
|
||||
/// </summary>
|
||||
/// <param name="targetBounds">路线的边界</param>
|
||||
/// <param name="screenBounds">小地图边界</param>
|
||||
private int SetZoomToFitBounds(Vector2dBounds targetBounds, Vector2dBounds screenBounds)
|
||||
{
|
||||
var targetLonDelta = targetBounds.East - targetBounds.West;
|
||||
var targetLatDelta = targetBounds.North - targetBounds.South;
|
||||
|
||||
var screenLonDelta = screenBounds.East - screenBounds.West;
|
||||
var screenLatDelta = screenBounds.North - screenBounds.South;
|
||||
|
||||
var zoomLatMultiplier = screenLatDelta / targetLatDelta;
|
||||
var zoomLonMultiplier = screenLonDelta / targetLonDelta;
|
||||
|
||||
var latZoom = Math.Log(zoomLatMultiplier, 2);
|
||||
var lonZoom = Math.Log(zoomLonMultiplier, 2);
|
||||
|
||||
var zoom = (float)(_map.Zoom + Math.Min(latZoom, lonZoom));
|
||||
|
||||
_map.SetZoom((float)Math.Floor(zoom));
|
||||
_map.UpdateMap();
|
||||
return (int)Math.Floor(zoom);
|
||||
}
|
||||
private Vector2dBounds GetScreenBounds()
|
||||
{
|
||||
var screenWidth = UnityEngine.Screen.width;
|
||||
var screenHeight = UnityEngine.Screen.height;
|
||||
|
||||
var sw_world = _minicamera.ViewportToWorldPoint(new Vector3(0.25f, 0.1f, 160));
|
||||
var sw = _map.WorldToGeoPosition(sw_world);
|
||||
var ne_world = _minicamera.ViewportToWorldPoint(new Vector3(0.75f, 0.9f, 90));
|
||||
var ne = _map.WorldToGeoPosition(ne_world);
|
||||
|
||||
return new Vector2dBounds(new Vector2d(sw.x, sw.y), new Vector2d(ne.x, ne.y));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建小地图路线
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
CreateMiniRoute();
|
||||
}
|
||||
void CreateMiniRoute()
|
||||
{
|
||||
var meshData = new MeshData();
|
||||
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 += 1f;
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateLineRender(feat);//创建小地图路线
|
||||
}
|
||||
}
|
||||
//创建小地图路线
|
||||
void CreateLineRender(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapRoute != null)
|
||||
{
|
||||
_mipMapRoute.Destroy();
|
||||
}
|
||||
_mipMapRoute = new GameObject("MiniMapRoute");
|
||||
_mipMapRoute.transform.parent = transform;
|
||||
var lineRender = _mipMapRoute.AddComponent<LineRenderer>();
|
||||
|
||||
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/1"));
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.white;
|
||||
lineRender.startColor = Color.white;
|
||||
//设置宽度
|
||||
lineRender.startWidth = 10f;
|
||||
lineRender.endWidth = 10f;
|
||||
lineRender.positionCount = dat.Count;
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.numCornerVertices = 20;
|
||||
lineRender.numCapVertices = 20;
|
||||
lineRender.loop = false;
|
||||
_mipMapRoute.layer = 9;
|
||||
}
|
||||
GameObject _mipMapPath;
|
||||
void CreateRedLineRender(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapPath != null)
|
||||
{
|
||||
_mipMapPath.Destroy();
|
||||
}
|
||||
_mipMapPath = new GameObject("MiniMapPath");
|
||||
_mipMapPath.transform.parent = transform;
|
||||
var lineRender = _mipMapPath.AddComponent<LineRenderer>();
|
||||
|
||||
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/2"));
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.red;
|
||||
lineRender.startColor = Color.red;
|
||||
//设置宽度
|
||||
lineRender.startWidth = 10f;
|
||||
lineRender.endWidth = 10f;
|
||||
lineRender.positionCount = dat.Count;
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.numCornerVertices = 20;
|
||||
lineRender.numCapVertices = 20;
|
||||
lineRender.loop = false;
|
||||
_mipMapPath.layer = 9;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Scenes/VideoRide/InitMiniMapScript.cs.meta
Normal file
11
Assets/Scripts/Scenes/VideoRide/InitMiniMapScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c536d01b43b2f643a86ef176910485a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/Scenes/VideoRide/NearByScript.cs
Normal file
50
Assets/Scripts/Scenes/VideoRide/NearByScript.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public class NearByScript: MonoBehaviour
|
||||
{
|
||||
Text rideNum {get;set;}
|
||||
Text btnRideNum { get; set; }
|
||||
GameObject Hide { get; set; }
|
||||
GameObject Show { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
rideNum = transform.Find("Head/RideNum/Number").GetComponent<Text>();
|
||||
btnRideNum = transform.Find("Head/Show/Panel/Number").GetComponent<Text>();
|
||||
Hide = transform.Find("Head/Hide").gameObject;
|
||||
Show = transform.Find("Head/Show").gameObject;
|
||||
UIManager.AddEvent(Hide, UnityEngine.EventSystems.EventTriggerType.PointerClick, Hidehandler);
|
||||
UIManager.AddEvent(Show, UnityEngine.EventSystems.EventTriggerType.PointerClick, Showhandler);
|
||||
}
|
||||
private void Hidehandler(BaseEventData data)
|
||||
{
|
||||
transform.DOLocalMoveX(913, 1f).onComplete += () => {
|
||||
Show.SetActive(true);
|
||||
Hide.SetActive(false);
|
||||
};
|
||||
}
|
||||
private void Showhandler(BaseEventData data)
|
||||
{
|
||||
Show.SetActive(false);
|
||||
Hide.SetActive(true);
|
||||
transform.DOLocalMoveX(667.55f, 1f).onComplete += () => {
|
||||
|
||||
};
|
||||
}
|
||||
float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0) {
|
||||
rideNum.text = $"{MapUDPService.GetAllOnlineUserCount()}";
|
||||
btnRideNum.text = rideNum.text;
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Scenes/VideoRide/NearByScript.cs.meta
Normal file
11
Assets/Scripts/Scenes/VideoRide/NearByScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 626b431b9a468f94b89fce5f20a2cc36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Assets/Scripts/Scenes/VideoRide/NearVideoPlayerList.cs
Normal file
84
Assets/Scripts/Scenes/VideoRide/NearVideoPlayerList.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public struct ContactInfo
|
||||
{
|
||||
public string Name;
|
||||
public string Gender;
|
||||
public string id;
|
||||
}
|
||||
class NearVideoPlayerList : MonoBehaviour, IRecyclableScrollRectDataSource
|
||||
{
|
||||
[SerializeField]
|
||||
RecyclableScrollRect _recyclableScrollRect;
|
||||
|
||||
[SerializeField]
|
||||
private int _dataLength;
|
||||
|
||||
//Dummy data List
|
||||
private List<ContactInfo> _contactList = new List<ContactInfo>();
|
||||
|
||||
//Recyclable scroll rect's data source must be assigned in Awake.
|
||||
private void Awake()
|
||||
{
|
||||
InitData();
|
||||
_recyclableScrollRect.DataSource = this;
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
if (_contactList != null) _contactList.Clear();
|
||||
var list = MapUDPService.GetOnlineUsers(App.RouteIdParam);
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
ContactInfo obj = new ContactInfo();
|
||||
obj.Name = item.Name;
|
||||
obj.Gender = DateTime.Now.Millisecond.ToString();
|
||||
obj.id = item.Id.ToString();
|
||||
_contactList.Add(obj);
|
||||
}
|
||||
}
|
||||
float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
InitData();
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
|
||||
#region DATA-SOURCE
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. return the list length.
|
||||
/// </summary>
|
||||
public int GetItemCount()
|
||||
{
|
||||
return _contactList.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. Called for a cell every time it is recycled.
|
||||
/// Implement this method to do the necessary cell configuration.
|
||||
/// </summary>
|
||||
public void SetCell(ICell cell, int index)
|
||||
{
|
||||
//Casting to the implemented Cell
|
||||
var item = cell as ListItem;
|
||||
item.ConfigureCell(_contactList[index], index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Scenes/VideoRide/NearVideoPlayerList.cs.meta
Normal file
11
Assets/Scripts/Scenes/VideoRide/NearVideoPlayerList.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad9c66572ce69ea4fba3bc35e6db3d86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Scripts/Scenes/VideoRide/RankingScript.cs
Normal file
39
Assets/Scripts/Scenes/VideoRide/RankingScript.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
class RankingScript: MonoBehaviour
|
||||
{
|
||||
GameObject Hide { get; set; }
|
||||
GameObject Show { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
Hide = transform.Find("Head/Hide").gameObject;
|
||||
Show = transform.Find("Head/Show").gameObject;
|
||||
UIManager.AddEvent(Hide, UnityEngine.EventSystems.EventTriggerType.PointerClick, Hidehandler);
|
||||
UIManager.AddEvent(Show, UnityEngine.EventSystems.EventTriggerType.PointerClick, Showhandler);
|
||||
}
|
||||
private void Hidehandler(BaseEventData data)
|
||||
{
|
||||
transform.DOLocalMoveX(-913, 1f).onComplete+=()=> {
|
||||
Show.SetActive(true);
|
||||
Hide.SetActive(false);
|
||||
};
|
||||
}
|
||||
private void Showhandler(BaseEventData data)
|
||||
{
|
||||
Show.SetActive(false);
|
||||
Hide.SetActive(true);
|
||||
transform.DOLocalMoveX(-667, 1f).onComplete += () => {
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Scenes/VideoRide/RankingScript.cs.meta
Normal file
11
Assets/Scripts/Scenes/VideoRide/RankingScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5125c2c61c26934d858b75fa9dfd187
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -15,6 +15,8 @@ using TurfCS;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -26,7 +28,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
private MediaPlayer mediaPlayer { get; set; }
|
||||
private bool isStart { get; set; }
|
||||
private Route route { get; set; }
|
||||
private MapRoute mapRoute { get; set; }
|
||||
public MapRoute mapRoute { get; set; }
|
||||
public RouteResultParam selectParamModel;
|
||||
public RouteResult routeResult;
|
||||
public string recordId { get; set; }
|
||||
@ -38,9 +40,28 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public List<float> slots = new List<float>();
|
||||
GameObject infoPanel;
|
||||
GameObject OnlinePlayer;
|
||||
public enum ARMode
|
||||
{
|
||||
INSPECT,
|
||||
RIDE
|
||||
}
|
||||
public enum ViewMode
|
||||
{
|
||||
THIRD,
|
||||
FIRST,
|
||||
}
|
||||
//当前是观察者视角还是骑行者视角
|
||||
public ARMode _aRMode { get; set; }
|
||||
//当前是第一人称还是第三人称
|
||||
public ViewMode _viewMode { get; set; }
|
||||
|
||||
public int RankingId { get; set; }
|
||||
private async void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
#if UNITY_EDITOR
|
||||
App.RouteIdParam = 12353;
|
||||
#endif
|
||||
mediaPlayer = FindObjectOfType<MediaPlayer>();
|
||||
//自动登录
|
||||
if (App.CurrentUser == null)
|
||||
@ -50,7 +71,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||
//var check = CheckAnt();//初始化蓝牙设备
|
||||
recordId = Guid.NewGuid().ToString();
|
||||
MapUDPService.Init();//初始化TCP
|
||||
MockDirection();
|
||||
infoPanel = Resources.Load<GameObject>("UI/Prefab/Ride/OnlineInfoPanel");
|
||||
OnlinePlayer = Resources.Load<GameObject>("UI/Prefab/OnlineVideoPlayer");
|
||||
@ -59,13 +79,12 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
InitSlots();
|
||||
startTime = DateTime.Now;//UIManager.Now.GetDateTime();
|
||||
var videoPlayer = FindObjectOfType<VideoPlayer>();
|
||||
var mapApi = ConfigHelper.mapApi;
|
||||
const int routeId = 12353;
|
||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
||||
mapRoute = mapApi.GetById(routeId).data;
|
||||
var routeId = App.RouteIdParam;
|
||||
//获取路书
|
||||
GetMapRoute();
|
||||
GetMapData();
|
||||
route = new Route(mapData, mapRoute);
|
||||
CurrentPlayer = videoPlayer;
|
||||
|
||||
if (selectParamModel == null)
|
||||
{
|
||||
selectParamModel = new RouteResultParam
|
||||
@ -96,13 +115,13 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
Debug.Log($"当前在线人数:{ MapUDPService.GetAllOnlineUserCount()}");
|
||||
CreateOnlineUser(onlineRiders);
|
||||
timer += 1f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private int offSet = 50;
|
||||
private int currentOnlineCount = 0;
|
||||
//创建当前线路其他选手
|
||||
private void CreateOnlineUser(List<BaseRider> list)
|
||||
private void CreateOnlineUser(List<BaseRider> list)
|
||||
{
|
||||
var players = FindObjectsOfType<OnlineVideoPlayer>();
|
||||
var current = FindObjectOfType<VideoPlayer>();
|
||||
@ -129,18 +148,60 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
else
|
||||
{
|
||||
var diff = item.EndDistance - current.EndDistance;
|
||||
//进来观察 看谁呢 依据谁未中心构建其他玩家
|
||||
var diff = item.EndDistance - 0;//CurrentPlayer.EndDistance;
|
||||
if (diff < offSet)
|
||||
{
|
||||
var obj = Instantiate(OnlinePlayer, transform);
|
||||
var online = obj.GetComponent<OnlineVideoPlayer>();
|
||||
Debug.Log($"{onlineRider.EndDistance}={item.Power}={onlineRider.PreDistance}");
|
||||
online.SetPlayer(onlineRider.EndDistance, item.Cadence, item.HeartRate,item.UserId);
|
||||
online.SetPlayer(onlineRider.EndDistance, item.Cadence, item.HeartRate, item.UserId);
|
||||
obj.transform.DOMoveX(slots[currentOnlineCount], 1);
|
||||
currentOnlineCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//随机选择当前骑行的人作为观察对象
|
||||
if (_aRMode == ARMode.INSPECT && CurrentPlayer == null)
|
||||
{
|
||||
var currentPlayer = players.FirstOrDefault();
|
||||
if (currentPlayer != null)
|
||||
{
|
||||
ChangePlayer(currentPlayer.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
//设置当前是骑行模式还是观察模式
|
||||
public void SetCurrentMode(ARMode aRMode)
|
||||
{
|
||||
_aRMode = aRMode;
|
||||
var videoPlayer = FindObjectOfType<VideoPlayer>();
|
||||
if (_aRMode == ARMode.INSPECT)
|
||||
{
|
||||
videoPlayer?.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentPlayer = videoPlayer;
|
||||
}
|
||||
}
|
||||
//切换当前人物视角
|
||||
public void ChangeView()
|
||||
{
|
||||
var videoPlayer = FindObjectOfType<VideoPlayer>();
|
||||
var currentPlayer = CurrentPlayer == null? videoPlayer.transform : CurrentPlayer.transform;
|
||||
_viewMode = _viewMode == ViewMode.THIRD ? ViewMode.FIRST : ViewMode.THIRD;
|
||||
if (_viewMode == ViewMode.FIRST)
|
||||
{
|
||||
currentPlayer.DOMoveZ(-0.1f, 0f);
|
||||
currentPlayer.DOMoveY(-1.1f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPlayer.DOMoveZ(4, 0f);
|
||||
currentPlayer.DOMoveY(-1f, 0f);
|
||||
}
|
||||
}
|
||||
//切换人物
|
||||
public void ChangePlayer(int userId)
|
||||
@ -258,9 +319,14 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
if (mediaPlayer != null)
|
||||
{
|
||||
mediaPlayer.PlaybackRate = 1;//TODO:playbackRate;
|
||||
mediaPlayer.PlaybackRate = playbackRate;
|
||||
mediaPlayer.Play();
|
||||
}
|
||||
if (startTime == null)
|
||||
{
|
||||
startTime = UIManager.Now.GetDateTime();
|
||||
}
|
||||
isStart = true;
|
||||
}
|
||||
//暂停
|
||||
public void Pause()
|
||||
@ -289,11 +355,28 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
mediaPlayer?.Control.SeekToFrame(seq);
|
||||
}
|
||||
//获取路书信息
|
||||
//获取路书gps信息
|
||||
public MapDataModel GetMapData()
|
||||
{
|
||||
if (mapData == null)
|
||||
{
|
||||
var mapApi = ConfigHelper.mapApi;
|
||||
int routeId = App.RouteIdParam;
|
||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
||||
}
|
||||
return mapData;
|
||||
}
|
||||
//获取路书信息
|
||||
public MapRoute GetMapRoute()
|
||||
{
|
||||
if (mapRoute == null)
|
||||
{
|
||||
var mapApi = ConfigHelper.mapApi;
|
||||
int routeId = App.RouteIdParam;
|
||||
mapRoute = mapApi.GetById(routeId).data;
|
||||
}
|
||||
return mapRoute;
|
||||
}
|
||||
//保存骑行记录
|
||||
public void Save(double totalDistance)
|
||||
{
|
||||
@ -312,7 +395,20 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
cyclingController.recorderData.ManufacturerName = ManufacturerName;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
cyclingController.recorderData.LastFrame = GetCurrentFrame();
|
||||
var RankingId = cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
RankingId = cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
}
|
||||
public void GetUIPanel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddEvent(GameObject sender, EventTriggerType eventType, UnityAction<BaseEventData> unityAction)
|
||||
{
|
||||
UIManager.AddEvent(sender, eventType, unityAction);
|
||||
}
|
||||
public Texture GetCountryImageByCode(string code)
|
||||
{
|
||||
return UIManager.Instance.loginRegOptions.GetCountryImage(code);
|
||||
}
|
||||
//截图
|
||||
protected void CaptureCamera(Camera camera, Rect rect, string fileName)
|
||||
|
||||
@ -7,6 +7,7 @@ using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -22,12 +23,14 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
var button = transform.Find("Panel/Button").GetComponent<Button>();
|
||||
var Start = transform.Find("Panel/Start").GetComponent<Button>();
|
||||
var Back = transform.Find("Panel/Back").GetComponent<Button>();
|
||||
var Inspect = transform.Find("Panel/Inspect").gameObject;
|
||||
UIManager.AddEvent(Inspect, UnityEngine.EventSystems.EventTriggerType.PointerClick, InspectHandler);
|
||||
var canvasGroup = transform.GetComponent<CanvasGroup>();
|
||||
var ui = manager.GetCanvasTransform();
|
||||
|
||||
var route = manager.GetMapRoute();
|
||||
var text = transform.GetComponentInChildren<Text>();
|
||||
var fileName = "12067924_720p.mp4";
|
||||
var url = @"http://192.168.0.97:6031/12067924_720p.mp4";
|
||||
var fileName = route.FileName;// "12067924_720p.mp4";
|
||||
var url = route.Url; //@"http://192.168.0.97:6031/12067924_720p.mp4";
|
||||
var currentPath = "";
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
@ -72,6 +75,13 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
SceneManager.LoadScene("MainScene");
|
||||
});
|
||||
}
|
||||
//进入观察模式
|
||||
private void InspectHandler(BaseEventData data)
|
||||
{
|
||||
manager.SetCurrentMode(VideoGameManager.ARMode.INSPECT);
|
||||
var canvasGroup = transform.GetComponent<CanvasGroup>();
|
||||
canvasGroup.DOFade(0, 1);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@ -12,6 +13,12 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
base.Start();
|
||||
animator.Play("idle");
|
||||
|
||||
power = 200;
|
||||
;
|
||||
headPanel = manager.GetCanvasTransform().Find("GraphChart/HeadPanel").gameObject;
|
||||
MoveGraphHead(true);
|
||||
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -44,13 +51,27 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
protected override void ComputePlayer()
|
||||
{
|
||||
heartRate = manager.UpDateHeart();
|
||||
//power = manager.UpdatePower();
|
||||
power = manager.UpdatePower();
|
||||
cadance = manager.UpdateCadence();
|
||||
//TEST TODO
|
||||
power = 200;
|
||||
cadance = 150;
|
||||
heartRate = 160;
|
||||
weight = App.CurrentUser.Weight;
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
//发送阻力
|
||||
manager.TrackResistance(currentSlope);
|
||||
base.ComputePlayer();
|
||||
//一旦有功率就开始骑行、否则暂停
|
||||
if (power > 0)
|
||||
{
|
||||
manager.Play((float)speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.Pause();
|
||||
}
|
||||
|
||||
}
|
||||
//控制视频播放速度
|
||||
protected override void ComputeVideo()
|
||||
@ -104,5 +125,42 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
manager.Save(totalDistance);
|
||||
}
|
||||
}
|
||||
protected override void MoveGraphHead(bool init = false)
|
||||
{
|
||||
Vector3 oldPos = headPanel.transform.position;
|
||||
int nextIndex = currentIndex;
|
||||
var viewIndex = chartDataSourceScript.GetViewIndex(nextIndex);
|
||||
|
||||
var n = graph.DataSource.GetPoint("Player 2", viewIndex);
|
||||
graph.PointToWorldSpace(out Vector3 nextPosition, n.x, n.y, "Player 2");
|
||||
//nextPosition.x -= 14f;
|
||||
//nextPosition.y += 5f;
|
||||
//人物移动 停止条件 到中间且线未加载完
|
||||
if (manager.IsStart() && chartDataSourceScript.ReachMid(viewIndex) && !chartDataSourceScript.ReachEnd())
|
||||
{
|
||||
var currentDistance = totalDistance;
|
||||
var offset = currentDistance > 0 ? distance * 1000 / currentDistance : 1;
|
||||
if (UserId == manager.CurrentPlayer.UserId)
|
||||
{
|
||||
graph.HorizontalScrolling += offset;
|
||||
}
|
||||
var duration = init ? 0 : 1;
|
||||
headPanel.transform.DOMove(new Vector3(oldPos.x, nextPosition.y, 0), duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.position = new Vector3(nextPosition.x, nextPosition.y, 0);
|
||||
//headPanel.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 1);
|
||||
}
|
||||
headPanel.transform.SetAsLastSibling();
|
||||
}
|
||||
//保存骑行记录
|
||||
public void Upload()
|
||||
{
|
||||
if (manager.cyclingController.recorderData != null && !manager.cyclingController.recorderData.Saved)//处理重复上传的问题
|
||||
{
|
||||
manager.Save(totalDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
178
Assets/Scripts/Scenes/VideoRide/VideoResultScript.cs
Normal file
178
Assets/Scripts/Scenes/VideoRide/VideoResultScript.cs
Normal file
@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Facebook.Unity;
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
public class VideoResultScript : MonoBehaviour
|
||||
{
|
||||
#region 路书信息
|
||||
Text date;
|
||||
Text time;
|
||||
Text level;
|
||||
Text mapName;
|
||||
Text distance;
|
||||
RawImage country;
|
||||
RawImage altudeGraph;
|
||||
#endregion
|
||||
|
||||
#region 骑行结果
|
||||
Text rideTime;
|
||||
Text rideDistance;
|
||||
Text totalClimbed;
|
||||
Text wkgText;
|
||||
Text avCadence;
|
||||
Text avHeatrate;
|
||||
Text maxPower;
|
||||
Text avPower;
|
||||
Text maxSpeed;
|
||||
Text avSpeed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 功能按钮
|
||||
GameObject goResultBtn;
|
||||
GameObject cancelBtn;
|
||||
GameObject shareWxBtn;
|
||||
GameObject shareWxGpButton;
|
||||
Transform toolbar;
|
||||
Image DNF;
|
||||
Image newRecord;
|
||||
#endregion
|
||||
|
||||
VideoGameManager cyclingController;
|
||||
private void Awake()
|
||||
{
|
||||
#region 路书信息
|
||||
date = transform.Find("MapPanel/Date").GetComponent<Text>();
|
||||
time = transform.Find("MapPanel/Timer").GetComponent<Text>();
|
||||
level = transform.Find("MapPanel/Level/Text").GetComponent<Text>();
|
||||
mapName = transform.Find("MapPanel/MapName").GetComponent<Text>();
|
||||
distance = transform.Find("MapPanel/Distance").GetComponent<Text>();
|
||||
country = transform.Find("MapPanel/Country").GetComponent<RawImage>();
|
||||
altudeGraph = transform.Find("MapPanel/AltudeGraph").GetComponent<RawImage>();
|
||||
#endregion
|
||||
#region 骑行记录
|
||||
rideTime = transform.Find("TimePanel/Timer").GetComponent<Text>();
|
||||
rideDistance = transform.Find("DistancePanel/Distance").GetComponent<Text>();
|
||||
totalClimbed = transform.Find("FitPanel/TotalClimbedView/Value").GetComponent<Text>();
|
||||
wkgText = transform.Find("FitPanel/FTPView/Value").GetComponent<Text>();
|
||||
avCadence = transform.Find("FitPanel/CadenceView/Value").GetComponent<Text>();
|
||||
avHeatrate = transform.Find("FitPanel/HeartView/Value").GetComponent<Text>();
|
||||
maxPower = transform.Find("FitPanel/MaxPowerView/Value").GetComponent<Text>();
|
||||
avPower = transform.Find("FitPanel/AveragePowerView/Value").GetComponent<Text>();
|
||||
maxSpeed = transform.Find("FitPanel/MaxSpeedView/Value").GetComponent<Text>();
|
||||
avSpeed = transform.Find("FitPanel/AverageSpeed/Value").GetComponent<Text>();
|
||||
#endregion
|
||||
goResultBtn = transform.Find("ConFirmButton").gameObject;
|
||||
cancelBtn = transform.Find("CloseButton").gameObject;
|
||||
toolbar = transform.Find("ToolBarPanel");
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
shareWxBtn = transform.Find("ToolBarPanel/WeChatButton").gameObject;
|
||||
shareWxGpButton = transform.Find("ToolBarPanel/GoogleButton").gameObject;
|
||||
#endif
|
||||
DNF = transform.Find("DNF").GetComponent<Image>();
|
||||
newRecord = transform.Find("TimePanel/NewRecord").GetComponent<Image>();
|
||||
}
|
||||
|
||||
public void InjectController(VideoGameManager controller)
|
||||
{
|
||||
cyclingController = controller;
|
||||
controller.AddEvent(goResultBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, GoResult);
|
||||
controller.AddEvent(cancelBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Cancel);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
cyclingController.AddEvent(shareWxBtn, EventTriggerType.PointerClick, shareToWx);
|
||||
cyclingController.AddEvent(shareWxGpButton, EventTriggerType.PointerClick, shareToWxGp);
|
||||
var fbButton = transform.Find("ToolBarPanel/FaceBookButton").gameObject;
|
||||
cyclingController.AddEvent(fbButton, EventTriggerType.PointerClick, shareToFb);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void shareToFb(BaseEventData arg0)
|
||||
{
|
||||
FB.ShareLink(contentURL: new Uri($"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}"),
|
||||
contentTitle: cyclingController.mapRoute.Name,
|
||||
contentDescription: "By " + App.CurrentUser.Nickname,
|
||||
photoURL: new Uri(cyclingController.mapRoute.CoverImage));
|
||||
}
|
||||
|
||||
private void shareToWx(BaseEventData b)
|
||||
{
|
||||
if (App.weChatController.IsWeChatAppInstalled())
|
||||
{
|
||||
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(null, "未安装微信");
|
||||
}
|
||||
}
|
||||
|
||||
private void shareToWxGp(BaseEventData b)
|
||||
{
|
||||
if (App.weChatController.IsWeChatAppInstalled())
|
||||
{
|
||||
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(null, "未安装微信");
|
||||
}
|
||||
}
|
||||
|
||||
private void GoResult(BaseEventData baseEventData)
|
||||
{
|
||||
if (App.MainSceneParam.ContainsKey("Name"))
|
||||
{
|
||||
App.MainSceneParam["Name"] = "UserInfoPanel";
|
||||
}
|
||||
else
|
||||
{
|
||||
App.MainSceneParam.Add("Name", "UserInfoPanel");
|
||||
}
|
||||
|
||||
Application.OpenURL($"{App.CurrentUser.WebHost}Mine/Detail/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}");
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
|
||||
private void Cancel(BaseEventData baseEventData)
|
||||
{
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
public void SetDataSource(RecorderDataModel record)
|
||||
{
|
||||
var route = record.CurrentRoute.RouteInstance;
|
||||
var dataformt = App.GetLocalLanguage().Equals("zh") ? "yyyy-MM-dd" : "dd-MM-yyyy";
|
||||
date.text = record.StartTime.ToString(dataformt);
|
||||
time.text = record.StartTime.ToShortTimeString();
|
||||
level.text = route.Hard;
|
||||
mapName.text = route.Name;
|
||||
distance.text = route.Distance.ToString("f1") + "KM";
|
||||
country.texture = cyclingController.GetCountryImageByCode(route.CountryCode);
|
||||
Utils.DisplayImage(altudeGraph, route.AltitudeGraph);
|
||||
//绑定骑行记录结果
|
||||
rideTime.text = Helper.FormatTicks(record.RiderDatas.Count);
|
||||
rideDistance.text = record.RiderDatas.Last()._Distance.ToString("f1") + "KM";
|
||||
totalClimbed.text = record.RiderDatas.Last()._TotalClimb.ToString("f1");
|
||||
var power = Math.Round(record.RiderDatas.Average(c => c._Power), 0);
|
||||
avPower.text = power.ToString();
|
||||
maxPower.text = record.RiderDatas.Max(c => c._Power).ToString("f0");
|
||||
avHeatrate.text = record.RiderDatas.Average(c => c._HeartRate.GetValueOrDefault(0)).ToString("f0");
|
||||
avSpeed.text = record.RiderDatas.Average(c => c._Speed).ToString("f1");
|
||||
maxSpeed.text = record.RiderDatas.Max(c => c._Speed).ToString("f1");
|
||||
wkgText.text = Math.Round(power / record.CurrentUser.Weight, 2).ToString();
|
||||
avCadence.text = record.RiderDatas.Average(c => c._Cadence).GetValueOrDefault(0).ToString("f0");
|
||||
|
||||
DNF.gameObject.SetActive(!record.IsCompleted);
|
||||
var recordImagePath = App.GetLocalLanguage().Equals("zh") ? "Images/Ride/img_newrecord_cn" : "img_newrecord";
|
||||
newRecord.sprite = Resources.Load<Sprite>(recordImagePath);
|
||||
newRecord.gameObject.SetActive(record.IsCompleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Scenes/VideoRide/VideoResultScript.cs.meta
Normal file
11
Assets/Scripts/Scenes/VideoRide/VideoResultScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf670cbf2ee31f54e948d1ae90112d81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,9 +1,14 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@ -12,7 +17,33 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
GameObject button;
|
||||
VideoGameManager manager;
|
||||
VideoPlayer videoPlayer;
|
||||
const float MAXPOWER = 450f;
|
||||
const float MAXPOWER_RATE = 6f;
|
||||
const float MAXHEARRATE = 200f;
|
||||
private ChartDataSourceScript chartDataSourceScript;
|
||||
Text infoText { get; set; }
|
||||
//ComputerPanel
|
||||
Text power { get; set; }
|
||||
Text cadance { get; set; }
|
||||
Text heartRate { get; set; }
|
||||
Text speed { get; set; }
|
||||
Text totalDistance { get; set; }
|
||||
Text totalClimbed { get; set; }
|
||||
Text ridingTime { get; set; }
|
||||
Image left { get; set; }
|
||||
Image right { get; set; }
|
||||
//ToolBarPanel
|
||||
GameObject pauseBtn { get; set; }
|
||||
GameObject deviceBtn { get; set; }
|
||||
GameObject changeViewBtn { get; set; }
|
||||
GameObject quitBtn { get; set; }
|
||||
//minimap
|
||||
Text playerTimer { get; set; }
|
||||
Text distance { get; set; }
|
||||
//modal
|
||||
GameObject settingPanel { get; set; }
|
||||
GameObject resultPanel { get; set; }
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -20,18 +51,132 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
manager = FindObjectOfType<VideoGameManager>();
|
||||
videoPlayer = FindObjectOfType<VideoPlayer>();
|
||||
button = transform.Find("Panel/Button").gameObject;
|
||||
Init();
|
||||
RenderChart();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
power = transform.Find("Panel/ComputerPanel/Power").GetComponent<Text>();
|
||||
cadance = transform.Find("Panel/ComputerPanel/Cadance").GetComponent<Text>();
|
||||
heartRate = transform.Find("Panel/ComputerPanel/Hr").GetComponent<Text>();
|
||||
speed = transform.Find("Panel/ComputerPanel/Speed").GetComponent<Text>();
|
||||
left = transform.Find("Panel/ComputerPanel/Left").GetComponent<Image>();
|
||||
right = transform.Find("Panel/ComputerPanel/Right").GetComponent<Image>();
|
||||
//ToolBarPanel
|
||||
pauseBtn = transform.Find("Panel/ToolBarPanel/StartOrPauseButton").gameObject;
|
||||
quitBtn = transform.Find("Panel/ToolBarPanel/ExitButton").gameObject;
|
||||
changeViewBtn = transform.Find("Panel/ToolBarPanel/ChangeView").gameObject;
|
||||
deviceBtn = transform.Find("Panel/ToolBarPanel/DeviceButton").gameObject;
|
||||
//minmap
|
||||
playerTimer = transform.Find("Panel/MiniMap/MiniMap/Panel/Timer").GetComponent<Text>();
|
||||
distance = transform.Find("Panel/MiniMap/MiniMap/Panel/Distance").GetComponent<Text>();
|
||||
//modal
|
||||
settingPanel = transform.Find("Panel/SettingPanel").gameObject;
|
||||
resultPanel = transform.Find("Panel/ResultPanel").gameObject;
|
||||
//toolbar 事件注册
|
||||
UIManager.AddEvent(pauseBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, PauseClick);
|
||||
UIManager.AddEvent(changeViewBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, ChangeViewClick);
|
||||
UIManager.AddEvent(deviceBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, DeviceClick);
|
||||
UIManager.AddEvent(quitBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, QuitClick);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (videoPlayer != null && manager != null)
|
||||
{
|
||||
//infoText.text = $"帧数:{manager.GetCurrentFrame()}";
|
||||
power.text = Math.Round(videoPlayer.power).ToString();
|
||||
speed.text = Math.Round(videoPlayer.speed).ToString();
|
||||
heartRate.text = Math.Round((videoPlayer.heartRate ?? 0d)).ToString();
|
||||
cadance.text = Math.Round(videoPlayer.cadance).ToString();
|
||||
playerTimer.text = Helper.FormatTicks(videoPlayer.ticks);
|
||||
distance.text = Math.Round((videoPlayer.totalDistance)).ToString();
|
||||
if (App.CurrentUser != null)
|
||||
{
|
||||
left.fillAmount = (float)(Math.Round(videoPlayer.power) / MAXPOWER_RATE);
|
||||
right.fillAmount = (float)(Math.Round((videoPlayer.heartRate ?? 0f)) / MAXHEARRATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PauseClick(BaseEventData e)
|
||||
{
|
||||
manager.Pause();
|
||||
}
|
||||
private void DeviceClick(BaseEventData e)
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, null, true);
|
||||
}
|
||||
private void ChangeViewClick(BaseEventData e)
|
||||
{
|
||||
manager.ChangeView();
|
||||
}
|
||||
private void QuitClick(BaseEventData e)
|
||||
{
|
||||
UIManager.ShowConfirm("Quit", "Do you want to keep the record?",
|
||||
() => {
|
||||
videoPlayer?.Upload();
|
||||
UIManager.CloseConfirm();
|
||||
//show result
|
||||
resultPanel.SetActive(true);
|
||||
resultPanel.transform.SetAsLastSibling();
|
||||
var videoResultScript = resultPanel.GetComponent<VideoResultScript>();
|
||||
videoResultScript.InjectController(manager);
|
||||
videoResultScript.SetDataSource(manager.cyclingController.recorderData);
|
||||
},
|
||||
2,
|
||||
() => {
|
||||
UIManager.CloseConfirm();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
GameObject GraphChart { get; set; }
|
||||
GraphChartBase Graph { get; set; }
|
||||
private void RenderChart()
|
||||
{
|
||||
var mapData = manager.GetMapData();
|
||||
double x = 0;
|
||||
Dictionary<double, double> dataSource = new Dictionary<double, double>();
|
||||
List<double> dd = new List<double>();
|
||||
foreach (var item in mapData.List)
|
||||
{
|
||||
if (!dataSource.ContainsKey(x))
|
||||
{
|
||||
dataSource.Add(x, item.Elevation);
|
||||
}
|
||||
x += item.Distance;
|
||||
dd.Add(item.Elevation);
|
||||
}
|
||||
GraphChart = transform.Find("Panel/GraphChart").gameObject;
|
||||
chartDataSourceScript = GraphChart.GetComponent<ChartDataSourceScript>();
|
||||
Graph = GraphChart.GetComponent<GraphChartBase>();
|
||||
chartDataSourceScript.SetDataSource(dd.ToArray());
|
||||
}
|
||||
|
||||
#region
|
||||
|
||||
private void EventHandler()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
GameObject start = transform.Find("Panel/start").gameObject;
|
||||
GameObject stop = transform.Find("Panel/stop").gameObject;
|
||||
GameObject save = transform.Find("Panel/save").gameObject;
|
||||
|
||||
GameObject left = transform.Find("Panel/left").gameObject;
|
||||
GameObject right = transform.Find("Panel/right").gameObject;
|
||||
GameObject continueBtn = transform.Find("Panel/continue").gameObject;
|
||||
GameObject change = transform.Find("Panel/change").gameObject;
|
||||
|
||||
UIManager.AddEvent(change, UnityEngine.EventSystems.EventTriggerType.PointerClick, async (s) =>
|
||||
{
|
||||
manager.ChangePlayer(-16379);
|
||||
});
|
||||
UIManager.AddEvent(continueBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, async (s) =>
|
||||
{
|
||||
await manager.ContinueAsync();
|
||||
});
|
||||
{
|
||||
await manager.ContinueAsync();
|
||||
});
|
||||
infoText = transform.Find("InfoText").GetComponent<Text>();
|
||||
UIManager.AddEvent(button, UnityEngine.EventSystems.EventTriggerType.PointerClick, (s) =>
|
||||
{
|
||||
@ -62,42 +207,71 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
sb.AppendLine($"{manager.GetCurrentFrame()}:{5}");
|
||||
});
|
||||
ShowPlayerInfo();
|
||||
}
|
||||
Text power { get; set; }
|
||||
Text cadance { get; set; }
|
||||
Text heartRate { get; set; }
|
||||
Text speed { get; set; }
|
||||
Text totalDistance { get; set; }
|
||||
Text totalClimbed { get; set; }
|
||||
Text ridingTime { get; set; }
|
||||
private void ShowPlayerInfo()
|
||||
{
|
||||
power = transform.Find("Panel/PowerPanel/Power").GetComponent<Text>();
|
||||
cadance = transform.Find("Panel/PowerPanel/Cadance").GetComponent<Text>();
|
||||
heartRate = transform.Find("Panel/PowerPanel/Hrv").GetComponent<Text>();
|
||||
speed = transform.Find("Panel/ComputerPanel/Speed").GetComponent<Text>();
|
||||
totalDistance = transform.Find("Panel/ComputerPanel/Distance").GetComponent<Text>();
|
||||
totalClimbed = transform.Find("Panel/ComputerPanel/TotalClimb").GetComponent<Text>();
|
||||
ridingTime = transform.Find("Panel/ComputerPanel/Timer").GetComponent<Text>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (videoPlayer != null && manager != null)
|
||||
{
|
||||
infoText.text = $"帧数:{manager.GetCurrentFrame()}";
|
||||
power.text = Math.Round(videoPlayer.power).ToString();
|
||||
speed.text = Math.Round(videoPlayer.speed,2).ToString();
|
||||
totalDistance.text = Math.Round(videoPlayer.totalDistance,2).ToString();
|
||||
totalClimbed.text = Math.Round(videoPlayer.totalClimb).ToString();
|
||||
#endregion
|
||||
|
||||
if (manager.CurrentPlayer != null)
|
||||
{
|
||||
ridingTime.text = Helper.FormatTicks(manager.CurrentPlayer.ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
//private int pageIndex = 0;
|
||||
//private int pageSize = 15;
|
||||
//private int bufferSize = 15;
|
||||
|
||||
//protected override void CreateList()
|
||||
//{
|
||||
// //OnlineUserNum.text = " " + MapUDPService.GetNearRiderCount().ToString();
|
||||
// //LayoutRebuilder.ForceRebuildLayoutImmediate(OnlineUserNum.rectTransform);
|
||||
// var nearList = MapUDPService.GetOnlineUsers(App.RouteIdParam);
|
||||
// if (nearList == null)
|
||||
// return;
|
||||
// var mod = MapUDPService.GetNearRiderCount() % pageSize;
|
||||
// var pages = MapUDPService.GetNearRiderCount() / pageSize;
|
||||
// //totalPages = mod > 0 ? pages + 1 : pages;
|
||||
// //删除
|
||||
// var currentNearList = FindObjectsOfType<NearByItemScript>();
|
||||
// foreach (var item in currentNearList)
|
||||
// {
|
||||
// var e = nearList.Where(c => c.Id == item.UserId).FirstOrDefault();
|
||||
// if (e == null)
|
||||
// {
|
||||
// //item.transform.gameObject.SetActive(false);
|
||||
// item.Dispose();
|
||||
// bufferSize--;
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < nearList.Count(); i++)
|
||||
// {
|
||||
// Create(nearList[i], currentNearList);
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void Create(OnlineUser item, NearByItemScript[] rankingList)
|
||||
//{
|
||||
// //var rankingList = FindObjectsOfType<NearByItemScript>();
|
||||
// var nearByItemscript = rankingList.Where(c => c.UserId == item.Id).FirstOrDefault();
|
||||
// //如果当前有这个用户则更新没有则创建并setslibingindex
|
||||
// if (nearByItemscript == null)
|
||||
// {
|
||||
// //创建
|
||||
// if (bufferSize < pageSize)
|
||||
// {
|
||||
// //情况一:还有足够的buffer,直接创建
|
||||
// GameObject prefabItem = item.IsSelf ? nearByMajorItem : nearByItem;
|
||||
// GameObject newObj = (GameObject)Instantiate(prefabItem, parent);
|
||||
// nearByItemscript = newObj.GetComponent<NearByItemScript>();
|
||||
// bufferSize++;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //情况二:没有足够的buffer,找到要被淘汰的buffer()最后一名
|
||||
// nearByItemscript = rankingList.OrderByDescending(c => c.distance).FirstOrDefault();
|
||||
// }
|
||||
// }
|
||||
// nearByItemscript.setUserId(item.Id);
|
||||
// nearByItemscript.setName(item.Name);
|
||||
// nearByItemscript.setRatio(item.KGWeight + "W/KG");
|
||||
// nearByItemscript.setSpeed(item.Speed.ToString() + "KM/H");
|
||||
// nearByItemscript.setDistance(item.Near.ToString() + "KM");
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user