部分代码重构,AR起步冲的问题和停车动画调整
This commit is contained in:
parent
71b6155946
commit
fb4da81ce2
@ -323,8 +323,8 @@ namespace Assets.AR
|
|||||||
//创建轨迹上的转向
|
//创建轨迹上的转向
|
||||||
public void CreateTrajectoryOrientations()
|
public void CreateTrajectoryOrientations()
|
||||||
{
|
{
|
||||||
Quaternion[] quaternionArray = new Quaternion[this.FilteredCameraPositions.Length];
|
var quaternionArray = new Quaternion[this.FilteredCameraPositions.Length];
|
||||||
for (int index = 1; index < this.FilteredCameraPositions.Length - 1; ++index)
|
for (var index = 1; index < this.FilteredCameraPositions.Length - 1; ++index)
|
||||||
quaternionArray[index] = Quaternion.LookRotation(this.FilteredCameraPositions[index + 1] - this.FilteredCameraPositions[index - 1], Vector3.up);
|
quaternionArray[index] = Quaternion.LookRotation(this.FilteredCameraPositions[index + 1] - this.FilteredCameraPositions[index - 1], Vector3.up);
|
||||||
quaternionArray[0] = quaternionArray[1];
|
quaternionArray[0] = quaternionArray[1];
|
||||||
quaternionArray[this.FilteredCameraPositions.Length - 1] = quaternionArray[this.FilteredCameraPositions.Length - 2];
|
quaternionArray[this.FilteredCameraPositions.Length - 1] = quaternionArray[this.FilteredCameraPositions.Length - 2];
|
||||||
@ -374,7 +374,7 @@ namespace Assets.AR
|
|||||||
}
|
}
|
||||||
if (index1 + 1 == this.LightRotations.Length)
|
if (index1 + 1 == this.LightRotations.Length)
|
||||||
return this.LightRotations[this.LightRotations.Length - 1];
|
return this.LightRotations[this.LightRotations.Length - 1];
|
||||||
float t = Mathf.InverseLerp(this.LightRotationFrames[index1], this.LightRotationFrames[index1 + 1], distance);
|
var t = Mathf.InverseLerp(this.LightRotationFrames[index1], this.LightRotationFrames[index1 + 1], distance);
|
||||||
return Quaternion.Slerp(this.LightRotations[index1], this.LightRotations[index1 + 1], t);
|
return Quaternion.Slerp(this.LightRotations[index1], this.LightRotations[index1 + 1], t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +433,6 @@ namespace Assets.AR
|
|||||||
this.SlamSegments = data.SlamSegments;
|
this.SlamSegments = data.SlamSegments;
|
||||||
this.CameraHeight = data.CameraHeight;
|
this.CameraHeight = data.CameraHeight;
|
||||||
this.RiderScale = (double)data.RiderScale != 0.0 ? data.RiderScale : 1f;
|
this.RiderScale = (double)data.RiderScale != 0.0 ? data.RiderScale : 1f;
|
||||||
this.RiderScale *= 0.9f;
|
|
||||||
this.CameraPositions = ((IEnumerable<VectorData>)data.CameraPositions).Select<VectorData, Vector3>((Func<VectorData, Vector3>)(x => x.ToUnityVector())).ToArray<Vector3>();
|
this.CameraPositions = ((IEnumerable<VectorData>)data.CameraPositions).Select<VectorData, Vector3>((Func<VectorData, Vector3>)(x => x.ToUnityVector())).ToArray<Vector3>();
|
||||||
this.ProjectionParameters = data.CameraProjectionParameters;
|
this.ProjectionParameters = data.CameraProjectionParameters;
|
||||||
this.CameraRotations = ((IEnumerable<VectorData>)data.CameraRotations).Select<VectorData, Quaternion>((Func<VectorData, Quaternion>)(x => Quaternion.Euler(x.ToUnityVector()))).ToArray<Quaternion>();
|
this.CameraRotations = ((IEnumerable<VectorData>)data.CameraRotations).Select<VectorData, Quaternion>((Func<VectorData, Quaternion>)(x => Quaternion.Euler(x.ToUnityVector()))).ToArray<Quaternion>();
|
||||||
|
|||||||
@ -18,8 +18,8 @@ namespace Assets.AR
|
|||||||
ARVideoPlayerControl VideoPlayerControl;
|
ARVideoPlayerControl VideoPlayerControl;
|
||||||
ARLaneGameObject[] rides { get; set; }
|
ARLaneGameObject[] rides { get; set; }
|
||||||
public ARLaneGameObject mainRiderObject { get; set; }
|
public ARLaneGameObject mainRiderObject { get; set; }
|
||||||
private Light arLight;
|
public Light arLight;
|
||||||
private Light arBackLight;
|
private Light arBackLight { get; set; }
|
||||||
public CameraDistance RiderCameraDistance { get; set; }
|
public CameraDistance RiderCameraDistance { get; set; }
|
||||||
public VideoPlayMode VideoControlMode { get; private set; }
|
public VideoPlayMode VideoControlMode { get; private set; }
|
||||||
private float autoCameraSwitchTimeCounter = 80f;
|
private float autoCameraSwitchTimeCounter = 80f;
|
||||||
@ -55,6 +55,7 @@ namespace Assets.AR
|
|||||||
//ar数据加载本地,本地没有就下载
|
//ar数据加载本地,本地没有就下载
|
||||||
this.aRData = arData;
|
this.aRData = arData;
|
||||||
this.detail = routeDetailData;
|
this.detail = routeDetailData;
|
||||||
|
|
||||||
this.RiderCameraDistance = AR.CameraDistance.Middle;
|
this.RiderCameraDistance = AR.CameraDistance.Middle;
|
||||||
videoPointsSync = new VideoPointsSync(detail.VideoPoints.Select(c => new VideoPoint()
|
videoPointsSync = new VideoPointsSync(detail.VideoPoints.Select(c => new VideoPoint()
|
||||||
{
|
{
|
||||||
@ -62,14 +63,20 @@ namespace Assets.AR
|
|||||||
Time = (float)c.VideoTime
|
Time = (float)c.VideoTime
|
||||||
}));
|
}));
|
||||||
videoSync = videoPointsSync;
|
videoSync = videoPointsSync;
|
||||||
this.VideoPlayerControl = new ARVideoPlayerControl();
|
this.VideoPlayerControl = new ARVideoPlayerControl
|
||||||
this.VideoPlayerControl.VideoSyncSource = videoSync;
|
{
|
||||||
|
VideoSyncSource = videoSync
|
||||||
|
};
|
||||||
|
|
||||||
this.videoPlayer = mediaPlayer.gameObject.AddComponent<AVProVideoPlayer>();
|
this.videoPlayer = mediaPlayer.gameObject.AddComponent<AVProVideoPlayer>();
|
||||||
this.videoPlayer.videoPlayer = mediaPlayer;
|
this.videoPlayer.videoPlayer = mediaPlayer;
|
||||||
|
|
||||||
SetArRoute(new ARRoute(aRData.Route), videoSync, videoPlayer);
|
SetArRoute(new ARRoute(aRData.Route), videoSync, videoPlayer);
|
||||||
|
|
||||||
this.VideoPlayerControl.VideoFrameOffset = this.Route.VideoFrameOffset;
|
this.VideoPlayerControl.VideoFrameOffset = this.Route.VideoFrameOffset;
|
||||||
this.VideoPlayerControl.Route = Route;
|
this.VideoPlayerControl.Route = Route;
|
||||||
this.VideoPlayerControl.SetVideoPlayer(videoPlayer);
|
this.VideoPlayerControl.SetVideoPlayer(videoPlayer);
|
||||||
|
|
||||||
rides = FindObjectsOfType<ARLaneGameObject>();
|
rides = FindObjectsOfType<ARLaneGameObject>();
|
||||||
SetUpLight();
|
SetUpLight();
|
||||||
}
|
}
|
||||||
@ -123,7 +130,7 @@ namespace Assets.AR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timers += 1f;
|
timers += 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainRiderObject == null || Route == null)
|
if (mainRiderObject == null || Route == null)
|
||||||
@ -134,16 +141,15 @@ namespace Assets.AR
|
|||||||
var delta = Time.deltaTime;
|
var delta = Time.deltaTime;
|
||||||
foreach (var obj in this.riderObjects.Values)
|
foreach (var obj in this.riderObjects.Values)
|
||||||
{
|
{
|
||||||
var offset = obj.DeltaDistance * delta;
|
if(obj.DeltaDistance == 0 )continue;
|
||||||
//Debug.Log($"offset:{offset}:{DateTime.Now}");
|
obj.Distance = Mathf.Lerp(obj.Distance, obj.Distance + obj.DeltaDistance, delta);
|
||||||
obj.Distance += offset;
|
obj.RouteDistance = Mathf.Lerp(obj.RouteDistance, obj.RouteDistance + obj.DeltaDistance, delta);
|
||||||
obj.RouteDistance += offset;
|
|
||||||
}
|
}
|
||||||
|
VideoPlayerControl.UpdateVideoPlayRate(mainRiderObject.PreSpeed, mainRiderObject.Distance);
|
||||||
|
|
||||||
this.FrameIndexDistanceCorrection = this.VideoPlayerControl.FrameIndexDistanceCorrection;
|
this.FrameIndexDistanceCorrection = this.VideoPlayerControl.FrameIndexDistanceCorrection;
|
||||||
//this.FollowedRiderId = mainObject.Id;
|
//this.FollowedRiderId = mainObject.Id;
|
||||||
this.UpdateCameraFollowDistance();
|
this.UpdateCameraFollowDistance();
|
||||||
VideoPlayerControl.UpdateVideoPlayRate(mainRiderObject.PreSpeed, mainRiderObject.Distance);
|
|
||||||
base.Update();
|
base.Update();
|
||||||
this.UpdateRidersVisibility();
|
this.UpdateRidersVisibility();
|
||||||
this.UpdateRidersLean();
|
this.UpdateRidersLean();
|
||||||
@ -159,23 +165,11 @@ namespace Assets.AR
|
|||||||
//创建
|
//创建
|
||||||
private void SetUpLight()
|
private void SetUpLight()
|
||||||
{
|
{
|
||||||
GameObject gameObject1 = new GameObject("ARLight");
|
|
||||||
gameObject1.layer = this.gameObject.layer;
|
|
||||||
gameObject1.transform.SetParent(this.transform);
|
|
||||||
this.arLight = gameObject1.AddComponent<Light>();
|
|
||||||
this.arLight.type = LightType.Directional;
|
this.arLight.type = LightType.Directional;
|
||||||
this.arLight.transform.rotation = Quaternion.Euler(90f, 0.0f, 0.0f);
|
this.arLight.transform.rotation = Quaternion.Euler(90f, 0.0f, 0.0f);
|
||||||
//if (this.BuildConfig.IsIOs || this.BuildConfig.IsTvOs)
|
this.arLight.shadows = LightShadows.Soft;
|
||||||
//{
|
this.arLight.shadowStrength = 1f;
|
||||||
// this.arLight.shadows = LightShadows.Hard;
|
|
||||||
// this.arLight.shadowStrength = 0.5f;
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
{
|
|
||||||
this.arLight.shadows = LightShadows.Soft;
|
|
||||||
this.arLight.shadowStrength = 1f;
|
|
||||||
}
|
|
||||||
this.arLight.cullingMask = 512;
|
|
||||||
GameObject gameObject2 = new GameObject("ARBackLight");
|
GameObject gameObject2 = new GameObject("ARBackLight");
|
||||||
gameObject2.layer = this.gameObject.layer;
|
gameObject2.layer = this.gameObject.layer;
|
||||||
gameObject2.transform.SetParent(this.transform);
|
gameObject2.transform.SetParent(this.transform);
|
||||||
@ -184,7 +178,7 @@ namespace Assets.AR
|
|||||||
this.arBackLight.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
|
this.arBackLight.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
|
||||||
this.arBackLight.shadows = LightShadows.None;
|
this.arBackLight.shadows = LightShadows.None;
|
||||||
this.arBackLight.intensity = 0.5f;
|
this.arBackLight.intensity = 0.5f;
|
||||||
this.arBackLight.cullingMask = 512;
|
//this.arBackLight.cullingMask = 512;
|
||||||
}
|
}
|
||||||
//设置video显示模式
|
//设置video显示模式
|
||||||
public void SetVideoControlMode(VideoPlayMode mode)
|
public void SetVideoControlMode(VideoPlayMode mode)
|
||||||
@ -202,15 +196,15 @@ namespace Assets.AR
|
|||||||
//更新摄像机的位置
|
//更新摄像机的位置
|
||||||
private void UpdateCameraFollowDistance()
|
private void UpdateCameraFollowDistance()
|
||||||
{
|
{
|
||||||
this.NearViewMode = this.RiderCameraDistance == AR.CameraDistance.Near;
|
//this.NearViewMode = this.RiderCameraDistance == AR.CameraDistance.Near;
|
||||||
float cameraFollowDistance = GetCameraFollowDistance(this.RiderCameraDistance);
|
var cameraFollowDistance = GetCameraFollowDistance(this.RiderCameraDistance);
|
||||||
this.VideoPlayerControl.CameraFollowDistance = cameraFollowDistance;
|
this.VideoPlayerControl.CameraFollowDistance = cameraFollowDistance;
|
||||||
}
|
}
|
||||||
//人物是否显示
|
//人物是否显示
|
||||||
protected override bool IsObjectActive(ARGameObject arObject)
|
protected override bool IsObjectActive(ARGameObject arObject)
|
||||||
{
|
{
|
||||||
var flag = base.IsObjectActive(arObject);
|
var flag = base.IsObjectActive(arObject);
|
||||||
if ((UnityEngine.Object)arObject != (UnityEngine.Object)this.mainRiderObject)
|
if (arObject != this.mainRiderObject)
|
||||||
return flag;
|
return flag;
|
||||||
if ((double)this.VideoPlayerControl.CameraFollowDistance > 0.0 || this.AR360Version)
|
if ((double)this.VideoPlayerControl.CameraFollowDistance > 0.0 || this.AR360Version)
|
||||||
return flag;
|
return flag;
|
||||||
@ -270,7 +264,7 @@ namespace Assets.AR
|
|||||||
}
|
}
|
||||||
gameObject.transform.parent = this.transform;
|
gameObject.transform.parent = this.transform;
|
||||||
gameObject.transform.position = ARGameObjectsController.DefaultObjectPosition;
|
gameObject.transform.position = ARGameObjectsController.DefaultObjectPosition;
|
||||||
gameObject.layer = 9;
|
//gameObject.layer = 9;
|
||||||
riderModel.Route = this.Route;
|
riderModel.Route = this.Route;
|
||||||
riderModel.VideoSync = this.videoSync;
|
riderModel.VideoSync = this.videoSync;
|
||||||
//riderModel.VideoPlayer = this.videoPlayer;
|
//riderModel.VideoPlayer = this.videoPlayer;
|
||||||
@ -297,7 +291,7 @@ namespace Assets.AR
|
|||||||
transform = {
|
transform = {
|
||||||
parent = this.transform
|
parent = this.transform
|
||||||
},
|
},
|
||||||
layer = 9
|
//layer = 9
|
||||||
}.AddComponent<ARLaneGameObject>();
|
}.AddComponent<ARLaneGameObject>();
|
||||||
riderObject.Route = this.Route;
|
riderObject.Route = this.Route;
|
||||||
riderObject.VideoSync = this.videoSync;
|
riderObject.VideoSync = this.videoSync;
|
||||||
@ -660,17 +654,9 @@ namespace Assets.AR
|
|||||||
}
|
}
|
||||||
//更新后背的光线
|
//更新后背的光线
|
||||||
private void UpdateBackLight()
|
private void UpdateBackLight()
|
||||||
{
|
{
|
||||||
//if (this.SelectedPanorama != null)
|
this.arBackLight.transform.position = this.UnityCamera.transform.position;
|
||||||
//{
|
this.arBackLight.transform.rotation = this.UnityCamera.transform.rotation;
|
||||||
// this.arBackLight.transform.position = this.PanoramaCamera.transform.position;
|
|
||||||
// this.arBackLight.transform.rotation = this.PanoramaCamera.transform.rotation;
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
{
|
|
||||||
this.arBackLight.transform.position = this.UnityCamera.transform.position;
|
|
||||||
this.arBackLight.transform.rotation = this.UnityCamera.transform.rotation;
|
|
||||||
}
|
|
||||||
this.arLight.transform.rotation = this.Route.GetLightDirection(this.videoPlayer.CurrentFrame);
|
this.arLight.transform.rotation = this.Route.GetLightDirection(this.videoPlayer.CurrentFrame);
|
||||||
this.arLight.shadowStrength = this.Route.GetShadowIntensity(this.videoPlayer.CurrentFrame);
|
this.arLight.shadowStrength = this.Route.GetShadowIntensity(this.videoPlayer.CurrentFrame);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,7 @@ namespace Assets.AR
|
|||||||
|
|
||||||
private void SkipVideoToFrame(long frame) => this.VideoPlayer.Seek(frame);
|
private void SkipVideoToFrame(long frame) => this.VideoPlayer.Seek(frame);
|
||||||
|
|
||||||
|
private const float TimerInterval = 0.2f;
|
||||||
public void UpdateVideoPlayRate(float speed, float routeDistance)
|
public void UpdateVideoPlayRate(float speed, float routeDistance)
|
||||||
{
|
{
|
||||||
if (!this.AllowUpdate)
|
if (!this.AllowUpdate)
|
||||||
@ -103,32 +104,32 @@ namespace Assets.AR
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float videoFrameAtDistance1 = this.VideoSyncSource.GetVideoFrameAtDistance(routeDistance);
|
var videoFrameAtDistance1 = this.VideoSyncSource.GetVideoFrameAtDistance(routeDistance);
|
||||||
float val2 = routeDistance - this.CameraFollowDistance;
|
var val2 = routeDistance - this.CameraFollowDistance;
|
||||||
//if (this.IsMultilap && (double)this.RiderDistance.RouteDistance > (double)this.RiderDistance.LapDistance && (double)val2 < 0.0)
|
//if (this.IsMultilap && (double)this.RiderDistance.RouteDistance > (double)this.RiderDistance.LapDistance && (double)val2 < 0.0)
|
||||||
// val2 += (float)this.lapLength;
|
// val2 += (float)this.lapLength;
|
||||||
float distance = Math.Max(0.0f, val2);
|
var distance = Math.Max(0.0f, val2);
|
||||||
float frame = this.VideoSyncSource.GetVideoFrameAtDistance(distance) + (float)this.VideoFrameOffset;
|
var frame = this.VideoSyncSource.GetVideoFrameAtDistance(distance) + (float)this.VideoFrameOffset;
|
||||||
if (this.Route != null && (double)this.Route.GetVisibility(frame) > 10.0)
|
if (this.Route != null && (double)this.Route.GetVisibility(frame) > 10.0)
|
||||||
frame = (float)this.Route.GetFrameAtDistance(Math.Max(0.0, this.Route.GetDistanceForFrame((double)videoFrameAtDistance1) - (double)this.CameraFollowDistance)) + (float)this.VideoFrameOffset;
|
frame = (float)this.Route.GetFrameAtDistance(Math.Max(0.0, this.Route.GetDistanceForFrame((double)videoFrameAtDistance1) - (double)this.CameraFollowDistance)) + (float)this.VideoFrameOffset;
|
||||||
//if (this.VideoPlayer is RouvyLib.Video.RouvyVideoPlayer.RouvyVideoPlayer videoPlayer)
|
//if (this.VideoPlayer is RouvyLib.Video.RouvyVideoPlayer.RouvyVideoPlayer videoPlayer)
|
||||||
// videoPlayer.TargetFrame = frame;
|
// videoPlayer.TargetFrame = frame;
|
||||||
this.VideoPlayer.UpdateCurrentFrame();
|
this.VideoPlayer.UpdateCurrentFrame();
|
||||||
float distanceForVideoFrame = this.VideoSyncSource.GetDistanceForVideoFrame(this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
var distanceForVideoFrame = this.VideoSyncSource.GetDistanceForVideoFrame(this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
||||||
float f;
|
float f;
|
||||||
if (this.Route != null)
|
if (this.Route != null)
|
||||||
{
|
{
|
||||||
double frameAtDistance = this.Route.GetFrameAtDistance(this.Route.GetDistanceForFrame((double)this.VideoPlayer.CurrentFrame - (double)this.VideoFrameOffset) + (double)Mathf.Min(routeDistance, this.CameraFollowDistance));
|
var frameAtDistance = this.Route.GetFrameAtDistance(this.Route.GetDistanceForFrame((double)this.VideoPlayer.CurrentFrame - (double)this.VideoFrameOffset) + (double)Mathf.Min(routeDistance, this.CameraFollowDistance));
|
||||||
f = videoFrameAtDistance1 - (float)frameAtDistance;
|
f = videoFrameAtDistance1 - (float)frameAtDistance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
f = frame - (this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
f = frame - (this.VideoPlayer.CurrentFrame - (float)this.VideoFrameOffset);
|
||||||
float num1 = Mathf.Clamp01(PFMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(f)));
|
var num1 = Mathf.Clamp01(PFMath.Lerp(0.0f, 1f, 100f, 0.0f, Mathf.Abs(f)));
|
||||||
this.FrameIndexDistanceCorrection = f * num1;
|
this.FrameIndexDistanceCorrection = f * num1;
|
||||||
this.CameraDistanceError = distance - distanceForVideoFrame;
|
this.CameraDistanceError = distance - distanceForVideoFrame;
|
||||||
if (this.IsMultilap)
|
if (this.IsMultilap)
|
||||||
{
|
{
|
||||||
float num2 = distance - (distanceForVideoFrame + (float)this.lapLength);
|
var num2 = distance - (distanceForVideoFrame + (float)this.lapLength);
|
||||||
if ((double)Math.Abs(num2) < (double)Math.Abs(this.CameraDistanceError) && (double)Math.Abs(num2) < 200.0)
|
if ((double)Math.Abs(num2) < (double)Math.Abs(this.CameraDistanceError) && (double)Math.Abs(num2) < 200.0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -139,7 +140,7 @@ namespace Assets.AR
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var totalSeconds = DateTime.UtcNow.Subtract(this.lastPlaybackSpeedChange).TotalSeconds;
|
var totalSeconds = DateTime.UtcNow.Subtract(this.lastPlaybackSpeedChange).TotalSeconds;
|
||||||
if (totalSeconds >= 0.0 && totalSeconds < 0.20000000298023224)
|
if (totalSeconds >= 0.0 && totalSeconds < TimerInterval)
|
||||||
return;
|
return;
|
||||||
var num3 = (float)totalSeconds;
|
var num3 = (float)totalSeconds;
|
||||||
var num4 = num3 * speed;
|
var num4 = num3 * speed;
|
||||||
|
|||||||
8
Assets/Materials.meta
Normal file
8
Assets/Materials.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39e9f40939fde574ca2a293c619e95e9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
77
Assets/Materials/VideoMaterial.mat
Normal file
77
Assets/Materials/VideoMaterial.mat
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: VideoMaterial
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0
|
||||||
|
- _GlossyReflections: 0
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 0
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
8
Assets/Materials/VideoMaterial.mat.meta
Normal file
8
Assets/Materials/VideoMaterial.mat.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a7d739233991f94b80481005b079d7d
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 8629729479594509059}
|
m_GameObject: {fileID: 8629729479594509059}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 6918487040151656200}
|
- {fileID: 6918487040151656200}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 8629729479594509059}
|
m_GameObject: {fileID: 8629729479594509059}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 669762769015553617}
|
- {fileID: 669762769015553617}
|
||||||
|
|||||||
@ -3691,8 +3691,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1535700487792324436}
|
m_GameObject: {fileID: 1535700487792324436}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -1, z: 0}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 0.75, y: 0.75, z: 0.75}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 5510178270068819320}
|
- {fileID: 5510178270068819320}
|
||||||
- {fileID: 3524312104137692172}
|
- {fileID: 3524312104137692172}
|
||||||
@ -4023,18 +4023,8 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
weight: 0
|
weight: 0
|
||||||
speed: 0
|
speed: 0
|
||||||
power: 0
|
|
||||||
cadance: 0
|
|
||||||
wkg: 0
|
|
||||||
ticks: 0
|
|
||||||
currentSlope: 0
|
|
||||||
distance: 0
|
distance: 0
|
||||||
totalClimb: 0
|
power: 0
|
||||||
currentIndex: 0
|
|
||||||
bearing: 0
|
|
||||||
target: {fileID: 0}
|
|
||||||
diff: 0
|
|
||||||
frames: 0
|
|
||||||
--- !u!114 &6834098711345890891
|
--- !u!114 &6834098711345890891
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -4053,8 +4043,8 @@ MonoBehaviour:
|
|||||||
PositionOffset: {x: 0, y: 0, z: 0}
|
PositionOffset: {x: 0, y: 0, z: 0}
|
||||||
RotationOffset: {x: 0, y: 0, z: 0}
|
RotationOffset: {x: 0, y: 0, z: 0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
StartPosition: 0
|
wheelFront: {fileID: 0}
|
||||||
TestPower: 500
|
wheelRear: {fileID: 0}
|
||||||
--- !u!1 &1540924146250517987
|
--- !u!1 &1540924146250517987
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -27,8 +27,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 26904646242573121}
|
m_GameObject: {fileID: 26904646242573121}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -1, z: 0}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 0.75, y: 0.75, z: 0.75}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 6442512681317347693}
|
- {fileID: 6442512681317347693}
|
||||||
- {fileID: 2465416350492459823}
|
- {fileID: 2465416350492459823}
|
||||||
@ -363,17 +363,8 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
weight: 0
|
weight: 0
|
||||||
speed: 0
|
speed: 0
|
||||||
power: 0
|
|
||||||
cadance: 0
|
|
||||||
wkg: 0
|
|
||||||
ticks: 0
|
|
||||||
currentSlope: 0
|
|
||||||
distance: 0
|
distance: 0
|
||||||
totalClimb: 0
|
power: 0
|
||||||
currentIndex: 0
|
|
||||||
bearing: 0
|
|
||||||
diff: 0
|
|
||||||
frames: 0
|
|
||||||
--- !u!114 &7778627600969797816
|
--- !u!114 &7778627600969797816
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -392,8 +383,8 @@ MonoBehaviour:
|
|||||||
PositionOffset: {x: 0, y: 0, z: 0}
|
PositionOffset: {x: 0, y: 0, z: 0}
|
||||||
RotationOffset: {x: 0, y: 0, z: 0}
|
RotationOffset: {x: 0, y: 0, z: 0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
StartPosition: 0
|
wheelFront: {fileID: 0}
|
||||||
TestPower: 500
|
wheelRear: {fileID: 0}
|
||||||
--- !u!1 &32093163217517046
|
--- !u!1 &32093163217517046
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -3691,8 +3691,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1535700487792324436}
|
m_GameObject: {fileID: 1535700487792324436}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -1, z: 3}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 0.65, y: 0.65, z: 0.65}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 5510178270068819320}
|
- {fileID: 5510178270068819320}
|
||||||
- {fileID: 3524312104137692172}
|
- {fileID: 3524312104137692172}
|
||||||
@ -4023,16 +4023,8 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
weight: 0
|
weight: 0
|
||||||
speed: 0
|
speed: 0
|
||||||
power: 0
|
|
||||||
cadance: 0
|
|
||||||
wkg: 0
|
|
||||||
ticks: 0
|
|
||||||
currentSlope: 0
|
|
||||||
distance: 0
|
distance: 0
|
||||||
totalClimb: 0
|
power: 0
|
||||||
currentIndex: 0
|
|
||||||
bearing: 0
|
|
||||||
IsStart: 0
|
|
||||||
--- !u!114 &3611148035918924976
|
--- !u!114 &3611148035918924976
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -27,8 +27,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 26904646242573121}
|
m_GameObject: {fileID: 26904646242573121}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -1, z: 0}
|
m_LocalPosition: {x: 0, y: -100, z: -100}
|
||||||
m_LocalScale: {x: 0.75, y: 0.75, z: 0.75}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 6442512681317347693}
|
- {fileID: 6442512681317347693}
|
||||||
- {fileID: 2465416350492459823}
|
- {fileID: 2465416350492459823}
|
||||||
@ -363,15 +363,8 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
weight: 0
|
weight: 0
|
||||||
speed: 0
|
speed: 0
|
||||||
power: 0
|
|
||||||
cadance: 0
|
|
||||||
wkg: 0
|
|
||||||
ticks: 0
|
|
||||||
currentSlope: 0
|
|
||||||
distance: 0
|
distance: 0
|
||||||
totalClimb: 0
|
power: 0
|
||||||
currentIndex: 0
|
|
||||||
bearing: 0
|
|
||||||
--- !u!114 &5851000374308093711
|
--- !u!114 &5851000374308093711
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -390,8 +383,6 @@ MonoBehaviour:
|
|||||||
PositionOffset: {x: 0, y: 0, z: 0}
|
PositionOffset: {x: 0, y: 0, z: 0}
|
||||||
RotationOffset: {x: 0, y: 0, z: 0}
|
RotationOffset: {x: 0, y: 0, z: 0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
StartPosition: 0
|
|
||||||
TestPower: 500
|
|
||||||
wheelFront: {fileID: 4724697995724873205}
|
wheelFront: {fileID: 4724697995724873205}
|
||||||
wheelRear: {fileID: 6597490539092503497}
|
wheelRear: {fileID: 6597490539092503497}
|
||||||
--- !u!1 &32093163217517046
|
--- !u!1 &32093163217517046
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@ using Assets.Scripts.Apis.Models;
|
|||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using Mapbox.Utils;
|
using Mapbox.Utils;
|
||||||
using Assets.Scenes.Ride.Scripts;
|
using Assets.Scenes.Ride.Scripts;
|
||||||
|
using UnityEngine.Assertions;
|
||||||
|
|
||||||
namespace Assets.Scripts.Scenes.VideoRide
|
namespace Assets.Scripts.Scenes.VideoRide
|
||||||
{
|
{
|
||||||
@ -58,6 +59,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
|
|
||||||
public double mockpower { get; set; }
|
public double mockpower { get; set; }
|
||||||
protected float ratio = 1;
|
protected float ratio = 1;
|
||||||
|
private static readonly int PreSpeed = Animator.StringToHash("preSpeed");
|
||||||
|
private static readonly int AnimatorSpeed = Animator.StringToHash("speed");
|
||||||
|
private static readonly int Grade = Animator.StringToHash("grade");
|
||||||
|
private static readonly int Power = Animator.StringToHash("power");
|
||||||
|
|
||||||
protected virtual void Start()
|
protected virtual void Start()
|
||||||
{
|
{
|
||||||
@ -112,10 +117,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
{
|
{
|
||||||
if (animator != null)
|
if (animator != null)
|
||||||
{
|
{
|
||||||
animator.SetFloat("preSpeed", (float)preSpeed);
|
animator.SetFloat(PreSpeed, (float)preSpeed);
|
||||||
animator.SetFloat("speed", (float)Speed);
|
animator.SetFloat(AnimatorSpeed, (float)speed);
|
||||||
animator.SetFloat("grade", (float)currentSlope);
|
animator.SetFloat(Grade, (float)currentSlope);
|
||||||
animator.SetFloat("power", (float)power);
|
animator.SetFloat(Power, (float)power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//计算人物当前属性
|
//计算人物当前属性
|
||||||
@ -148,21 +153,22 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
}
|
}
|
||||||
public virtual void ComputeAnimatorSpeed()
|
public virtual void ComputeAnimatorSpeed()
|
||||||
{
|
{
|
||||||
if (manager == null)
|
Assert.IsNotNull(manager);
|
||||||
return;
|
|
||||||
mapData = manager.GetMapData();
|
mapData = manager.GetMapData();
|
||||||
int safeIndex = currentIndex + 1 < mapData.List.Count ? currentIndex + 1 : currentIndex;
|
|
||||||
float num = speed == 0 ? 1f : (float)(speed / mapData.List[safeIndex].Distance);
|
var safeIndex = currentIndex + 1 < mapData.List.Count ? currentIndex + 1 : currentIndex;
|
||||||
|
var num = speed == 0 ? 1f : (float)(speed / mapData.List[safeIndex].Distance);
|
||||||
|
|
||||||
ratio = Mathf.Clamp(num, 0.3f, 1.2f);
|
ratio = Mathf.Clamp(num, 0.3f, 1.2f);
|
||||||
|
|
||||||
var info = animator.GetCurrentAnimatorClipInfo(0);
|
var info = animator.GetCurrentAnimatorClipInfo(0);
|
||||||
if (info != null)
|
if (info == null) return;
|
||||||
|
|
||||||
|
var currentClip = info.FirstOrDefault();
|
||||||
|
if (currentClip.clip != null)
|
||||||
{
|
{
|
||||||
var currentClip = info.FirstOrDefault();
|
animator.speed = ratio;
|
||||||
if (currentClip.clip != null)
|
|
||||||
{
|
|
||||||
animator.speed = ratio;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void ComputeRecord() { }
|
public virtual void ComputeRecord() { }
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@ -14,58 +13,56 @@ using System.Linq;
|
|||||||
using Assets.Scenes.Ride.Scripts.Model;
|
using Assets.Scenes.Ride.Scripts.Model;
|
||||||
using Assets.AR;
|
using Assets.AR;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cysharp.Threading.Tasks;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Assets.Scripts.Scenes.VideoRide
|
namespace Assets.Scripts.Scenes.VideoRide
|
||||||
{
|
{
|
||||||
public class VideoLoading : MonoBehaviour, IProgress<float>
|
public class VideoLoading : MonoBehaviour, IProgress<float>
|
||||||
{
|
{
|
||||||
UnityWebRequest request { get; set; }
|
|
||||||
VideoGameManager manager { get; set; }
|
VideoGameManager manager { get; set; }
|
||||||
|
|
||||||
protected Text mapName;
|
private Text mapName;
|
||||||
protected RawImage mapRouteImage;
|
private RawImage mapRouteImage;
|
||||||
protected CanvasGroup canvasGroup;
|
private CanvasGroup canvasGroup;
|
||||||
protected Slider slider;
|
private Slider slider;
|
||||||
protected Text processText;
|
private Text processText;
|
||||||
protected Text rideNowText;
|
private Text rideNowText;
|
||||||
protected Button rideNow;
|
private Button rideNow;
|
||||||
protected Button cancel;
|
private Button cancel;
|
||||||
protected Text mapDescText;
|
private Text mapDescText;
|
||||||
protected Text distance;
|
private Text distance;
|
||||||
protected Text elevaction;
|
private Text elevaction;
|
||||||
protected Text slope;
|
private Text slope;
|
||||||
protected GameObject panel;
|
private GameObject panel;
|
||||||
protected GameObject download;
|
private GameObject download;
|
||||||
protected GameObject watch;
|
private GameObject watch;
|
||||||
|
|
||||||
protected GameObject loadingPanel { get; set; }
|
protected GameObject loadingPanel { get; set; }
|
||||||
|
|
||||||
protected Text level;
|
private Text level;
|
||||||
protected Text rideNum;
|
private Text rideNum;
|
||||||
protected Text uploadByUserName;
|
private Text uploadByUserName;
|
||||||
protected RawImage head;
|
private RawImage head;
|
||||||
protected RawImage country;
|
private RawImage country;
|
||||||
protected RawImage mapCountry;
|
private RawImage mapCountry;
|
||||||
protected RawImage altitudeGraph { get; set; }
|
private RawImage altitudeGraph { get; set; }
|
||||||
protected Transform mapRanking;
|
private Transform mapRanking;
|
||||||
protected Text mapId;
|
private Text mapId;
|
||||||
|
private Text downloadText { get; set; }
|
||||||
|
private Transform ui;
|
||||||
|
private MapRoute route;
|
||||||
|
|
||||||
protected float process = 0;//0-100 %
|
protected float process = 0;//0-100 %
|
||||||
public float targetAlpha = 0f;
|
|
||||||
public float alphaSpeed = 2.0f;
|
private bool startBtnLock = false;
|
||||||
|
|
||||||
protected Transform ui;
|
|
||||||
|
|
||||||
protected MapRoute route;
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if(App.gameRoomDetail != null)
|
if(App.gameRoomDetail != null)
|
||||||
ShowGameRoomLoading();
|
ShowGameRoomLoading();
|
||||||
}
|
}
|
||||||
void Start()
|
|
||||||
|
private void Start()
|
||||||
{
|
{
|
||||||
manager = FindObjectOfType<VideoGameManager>();
|
manager = FindObjectOfType<VideoGameManager>();
|
||||||
ui = manager.GetCanvasTransform();
|
ui = manager.GetCanvasTransform();
|
||||||
@ -184,19 +181,18 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
|
|
||||||
downloadText = rideNow.GetComponentInChildren<Text>();//视频下载进度text
|
downloadText = rideNow.GetComponentInChildren<Text>();//视频下载进度text
|
||||||
}
|
}
|
||||||
Text downloadText { get; set; }
|
|
||||||
|
|
||||||
protected void InitGameObjectData()
|
protected void InitGameObjectData()
|
||||||
{
|
{
|
||||||
var route = manager.mapRoute;
|
var route = manager.mapRoute;
|
||||||
#region 绑定路书基本信息
|
#region 绑定路书基本信息
|
||||||
mapName.text = GetMaxString(route.Name, 40);
|
mapName.text = route.Name.ToEllipsisString(40);
|
||||||
level.text = route.Hard;
|
level.text = route.Hard;
|
||||||
elevaction.text = Math.Round(route.TotalClimb.GetValueOrDefault(0), 2).ToString() + "M";
|
elevaction.text = Math.Round(route.TotalClimb.GetValueOrDefault(0), 2) + "M";
|
||||||
slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%";
|
slope.text = Math.Round(route.AverageGrade, 2) + "%";
|
||||||
rideNum.text = route.TheHeat.ToString();
|
rideNum.text = route.TheHeat.ToString();
|
||||||
distance.text = route.Distance.ToString("f1") + "KM";
|
distance.text = route.Distance.ToString("f1") + "KM";
|
||||||
mapDescText.text = GetMaxString(route.Dec, 255);
|
mapDescText.text = route.Dec.ToEllipsisString(255);
|
||||||
mapId.text = $"#{route.Id.ToString()}";
|
mapId.text = $"#{route.Id.ToString()}";
|
||||||
var userList = ConfigHelper.mapApi.GetOnlineUserInfo(new int[] { route.UserId }).data;
|
var userList = ConfigHelper.mapApi.GetOnlineUserInfo(new int[] { route.UserId }).data;
|
||||||
if (userList.Count > 0)
|
if (userList.Count > 0)
|
||||||
@ -218,15 +214,18 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
CreateRankingList(list.data.list);
|
CreateRankingList(list.data.list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool startBtnLock = false;
|
|
||||||
public void StartRide(BaseEventData baseEvent)
|
private void StartRide(BaseEventData baseEvent)
|
||||||
{
|
{
|
||||||
if (startBtnLock)
|
if (startBtnLock) return;
|
||||||
return;
|
|
||||||
startBtnLock = true;
|
startBtnLock = true;
|
||||||
var ui = manager.GetCanvasTransform();
|
|
||||||
|
InitClientState(false);
|
||||||
|
|
||||||
|
InitAR();
|
||||||
|
|
||||||
canvasGroup.DOFade(0, 1).onComplete += () => {
|
canvasGroup.DOFade(0, 1).onComplete += () => {
|
||||||
InitAR();
|
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
manager.StartGame();
|
manager.StartGame();
|
||||||
manager.SetCyclingModel(Assets.Scenes.Ride.Scripts.Model.CyclingModel.Single);
|
manager.SetCyclingModel(Assets.Scenes.Ride.Scripts.Model.CyclingModel.Single);
|
||||||
@ -234,9 +233,9 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void InitAR()
|
private async void InitAR()
|
||||||
{
|
{
|
||||||
var route = manager.mapRoute;
|
route = manager.mapRoute;
|
||||||
var arDataPath = $"{PFConstants.ARFolder}/{route.Id}/{route.Id}.json";
|
var arDataPath = $"{PFConstants.ARFolder}/{route.Id}/{route.Id}.json";
|
||||||
var videoRoute = $"{PFConstants.ARFolder}/{route.Id}/route-{route.Id}.json";
|
var videoRoute = $"{PFConstants.ARFolder}/{route.Id}/route-{route.Id}.json";
|
||||||
|
|
||||||
@ -245,13 +244,15 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
|
|
||||||
await Task.Run<ARData>((Func<ARData>)(() => aRData = ARData.LoadFromFile(arDataPath)));
|
await Task.Run<ARData>((Func<ARData>)(() => aRData = ARData.LoadFromFile(arDataPath)));
|
||||||
await Task.Run<RouteDetailData>((Func<RouteDetailData>)(() => routeDetailData = RouteDetailData.LoadFromFile(videoRoute)));
|
await Task.Run<RouteDetailData>((Func<RouteDetailData>)(() => routeDetailData = RouteDetailData.LoadFromFile(videoRoute)));
|
||||||
|
|
||||||
var arController = FindObjectOfType<ARTrainingController>();
|
var arController = FindObjectOfType<ARTrainingController>();
|
||||||
arController.Initialize(aRData, routeDetailData);
|
arController.Initialize(aRData, routeDetailData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void StartRide(int seconds)
|
public void StartRide(int seconds)
|
||||||
{
|
{
|
||||||
|
InitClientState(false);
|
||||||
|
|
||||||
var ui = manager.GetCanvasTransform();
|
var ui = manager.GetCanvasTransform();
|
||||||
canvasGroup.DOFade(0, 0).onComplete += () => {
|
canvasGroup.DOFade(0, 0).onComplete += () => {
|
||||||
InitAR();
|
InitAR();
|
||||||
@ -260,6 +261,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
manager.SetCurrentMode(VideoGameManager.ARMode.RIDE);
|
manager.SetCurrentMode(VideoGameManager.ARMode.RIDE);
|
||||||
ui.Find("Panel").gameObject.SetActive(true);
|
ui.Find("Panel").gameObject.SetActive(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
UIManager.ShowGameRoomCountDownPanel(seconds,()=> {
|
UIManager.ShowGameRoomCountDownPanel(seconds,()=> {
|
||||||
manager.StartGame();
|
manager.StartGame();
|
||||||
},false,true);
|
},false,true);
|
||||||
@ -267,7 +269,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
|
|
||||||
private bool downloading = false;
|
private bool downloading = false;
|
||||||
private CancellationTokenSource cancelToken;
|
private CancellationTokenSource cancelToken;
|
||||||
protected async void DownloadAsync(BaseEventData baseEvent)
|
private async void DownloadAsync(BaseEventData baseEvent)
|
||||||
{
|
{
|
||||||
if (downloading)
|
if (downloading)
|
||||||
return;
|
return;
|
||||||
@ -322,24 +324,35 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
slider.value = value < 1 ? (float)Math.Round(value * 100, 0) : 100;
|
slider.value = value < 1 ? (float)Math.Round(value * 100, 0) : 100;
|
||||||
downloadText.text = slider.value.ToString() + "%";
|
downloadText.text = slider.value.ToString(CultureInfo.InvariantCulture) + "%";
|
||||||
}
|
}
|
||||||
//进入观察模式
|
//进入观察模式
|
||||||
private void WatchHandler(BaseEventData data)
|
private void WatchHandler(BaseEventData data)
|
||||||
{
|
{
|
||||||
var canvasGroup = transform.GetComponent<CanvasGroup>();
|
|
||||||
var ui = manager.GetCanvasTransform();
|
|
||||||
InitAR();
|
InitAR();
|
||||||
MapUDPService.IsWatch = true;
|
InitClientState(true);
|
||||||
MapUDPService.SendGizpModel();
|
|
||||||
canvasGroup.DOFade(0, 1).onComplete += () => {
|
var canvas = transform.GetComponent<CanvasGroup>();
|
||||||
|
var canvasTransform = manager.GetCanvasTransform();
|
||||||
|
canvas.DOFade(0, 1).onComplete += () => {
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
ui.gameObject.SetActive(true);
|
canvasTransform.gameObject.SetActive(true);
|
||||||
manager.SetCurrentMode(VideoGameManager.ARMode.INSPECT);
|
manager.SetCurrentMode(VideoGameManager.ARMode.INSPECT);
|
||||||
manager.StartGame();
|
manager.StartGame();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
protected void Cancel(BaseEventData baseEvent)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 告诉服务器是观察模式还是骑行模式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isWatch"></param>
|
||||||
|
private static void InitClientState(bool isWatch)
|
||||||
|
{
|
||||||
|
MapUDPService.IsWatch = isWatch;
|
||||||
|
MapUDPService.SendGizpModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel(BaseEventData baseEvent)
|
||||||
{
|
{
|
||||||
if (cancelToken == null)
|
if (cancelToken == null)
|
||||||
{
|
{
|
||||||
@ -361,7 +374,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
UIManager.CloseConfirm();
|
UIManager.CloseConfirm();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
protected async void DrawMapRouteAsync(int routeId, int type = 0)
|
private async void DrawMapRouteAsync(int routeId, int type = 0)
|
||||||
{
|
{
|
||||||
var result = await ConfigHelper.mapApi.GetMapLoadingCoverageUrl(routeId, type);
|
var result = await ConfigHelper.mapApi.GetMapLoadingCoverageUrl(routeId, type);
|
||||||
if (!result.result)
|
if (!result.result)
|
||||||
@ -378,7 +391,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
Utils.DisplayImageAysnc(StartCoroutine, mapRouteImage, url, DowloadCallBack);
|
Utils.DisplayImageAysnc(StartCoroutine, mapRouteImage, url, DowloadCallBack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void DowloadCallBack(string url, RawImage rawImage)
|
private void DowloadCallBack(string url, RawImage rawImage)
|
||||||
{
|
{
|
||||||
if (!App.TextureCache.ContainsKey(url))
|
if (!App.TextureCache.ContainsKey(url))
|
||||||
{
|
{
|
||||||
@ -449,11 +462,5 @@ namespace Assets.Scripts.Scenes.VideoRide
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string GetMaxString(string value, int length)
|
|
||||||
{
|
|
||||||
var s = Helper.SubStr(value, length);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
34
Assets/Scripts/Utils/ObjectExtension.cs
Normal file
34
Assets/Scripts/Utils/ObjectExtension.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
public static class ObjectExtension
|
||||||
|
{
|
||||||
|
public static string ToEllipsisString(this string message, int length)
|
||||||
|
{
|
||||||
|
var index = 0;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
foreach (var item in message)
|
||||||
|
{
|
||||||
|
if (IsChineseCharacter(item))
|
||||||
|
{
|
||||||
|
index += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append(item);
|
||||||
|
if (length <= index)
|
||||||
|
{
|
||||||
|
return sb.Append("...").ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsChineseCharacter(char c)
|
||||||
|
{
|
||||||
|
return (19968 <= (int)c) && ((int)c <= 171941);
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Utils/ObjectExtension.cs.meta
Normal file
3
Assets/Scripts/Utils/ObjectExtension.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6474a1d1e1c3429dba1abc390b5e67e9
|
||||||
|
timeCreated: 1678262635
|
||||||
Loading…
x
Reference in New Issue
Block a user