ar骑行bug fix
This commit is contained in:
parent
2c9440f656
commit
08b92e7e9b
@ -64,7 +64,7 @@ namespace Assets.AR
|
||||
videoSync = videoPointsSync;
|
||||
this.VideoPlayerControl = new ARVideoPlayerControl();
|
||||
this.VideoPlayerControl.VideoSyncSource = videoSync;
|
||||
this.videoPlayer = new AVProVideoPlayer();
|
||||
this.videoPlayer = mediaPlayer.gameObject.AddComponent<AVProVideoPlayer>();
|
||||
this.videoPlayer.videoPlayer = mediaPlayer;
|
||||
SetArRoute(new ARRoute(aRData.Route), videoSync, videoPlayer);
|
||||
this.VideoPlayerControl.VideoFrameOffset = this.Route.VideoFrameOffset;
|
||||
@ -76,42 +76,42 @@ namespace Assets.AR
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
//if (manager.IsQuit())
|
||||
// return;
|
||||
|
||||
if (this.videoPlayer == null)
|
||||
return;
|
||||
timers -= Time.deltaTime;
|
||||
|
||||
while (timers <= 0)
|
||||
{
|
||||
foreach (var dic in manager.rideObjs)
|
||||
{
|
||||
|
||||
var item = dic.Value;
|
||||
if (dic.Key.UserId == manager.CurrentPlayer.userId)
|
||||
{
|
||||
mainRiderObject = item;
|
||||
}
|
||||
item.PreSpeed = item.Speed;
|
||||
item.Speed = (float)dic.Key.OnlineSpeed;
|
||||
item.DeltaDistance = (float)(dic.Key.EndDistance - dic.Key.PreDistance);
|
||||
//如果速度为0就停止播放视频
|
||||
if (item.DeltaDistance == 0 || item.Speed == 0)
|
||||
{
|
||||
item.DeltaDistance = 0;
|
||||
videoPlayer.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPlayer.Resume();
|
||||
}
|
||||
item.Route = Route;
|
||||
item.VideoSync = videoPointsSync;
|
||||
item.IsAtFinish = dic.Key.EndDistance >= manager.GetMapRoute().Distance*1000f;
|
||||
if (!this.arObjects.Contains(item))
|
||||
this.arObjects.Add(item);
|
||||
if (!this.riderObjects.ContainsKey(item.UserId))
|
||||
this.riderObjects.Add(item.UserId, item);
|
||||
|
||||
item.PreSpeed = item.Speed;
|
||||
item.Speed = (float)dic.Key.OnlineSpeed;
|
||||
item.DeltaDistance = (float)(dic.Key.EndDistance - dic.Key.PreDistance);
|
||||
item.Route = Route;
|
||||
item.VideoSync = videoPointsSync;
|
||||
item.IsAtFinish = dic.Key.EndDistance >= manager.GetMapRoute().Distance*1000f;
|
||||
|
||||
if (dic.Key.UserId == manager.CurrentUserId)
|
||||
{
|
||||
mainRiderObject = item;
|
||||
//如果速度为0就停止播放视频
|
||||
if (item.DeltaDistance == 0 || item.Speed == 0)
|
||||
{
|
||||
item.DeltaDistance = 0;
|
||||
videoPlayer.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
videoPlayer.Resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.arObjects.RemoveAll(c => !manager.rideObjs.Select(m => m.Key.UserId.ToString()).Contains(c.UserId.ToString()));
|
||||
|
||||
var keys = riderObjects.Keys.ToList();
|
||||
|
||||
18
Assets/Core/DownloadInfo.cs
Normal file
18
Assets/Core/DownloadInfo.cs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
namespace Assets.Core
|
||||
{
|
||||
public class DownloadInfo
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string Url { get; set; }
|
||||
public float Process { get; set; }
|
||||
public DownloadInfo(string FileName, string DisplayName, float Process,string url = "")
|
||||
{
|
||||
this.FileName = FileName;
|
||||
this.DisplayName = DisplayName;
|
||||
this.Process = Process;
|
||||
this.Url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eeac2113ec2cb364fa42782c57e2c802
|
||||
guid: 34041572f14194b4aa5cdbd0318cf85a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19b5fde17c327fc47b67f5109de2b5c1
|
||||
folderAsset: yes
|
||||
timeCreated: 1456430305
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eadea68d080befc40bf4a084b6e50974
|
||||
folderAsset: yes
|
||||
timeCreated: 1456430305
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015,2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public class DoNotFakeAttribute: System.Attribute
|
||||
{
|
||||
public DoNotFakeAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04b72297763b2b248a299450309ef5c3
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,7 +0,0 @@
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
public enum MessageCode
|
||||
{
|
||||
UnityReflectionMethodNotFound
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b489aabd28c6fcd47ba0e3800e63c008
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,16 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class)]
|
||||
public class ObfuscateLiteralsAttribute : System.Attribute
|
||||
{
|
||||
public ObfuscateLiteralsAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015,2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Enum|AttributeTargets.Field|AttributeTargets.Property|AttributeTargets.Delegate)]
|
||||
public class RenameAttribute : System.Attribute
|
||||
{
|
||||
private readonly string target;
|
||||
|
||||
private RenameAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public RenameAttribute(string target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public string GetTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82b8519c2b68ec346a26608597706bb6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Enum|AttributeTargets.Field|AttributeTargets.Property|AttributeTargets.Event|AttributeTargets.Delegate)]
|
||||
public class ReplaceLiteralsWithNameAttribute : System.Attribute
|
||||
{
|
||||
public ReplaceLiteralsWithNameAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deaebd23fa7658a449def3d74a4cb94f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015,2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Event | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Delegate)]
|
||||
public class SkipAttribute : System.Attribute
|
||||
{
|
||||
public SkipAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03318b5bebc7dc74cbb8a77069562661
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015,2016 Beebyte Limited. All rights reserved.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Event | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Delegate)]
|
||||
public class SkipRenameAttribute : System.Attribute
|
||||
{
|
||||
public SkipRenameAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2288ab70b40614240a9d8b9992e32b5d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1 +0,0 @@
|
||||
// Deprecated - See SuppressLogAttribute.cs
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dd28f0e347550542af285906ff2b7b6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Beebyte.Obfuscator
|
||||
{
|
||||
/**
|
||||
* Suppresses certain messages (usually warnings) that the Obfuscator can output.
|
||||
*/
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class SuppressLogAttribute : System.Attribute
|
||||
{
|
||||
#pragma warning disable 414
|
||||
private readonly MessageCode _messageCode;
|
||||
#pragma warning restore 414
|
||||
|
||||
private SuppressLogAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public SuppressLogAttribute(MessageCode messageCode)
|
||||
{
|
||||
_messageCode = messageCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 127983f6e52ffcd48b32ca6570834a69
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -2153,7 +2153,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key: The same AR route video does not need to be downloaded again next time
|
||||
key: GameRoomNeedDownload
|
||||
--- !u!1 &5171024443369967979
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -2572,6 +2572,7 @@ GameObject:
|
||||
- component: {fileID: 1883898665613752188}
|
||||
- component: {fileID: 7782027320298980230}
|
||||
- component: {fileID: 6325806119130258484}
|
||||
- component: {fileID: 5578787585634813026}
|
||||
m_Layer: 5
|
||||
m_Name: Downloading
|
||||
m_TagString: Untagged
|
||||
@ -2639,6 +2640,19 @@ MonoBehaviour:
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: downloading...
|
||||
--- !u!114 &5578787585634813026
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7277102315646152282}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key: downloading
|
||||
--- !u!1 &7312186405814551362
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2986,7 +3000,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: DownloadVideoTip
|
||||
--- !u!1 &8442301620115864133
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -1261,7 +1261,7 @@ GameObject:
|
||||
- component: {fileID: 2034507939346343114}
|
||||
- component: {fileID: 9218768013036575747}
|
||||
m_Layer: 5
|
||||
m_Name: Text (1)
|
||||
m_Name: Tips
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -1339,7 +1339,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: DontNeedDownload
|
||||
--- !u!1 &493373383930290263
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -6022,7 +6022,7 @@ GameObject:
|
||||
- component: {fileID: 935607493012859036}
|
||||
- component: {fileID: 5162612994047282062}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_Name: RouteName
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -6045,7 +6045,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -200}
|
||||
m_SizeDelta: {x: 332, y: 60}
|
||||
m_SizeDelta: {x: 412, y: 60}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &4717817048795811502
|
||||
CanvasRenderer:
|
||||
@ -7317,7 +7317,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -141}
|
||||
m_SizeDelta: {x: 280, y: 50}
|
||||
m_SizeDelta: {x: 412, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6270701084363297290
|
||||
CanvasRenderer:
|
||||
@ -7359,7 +7359,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Download ?
|
||||
m_Text: Download Now?
|
||||
--- !u!114 &5945774264339454888
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -7372,7 +7372,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: Download Now?
|
||||
--- !u!1 &1765163434863270134
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -7786,7 +7786,7 @@ GameObject:
|
||||
- component: {fileID: 7082502746699067195}
|
||||
- component: {fileID: 8030906485536279105}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_Name: Title
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -8874,7 +8874,7 @@ GameObject:
|
||||
- component: {fileID: 7572952141885016866}
|
||||
- component: {fileID: 2002173388039739757}
|
||||
m_Layer: 5
|
||||
m_Name: Text (1)
|
||||
m_Name: Tips
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -8939,8 +8939,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: This room route is an AR route. You need to download the AR video file
|
||||
of this route first.
|
||||
m_Text: The same AR route video does not need to be downloaded again next time
|
||||
--- !u!114 &2002173388039739757
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -8953,7 +8952,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: DontNeedDownload
|
||||
--- !u!1 &2400530268491673124
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -13194,7 +13193,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Enter
|
||||
m_Text: Download
|
||||
--- !u!114 &9016755912838767949
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -17331,7 +17330,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: GameRoomNeedDownload
|
||||
--- !u!1 &4890111740037011948
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -21190,7 +21189,7 @@ GameObject:
|
||||
- component: {fileID: 8004512956775020659}
|
||||
- component: {fileID: 7770947466600092271}
|
||||
m_Layer: 5
|
||||
m_Name: Text (1)
|
||||
m_Name: Tips
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -21255,8 +21254,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: This room route is an AR route. You need to download the AR video file
|
||||
of this route first.
|
||||
m_Text: The same AR route video does not need to be downloaded again next time
|
||||
--- !u!114 &7770947466600092271
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -21269,7 +21267,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: DontNeedDownload
|
||||
--- !u!1 &6106650993063756394
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -24943,7 +24941,7 @@ GameObject:
|
||||
- component: {fileID: 270038558541553861}
|
||||
- component: {fileID: 2706101848219946464}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_Name: Title
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -24966,7 +24964,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -141}
|
||||
m_SizeDelta: {x: 280, y: 50}
|
||||
m_SizeDelta: {x: 412, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &4138584695670000537
|
||||
CanvasRenderer:
|
||||
@ -25008,7 +25006,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Download ?
|
||||
m_Text: Downloading
|
||||
--- !u!114 &2706101848219946464
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -25219,7 +25217,7 @@ GameObject:
|
||||
- component: {fileID: 6332090240037850902}
|
||||
- component: {fileID: 2298784707269391979}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_Name: RouteName
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -25241,8 +25239,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -2000}
|
||||
m_SizeDelta: {x: 332, y: 60}
|
||||
m_AnchoredPosition: {x: 0, y: -199.5}
|
||||
m_SizeDelta: {x: 412, y: 60}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &917069172358647555
|
||||
CanvasRenderer:
|
||||
@ -25696,7 +25694,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e47f6ee11b78f3247a0b474b6c36e2cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key:
|
||||
key: Next Time
|
||||
--- !u!1 &7388770216237101015
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -31414,7 +31412,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 3D
|
||||
m_Text: AR
|
||||
--- !u!114 &8359135444460274282
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -428,7 +428,17 @@
|
||||
"Invitition":"邀请",
|
||||
"invite you to join in":"邀请您加入",
|
||||
"are you accept the invitation?":"是否接受该邀请?",
|
||||
"you have been kicked out of the room":"您已经移除房间!"
|
||||
"you have been kicked out of the room":"您已经移除房间!",
|
||||
"DownloadVideoTip":"这是一个视频线路,你必须提前下载该视频!",
|
||||
"Downloading":"下载中...",
|
||||
"more":"更多",
|
||||
"Tips":"温馨提示",
|
||||
"CancelDownloadConfirm":"当前有下载任务,是否取消下载?",
|
||||
"Download Now?":"立即下载",
|
||||
"GameRoomNeedDownload": "当前线路需要下载视频后才能进入对战房间!",
|
||||
"Run In The Background":"后台下载",
|
||||
"Next Time":"下次再说",
|
||||
"DontNeedDownload":"当前视频下载完成后,下次进入线路就不需要重复下载."
|
||||
},
|
||||
"en": {
|
||||
"HOT ROUTES": "HOT ROUTES",
|
||||
@ -852,6 +862,16 @@
|
||||
"Invitition":"Invitition",
|
||||
"invite you to join in":"invite you to join in",
|
||||
"are you accept the invitation?":"are you accept the invitation?",
|
||||
"you have been kicked out of the room":"you have been kicked out of the room!"
|
||||
"you have been kicked out of the room":"you have been kicked out of the room!",
|
||||
"DownloadVideoTip":"This map is an AR route,you need to download the route video in advance",
|
||||
"Downloading":"Downloading...",
|
||||
"more":"more",
|
||||
"Tips":"Tips",
|
||||
"CancelDownloadConfirm":"please confirm to cancel current downloading task?",
|
||||
"Download Now?":"Download Now?",
|
||||
"GameRoomNeedDownload": "This room route is an AR route. You need to download the AR video file of this route first.",
|
||||
"Run In The Background":"Run In The Background",
|
||||
"Next Time":"Next Time",
|
||||
"DontNeedDownload":"The same AR route video does not need to be downloaded again next time"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -82,7 +82,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
currentHead.transform.position = vector3;
|
||||
}
|
||||
//控制海拔图头像
|
||||
if (manager.CurrentPlayer.userId == item.UserId)
|
||||
if (manager.CurrentUserId == item.UserId)
|
||||
{
|
||||
currentHead.transform.Find("Main").gameObject.SetActive(true);
|
||||
currentHead.transform.SetAsLastSibling();
|
||||
|
||||
@ -177,13 +177,13 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
//断网移除所有用户
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
rideObjs.Clear();
|
||||
visibleRiders.Clear();
|
||||
var onlineUserList = FindObjectsOfType<AbstractVideoPlayer>();
|
||||
foreach (var item in onlineUserList)
|
||||
foreach (var item in visibleRiders)
|
||||
{
|
||||
Debug.Log($"销毁了{item}");
|
||||
DestroyImmediate(item.gameObject);
|
||||
}
|
||||
rideObjs.Clear();
|
||||
visibleRiders.Clear();
|
||||
CurrentPlayer = null;
|
||||
return;
|
||||
}
|
||||
@ -204,7 +204,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
//如果当前为观察者模式且currentPlayerInfo为null随机选择以为用户观察
|
||||
if (currentPlayerInfo == null)
|
||||
{
|
||||
currentPlayerInfo = needUpdateList.Where(c => c.UserId == currentUserId).FirstOrDefault();
|
||||
currentPlayerInfo = needUpdateList.Where(c => c.UserId == CurrentUserId).FirstOrDefault();
|
||||
if(currentPlayerInfo == null)
|
||||
currentPlayerInfo = needUpdateList.FirstOrDefault();
|
||||
}
|
||||
@ -215,10 +215,11 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
var visibleItem = visibleRiders.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
||||
if (visibleItem != null)
|
||||
{
|
||||
Debug.Log($"count {visibleRiders.Count()}");
|
||||
visibleItem.SetPlayer(onlineRider.NickName, onlineRider.Speed, onlineRider.PreDistance, onlineRider.EndDistance, item.Cadence, item.HeartRate, onlineRider.WeightKg, item.UserId, onlineRider.Power, currentPlayerInfo.EndDistance, onlineRider.FrameRate.Value);
|
||||
if(visibleItem.userId == currentUserId)
|
||||
if (visibleItem.userId == CurrentUserId)
|
||||
{
|
||||
CurrentPlayer = visibleItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -246,8 +247,10 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
visibleRiders.Add(online);
|
||||
trainController.AddRider(onlineRider);
|
||||
online.SetPlayer(onlineRider.NickName, onlineRider.Speed, onlineRider.PreDistance, onlineRider.EndDistance, item.Cadence, item.HeartRate, onlineRider.WeightKg, item.UserId, onlineRider.Power, currentPlayerInfo.EndDistance, onlineRider.FrameRate.Value);
|
||||
if (currentPlayerInfo.UserId == item.UserId)
|
||||
CurrentPlayer = online;
|
||||
if (online.userId == CurrentUserId)
|
||||
{
|
||||
CurrentPlayer = visibleItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -262,6 +265,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
videoPlayer = Instantiate(playerprefabNV, transform);
|
||||
}
|
||||
|
||||
CurrentUserId = App.CurrentUser.Id;
|
||||
CurrentPlayer = videoPlayer.GetComponent<AbstractVideoPlayer>();
|
||||
var vp = videoPlayer.GetComponent<VideoPlayer>();
|
||||
vp.SetEndDistance(item.EndDistance);
|
||||
@ -290,8 +294,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
uimanager.SetCurrentMode(aRMode);
|
||||
if (_aRMode != ARMode.INSPECT)
|
||||
{
|
||||
//InitCurrentPlayer();
|
||||
Debug.Log("ContinueAsync");
|
||||
CurrentUserId = App.CurrentUser.Id;
|
||||
ContinueAsync();
|
||||
}
|
||||
else
|
||||
@ -301,11 +304,12 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
public GameObject videoPlayer;
|
||||
public GameObject target;
|
||||
private int currentUserId { get; set; }
|
||||
public int CurrentUserId { get; set; }
|
||||
//切换人物
|
||||
public void ChangePlayer(int userId)
|
||||
{
|
||||
currentUserId = userId;
|
||||
Debug.Log($"切换到{userId}");
|
||||
CurrentUserId = userId;
|
||||
}
|
||||
//获取角色头顶信息预制件
|
||||
public GameObject GetHeadInfo()
|
||||
|
||||
@ -219,14 +219,14 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
bool startBtnLock = false;
|
||||
public async void StartRide(BaseEventData baseEvent)
|
||||
public void StartRide(BaseEventData baseEvent)
|
||||
{
|
||||
if (startBtnLock)
|
||||
return;
|
||||
startBtnLock = true;
|
||||
var ui = manager.GetCanvasTransform();
|
||||
InitAR();
|
||||
canvasGroup.DOFade(0, 1).onComplete += () => {
|
||||
InitAR();
|
||||
gameObject.SetActive(false);
|
||||
manager.StartGame();
|
||||
manager.SetCyclingModel(Assets.Scenes.Ride.Scripts.Model.CyclingModel.Single);
|
||||
@ -236,7 +236,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
public async void InitAR()
|
||||
{
|
||||
//加载本地文件
|
||||
var route = manager.mapRoute;
|
||||
var arDataPath = $"{PFConstants.ARFolder}/{route.Id}/{route.Id}.json";
|
||||
var videoRoute = $"{PFConstants.ARFolder}/{route.Id}/route-{route.Id}.json";
|
||||
@ -254,8 +253,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public void StartRide(int seconds)
|
||||
{
|
||||
var ui = manager.GetCanvasTransform();
|
||||
InitAR();
|
||||
canvasGroup.DOFade(0, 0).onComplete += () => {
|
||||
InitAR();
|
||||
gameObject.SetActive(false);
|
||||
manager.SetCyclingModel(CyclingModel.GameRoom);
|
||||
manager.SetCurrentMode(VideoGameManager.ARMode.RIDE);
|
||||
@ -266,47 +265,64 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
},false,true);
|
||||
}
|
||||
|
||||
private bool downloading = false;
|
||||
private CancellationTokenSource cancelToken;
|
||||
protected async void DownloadAsync(BaseEventData baseEvent)
|
||||
{
|
||||
if (downloading)
|
||||
return;
|
||||
|
||||
beforeDownload();
|
||||
await startDownloading();
|
||||
}
|
||||
|
||||
private void beforeDownload()
|
||||
{
|
||||
downloading = true;
|
||||
download.SetActive(false);
|
||||
rideNow.enabled = false;
|
||||
rideNow.interactable = false;
|
||||
downloadText.text = "0%";
|
||||
}
|
||||
|
||||
private async Task startDownloading()
|
||||
{
|
||||
var route = manager.mapRoute;
|
||||
var path = PFConstants.VideoFolder;
|
||||
|
||||
var localPath = PFConstants.ARFolder;
|
||||
var arDataPath = route.ARConfig;
|
||||
var videoRoute = route.VideoRoute;
|
||||
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var res1 = await UnityWebRequest.Get(arDataPath).SendWebRequest().WithCancellation(cancelToken.Token);//下载AR数据
|
||||
var res2 = await UnityWebRequest.Get(videoRoute).SendWebRequest().WithCancellation(cancelToken.Token);//下载video视频数据
|
||||
var res3 = await UnityWebRequest.Get(route.Url).SendWebRequest().ToUniTask(progress: this);//下载视频
|
||||
//持久化到磁盘
|
||||
var dataPath = $"{localPath}/{route.Id}";
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
File.WriteAllBytes($"{dataPath}/{route.Id}.json", res1.downloadHandler.data);
|
||||
File.WriteAllBytes($"{dataPath}/route-{route.Id}.json", res2.downloadHandler.data);
|
||||
File.WriteAllBytes($"{path}/{route.FileName}", res3.downloadHandler.data);
|
||||
|
||||
rideNow.enabled = true;
|
||||
rideNow.interactable = true;
|
||||
downloadText.text = App.GetLocalString("Ride Now");
|
||||
var filepath = $"{path}/{route.FileName}";
|
||||
manager.SetMedia(filepath);
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
|
||||
cancelToken = new CancellationTokenSource();
|
||||
|
||||
await Loom.DownloadToFileAsync(arDataPath, $"{dataPath}/{route.Id}.json");
|
||||
await Loom.DownloadToFileAsync(videoRoute, $"{dataPath}/route-{route.Id}.json");
|
||||
var res = await Loom.DownloadToFileAsync(route.Url, $"{path}/{route.FileName}",this,cancelToken);
|
||||
if (res.isDone)
|
||||
{
|
||||
var filepath = $"{PFConstants.VideoFolder}/{route.FileName}";
|
||||
manager.SetMedia(filepath);
|
||||
|
||||
rideNow.enabled = true;
|
||||
rideNow.interactable = true;
|
||||
|
||||
downloadText.text = App.GetLocalString("Ride Now");
|
||||
downloading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Report(float value)
|
||||
{
|
||||
if (value < 1)
|
||||
{
|
||||
rideNow.enabled = false;
|
||||
rideNow.interactable = false;
|
||||
slider.value = (float)Math.Round(value * 100, 0);
|
||||
downloadText.text = slider.value.ToString() + "%";
|
||||
download.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
slider.value = 100;
|
||||
}
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
slider.value = value < 1 ? (float)Math.Round(value * 100, 0) : 100;
|
||||
downloadText.text = slider.value.ToString() + "%";
|
||||
}
|
||||
//进入观察模式
|
||||
private void WatchHandler(BaseEventData data)
|
||||
@ -325,7 +341,25 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
protected void Cancel(BaseEventData baseEvent)
|
||||
{
|
||||
SceneManager.LoadScene("MainScene");
|
||||
if (cancelToken == null)
|
||||
{
|
||||
SceneManager.LoadSceneAsync("MainScene");
|
||||
return;
|
||||
}
|
||||
|
||||
UIManager.SetModalPanel(transform.Find("ModalPanel").GetComponent<PFUIPanel>());
|
||||
UIManager.ShowConfirm("Tips", "CancelDownloadConfirm",
|
||||
() =>
|
||||
{
|
||||
cancelToken?.Cancel();
|
||||
SceneManager.LoadSceneAsync("MainScene");
|
||||
UIManager.CloseConfirm();
|
||||
},
|
||||
2,
|
||||
() =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
protected async void DrawMapRouteAsync(int routeId, int type = 0)
|
||||
{
|
||||
|
||||
@ -264,9 +264,11 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
private void QuitClick(BaseEventData e)
|
||||
{
|
||||
if (manager.CurrentPlayer != null && manager.CurrentPlayer.UserId == App.CurrentUser.Id && (manager.CurrentPlayer.ticks == 0 || manager.CurrentPlayer.EndDistance - manager.CurrentPlayer.StartDistance < 0.1f))
|
||||
var idMainRider = manager.CurrentPlayer != null && manager.CurrentPlayer.UserId == App.CurrentUser.Id;
|
||||
var shortDistance = idMainRider && (manager.CurrentPlayer.ticks == 0 || manager.cyclingController.recorderData.RiderDatas.Count == 0 || manager.CurrentPlayer.EndDistance - manager.CurrentPlayer.StartDistance < 0.1f);
|
||||
if (shortDistance)
|
||||
{
|
||||
UIManager.ShowConfirm("Quit", App.GetLocalString("Current ride distance too short to save."), () => {
|
||||
UIManager.ShowConfirm(App.GetLocalString("Quit"), App.GetLocalString("Current ride distance too short to save."), () => {
|
||||
UIManager.CloseConfirm();
|
||||
SceneManager.LoadSceneAsync("MainScene");
|
||||
}, 2, () => { UIManager.CloseConfirm(); });
|
||||
@ -276,7 +278,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
if (manager._aRMode == VideoGameManager.ARMode.RIDE)
|
||||
{
|
||||
|
||||
UIManager.ShowConfirm("Quit", "Do you want to keep the record?",
|
||||
UIManager.ShowConfirm(App.GetLocalString("Quit"), App.GetLocalString("Do you want to keep the record?"),
|
||||
() =>
|
||||
{
|
||||
SaveAndShowResult();
|
||||
@ -291,7 +293,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowConfirm("Quit", "Do you want to quit?", () =>
|
||||
UIManager.ShowConfirm(App.GetLocalString("Quit"), App.GetLocalString("Do you want to quit?"), () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
SceneManager.LoadSceneAsync("MainScene");
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -31,8 +32,9 @@ class GameRoomDownLoad : MonoBehaviour
|
||||
public GameObject downLoadTask;
|
||||
|
||||
private GameRoomListController manager;
|
||||
private int RoomId { get; set; }
|
||||
private string FileName { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string RouteName { get; set; }
|
||||
private string FileUrl { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
@ -69,23 +71,27 @@ class GameRoomDownLoad : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(FileName) && Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
{
|
||||
processing(Loom.DownLoadTaskList[FileName]);
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(FileName) && Loom.DownloadStack.ContainsKey(FileName))
|
||||
//{
|
||||
// processing(Loom.DownloadStack[FileName]);
|
||||
//}
|
||||
}
|
||||
|
||||
public void Init(int Id,string fileName,string url, GameRoomListController gameRoomListController)
|
||||
|
||||
public void Init(int Id, string fileName, string url, GameRoomListController gameRoomListController, string routeName)
|
||||
{
|
||||
RoomId = Id;
|
||||
FileName = fileName;
|
||||
RouteName = routeName;
|
||||
FileUrl = url;
|
||||
manager = gameRoomListController;
|
||||
}
|
||||
public void ComeIntoStep2(string fileName)
|
||||
public void ComeIntoStep2(string fileName, string routeName)
|
||||
{
|
||||
FileName = fileName;
|
||||
RouteName = routeName;
|
||||
step2.SetActive(true);
|
||||
step2.transform.Find("RouteName").GetComponent<Text>().text = routeName;
|
||||
step3.transform.Find("RouteName").GetComponent<Text>().text = routeName;
|
||||
step3.SetActive(false);
|
||||
}
|
||||
|
||||
@ -103,60 +109,34 @@ class GameRoomDownLoad : MonoBehaviour
|
||||
private void processing(float p)
|
||||
{
|
||||
downloadSlider.value = p;
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
|
||||
if (!Loom.DownloadStack.ContainsKey(FileName) )
|
||||
{
|
||||
Loom.DownLoadTaskList[FileName] = p;
|
||||
Loom.DownloadStack.Add(FileName, new Assets.Core.DownloadInfo(FileName, RouteName, p));
|
||||
}
|
||||
else
|
||||
|
||||
Loom.DownloadStack[FileName].Process = p;
|
||||
|
||||
if (p >= 1)
|
||||
{
|
||||
Loom.DownLoadTaskList.Add(FileName, p);
|
||||
Loom.DownloadStack.Remove(FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void DownloadClick(BaseEventData baseEventData)
|
||||
private async void DownloadClick(BaseEventData baseEventData)
|
||||
{
|
||||
var fileName = FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
var url = FileUrl;
|
||||
|
||||
step2.SetActive(true);
|
||||
step2.transform.Find("RouteName").GetComponent<Text>().text = RouteName;
|
||||
|
||||
|
||||
//新增
|
||||
var content = downLoadList.transform.Find("Viewport/Content");
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
var currentTask = newtask.GetComponent<GameRoomDownloadTask>();
|
||||
currentTask.Init(RoomId, fileName,gameObject);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadFileWithProcess(fileName, url
|
||||
, path,(p, req) =>
|
||||
{
|
||||
currentTask.UpdateProcess(p);
|
||||
processing(p);
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(p))
|
||||
var filepath = PFConstants.VideoFolder + "/" + FileName;
|
||||
await Loom.DownloadToFileAsync(FileUrl, filepath, Progress.Create<float>(x => {
|
||||
processing(x);
|
||||
if (x >= 1)
|
||||
{
|
||||
var process = 100f;
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
{
|
||||
Loom.DownLoadTaskList[FileName] = process;
|
||||
}
|
||||
else
|
||||
{
|
||||
Loom.DownLoadTaskList.Add(FileName, process);
|
||||
}
|
||||
currentTask.UpdateProcess(process);
|
||||
downloadSlider.value = process;
|
||||
downloadSlider.value = 100;
|
||||
step3.SetActive(true);
|
||||
step3.transform.Find("RouteName").GetComponent<Text>().text = RouteName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, p);
|
||||
}
|
||||
}
|
||||
));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,32 +18,41 @@ class GameRoomDownloadTask : MonoBehaviour
|
||||
private Text fileNameText;
|
||||
|
||||
public int RoomId { get; set; }
|
||||
public string RouteName { get; set; }
|
||||
public string FileName { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
modal.SetActive(true);
|
||||
modal.GetComponent<GameRoomDownLoad>().ComeIntoStep2(FileName);
|
||||
if (!modal.transform.parent.Find("MapList").gameObject.activeSelf)
|
||||
{
|
||||
modal.SetActive(true);
|
||||
modal.GetComponent<GameRoomDownLoad>().ComeIntoStep2(FileName, RouteName);
|
||||
}
|
||||
else
|
||||
{
|
||||
modal.SetActive(false);
|
||||
}
|
||||
//transform.parent.parent.parent.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int roomId,string fileName,GameObject downloadPanel)
|
||||
public void Init(int roomId,string fileName,string routeName,GameObject downloadPanel)
|
||||
{
|
||||
modal = downloadPanel;
|
||||
fileNameText = transform.Find("Text").GetComponent<Text>();
|
||||
RoomId = roomId;
|
||||
fileNameText.text = fileName;
|
||||
RouteName = routeName;
|
||||
fileNameText.text = routeName;
|
||||
FileName = fileName;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
if (Loom.DownloadStack.ContainsKey(FileName))
|
||||
{
|
||||
UpdateProcess(Loom.DownLoadTaskList[FileName]);
|
||||
UpdateProcess(Loom.DownloadStack[FileName].Process);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,11 +64,12 @@ class GameRoomDownloadTask : MonoBehaviour
|
||||
done.SetActive(true);
|
||||
doneTxt.SetActive(true);
|
||||
icon.SetActive(false);
|
||||
Loom.DownloadStack.Remove(FileName);
|
||||
canvasGroup.DOFade(0, 2).onComplete += () =>
|
||||
{
|
||||
slider.gameObject.SetActive(false);
|
||||
gameObject.Destroy();
|
||||
Loom.DownLoadTaskList.Remove(FileName);
|
||||
Loom.DownloadStack.Remove(FileName);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(map.EnableAR && !File.Exists(filepath));
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, (e) =>
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, async (e) =>
|
||||
{
|
||||
downloadBtn.SetActive(false);
|
||||
downloading.SetActive(true);
|
||||
@ -80,19 +80,12 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
slider.gameObject.SetActive(true);
|
||||
var progress = Progress.Create<float>(x =>
|
||||
{
|
||||
Loom.DownLoadTaskList[map.FileName] = x;
|
||||
Loom.DownloadStack[map.FileName].Process = x;
|
||||
slider.value = x;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)this.slider.transform);
|
||||
if (x == 1)
|
||||
{
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(true);
|
||||
}
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(x!=1);
|
||||
});
|
||||
Loom.Download(map, progress);
|
||||
await Loom.DownloadLoadARDataAndVideo(map, progress);
|
||||
});
|
||||
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
|
||||
@ -80,7 +80,7 @@ public class GameRoomListController : PFUIPanel
|
||||
private int CloseTime;
|
||||
private int Members;
|
||||
private GameRoomModel GameRoom;
|
||||
|
||||
private int RoomId;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform _rectTransform;
|
||||
@ -181,12 +181,6 @@ public class GameRoomListController : PFUIPanel
|
||||
Total = roomList.GameRoomTotal;
|
||||
ListChanged = true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// list = null;
|
||||
// Total = 0;
|
||||
// ListChanged = true;
|
||||
//}
|
||||
//查询自己当前创建的房间信息并进入
|
||||
var info = message.Where(c => c.RoomList != null && c.RoomList.Where(o => o.UserId == App.CurrentUser.Id && o.Status == 0).Any()).FirstOrDefault();
|
||||
if (info != null)
|
||||
@ -194,11 +188,15 @@ public class GameRoomListController : PFUIPanel
|
||||
GameRoom = info.RoomList[0];
|
||||
App.gameRoomDetail = GameRoom;
|
||||
CreateRoomSuccessed = true;
|
||||
//进入房间清空列表
|
||||
list = null;
|
||||
Total = 0;
|
||||
ListChanged = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
protected override void Start()
|
||||
@ -223,7 +221,7 @@ public class GameRoomListController : PFUIPanel
|
||||
MapUDPService.MessageListener = ListenerHandler;
|
||||
MapUDPService.SendQueryGameRoomList(App.CurrentUser.Id, pageHelper.PageIndex, pageHelper.PageSize, seachName);
|
||||
}
|
||||
private List<string> fileNameList = new List<string>();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//房间已经进行骑行时间
|
||||
@ -257,7 +255,7 @@ public class GameRoomListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//列表改变事件
|
||||
if (ListChanged)
|
||||
{
|
||||
Refreash();
|
||||
@ -270,25 +268,29 @@ public class GameRoomListController : PFUIPanel
|
||||
CreateClicked = false;
|
||||
UIManager.ShowGameRoomDetailPanel();
|
||||
}
|
||||
|
||||
//LOOM中取数据渲染下载当前下载进度
|
||||
var downLoadList = transform.Find("DownLoadList").gameObject;
|
||||
var downloadPanel = transform.Find("DownloadPanel").gameObject;
|
||||
if (Loom.DownLoadTaskList.Count>0)
|
||||
var list = Loom.DownloadStack.Where(c => c.Value.Process < 1);
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
downLoadList.SetActive(true);
|
||||
var downloadPanel = transform.Find("DownloadPanel").gameObject;
|
||||
var content = downLoadList.transform.Find("Viewport/Content");
|
||||
foreach (var item in Loom.DownLoadTaskList)
|
||||
var currentList = FindObjectsOfType<GameRoomDownloadTask>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var done = fileNameList.Where(c => c.Equals(item.Key)).Any();
|
||||
if (!done)
|
||||
var loaded = currentList.Where(c => c.FileName.Equals(item.Key)).Any();
|
||||
if (!loaded)
|
||||
{
|
||||
fileNameList.Add(item.Key);
|
||||
var newtask = Instantiate(_downLoadTask, content);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(0, item.Key, downloadPanel);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(0, item.Key, item.Value.DisplayName, downloadPanel);
|
||||
}
|
||||
downLoadList.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
downLoadList.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitStep1()
|
||||
@ -744,7 +746,7 @@ public class GameRoomListController : PFUIPanel
|
||||
//查询fileUrl
|
||||
GameRoom.FileUrl = ConfigHelper.GameRoomApi.GetMapVideoURL(GameRoom.MapRouteId).data;
|
||||
download.SetActive(true);
|
||||
download.GetComponent<GameRoomDownLoad>().Init(RoomId, GameRoom.FileName, GameRoom.FileUrl, this);
|
||||
download.GetComponent<GameRoomDownLoad>().Init(RoomId, GameRoom.FileName, GameRoom.FileUrl, this, GameRoom.MapRouteName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -785,6 +787,7 @@ public class GameRoomListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowStatusModal(Transform tr,GameRoomModel data)
|
||||
{
|
||||
tr.Find("Modal/Id").GetComponent<Text>().text = data.RoomId.ToString().PadLeft(7, '0');
|
||||
@ -814,7 +817,7 @@ public class GameRoomListController : PFUIPanel
|
||||
UIManager.AddEvent(quit, EventTriggerType.PointerClick, (e) => { tr.gameObject.SetActive(false); });
|
||||
tr.gameObject.SetActive(true);
|
||||
}
|
||||
private int RoomId;
|
||||
|
||||
|
||||
public void GetInRoom()
|
||||
{
|
||||
@ -837,6 +840,7 @@ public class GameRoomListController : PFUIPanel
|
||||
MapUDPService.SendJoinGameRoom(App.gameRoomDetail.RoomId,App.CurrentUser.Id,UIManager.Now.GetDateTime().ToUniversalTime());
|
||||
UIManager.ShowGameRoomDetailPanel();
|
||||
}
|
||||
|
||||
public void SelectRoom(GameRoomModel room)
|
||||
{
|
||||
GameRoom = room;
|
||||
@ -881,6 +885,7 @@ public class GameRoomListController : PFUIPanel
|
||||
tabContainer.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImage(map.CountryCode);
|
||||
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
|
||||
@ -18,6 +18,7 @@ using UnityEngine.SceneManagement;
|
||||
using System.Threading;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Scenes.VideoRide;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
@ -1387,4 +1388,21 @@ public class UIManager : MonoBehaviour
|
||||
CloseConfirm();
|
||||
}, 2);
|
||||
}
|
||||
|
||||
//下载文件到本地
|
||||
IEnumerator DownloadToFile(string url,string filePath)
|
||||
{
|
||||
var uwr = new UnityWebRequest(url);
|
||||
uwr.method = UnityWebRequest.kHttpVerbGET;
|
||||
var dh = new DownloadHandlerFile(filePath);
|
||||
dh.removeFileOnAbort = true;
|
||||
uwr.downloadHandler = dh;
|
||||
yield return uwr.SendWebRequest();
|
||||
if (uwr.isHttpError)
|
||||
Debug.Log(uwr.error);
|
||||
else
|
||||
{
|
||||
Debug.Log("Download saved to: " + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Core;
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System;
|
||||
@ -7,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
@ -18,8 +20,6 @@ public class Loom : MonoBehaviour
|
||||
public static int maxThreads = 8;
|
||||
static int numThreads;
|
||||
|
||||
public static Dictionary<string, float> DownLoadTaskList = new Dictionary<string, float>();
|
||||
|
||||
private static Loom _current;
|
||||
public static Loom Current
|
||||
{
|
||||
@ -132,14 +132,6 @@ public class Loom : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
List<Action> _currentActions = new List<Action>();
|
||||
|
||||
// Update is called once per frame
|
||||
@ -179,23 +171,44 @@ public class Loom : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public static async void Download(MapRoute route,IProgress<float> progress)
|
||||
public static Dictionary<string, DownloadInfo> DownloadStack = new Dictionary<string, DownloadInfo>();
|
||||
|
||||
public static async Task DownloadLoadARDataAndVideo(MapRoute route,IProgress<float> progress)
|
||||
{
|
||||
DownLoadTaskList.Add(route.FileName, 0);
|
||||
DownloadStack.Add(route.FileName, new DownloadInfo(route.FileName,route.Name,0, route.Url));
|
||||
|
||||
var path = PFConstants.VideoFolder;
|
||||
var localPath = PFConstants.ARFolder;
|
||||
var arDataPath = route.ARConfig;
|
||||
var videoRoute = route.VideoRoute;
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var res1 = await UnityWebRequest.Get(arDataPath).SendWebRequest().WithCancellation(cancelToken.Token);//下载AR数据
|
||||
var res2 = await UnityWebRequest.Get(videoRoute).SendWebRequest().WithCancellation(cancelToken.Token);//下载video视频数据
|
||||
var res3 = await UnityWebRequest.Get(route.Url).SendWebRequest().ToUniTask(progress);//下载视频
|
||||
|
||||
var dataPath = $"{localPath}/{route.Id}";
|
||||
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
Helper.CreateDirectoryIfNotExsit(dataPath);
|
||||
File.WriteAllBytes($"{dataPath}/{route.Id}.json", res1.downloadHandler.data);
|
||||
File.WriteAllBytes($"{dataPath}/route-{route.Id}.json", res2.downloadHandler.data);
|
||||
File.WriteAllBytes($"{path}/{route.FileName}", res3.downloadHandler.data);
|
||||
|
||||
await Loom.DownloadToFileAsync(arDataPath, $"{dataPath}/{route.Id}.json");
|
||||
await Loom.DownloadToFileAsync(videoRoute, $"{dataPath}/route-{route.Id}.json");
|
||||
await Loom.DownloadToFileAsync(route.Url, $"{path}/{route.FileName}", progress, cancelToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载文件到本地(持续存入磁盘减少内存占用)
|
||||
/// </summary>
|
||||
/// <param name="downloadUrl">文件连接</param>
|
||||
/// <param name="fullPath">本地文件全路径</param>
|
||||
/// <param name="progress">下载进度</param>
|
||||
public static async UniTask<UnityWebRequest> DownloadToFileAsync(string downloadUrl, string fullPath, IProgress<float> progress = null, CancellationTokenSource cancellation = default(CancellationTokenSource))
|
||||
{
|
||||
var dh = new DownloadHandlerFile(fullPath)
|
||||
{
|
||||
removeFileOnAbort = true
|
||||
};
|
||||
|
||||
var request = UnityWebRequest.Get(downloadUrl);
|
||||
request.method = UnityWebRequest.kHttpVerbGET;
|
||||
request.downloadHandler = dh;
|
||||
|
||||
return await request.SendWebRequest().ToUniTask(progress, PlayerLoopTiming.Update, (cancellation?.Token ?? default(CancellationToken)));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user