ar骑行bug fix

This commit is contained in:
lishuo committed 2023-02-07 18:35:16 +08:00
1 parent 2c9440f656
commit 08b92e7e9b
37 files changed
+3233 -3358

No files matched your search

@@ -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();