对战AR
This commit is contained in:
1 parent
509c309252
commit
11b131b24a
60 files changed
+2505
-632
No files matched your search
@@ -37,5 +37,10 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
return await GetAsync<JsonResult<JObject>>($"GameRoom/ConfirmRoomPwd?id={id}&pwd={pwd}");
|
||||
}
|
||||
|
||||
public JsonResult<string> GetMapVideoURL(int routeId)
|
||||
{
|
||||
return Get<JsonResult<string>>($"Map/GetMapVideoURL?id={routeId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,12 +46,12 @@ namespace Assets.Scripts.Apis.Models
|
||||
public List<RoomPlayerModel> RoomPlayerList { get; set; }
|
||||
public static List<GameRoomModel> Parse(string s)
|
||||
{
|
||||
if (s.Equals("list"))
|
||||
if (s.Equals("l"))
|
||||
return null;
|
||||
List<GameRoomModel> list = new List<GameRoomModel>();
|
||||
try
|
||||
{
|
||||
var arr = s.Replace("list[", "").Replace("[","").Split(']');
|
||||
var arr = s.Replace("l[", "").Replace("[","").Split(']');
|
||||
foreach (var item in arr)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item))
|
||||
@@ -103,6 +103,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
public int RoomId { get; set; }
|
||||
public string WxHeadImage { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Country { get; set; }
|
||||
public int Sex { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public int FTP { get; set; }
|
||||
@@ -151,6 +152,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
item.Weight = user.Weight;
|
||||
item.Name = user.Name;
|
||||
item.Sex = user.Sex;
|
||||
item.Country = user.Country;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
MapUDPService.Send(route.RouteInstance.Id, recorderData.BelongUserId,
|
||||
new double[] { lastData._Lat, lastData._Lon },
|
||||
recorderData.IsCompleted, false, recorderData.EndDistance,
|
||||
true, 1, lastData._Speed, false, preDistance, weightKg, competitionId: recorderData.Competitionid, recorderData.Saved, 0, lastData._Power, lastData._Cadence, lastData.Ticks, (lastData._FrameRate??0),roomId: (recorderData.RoomId??0));
|
||||
true, 1, lastData._Speed, false, preDistance, weightKg, competitionId: recorderData.Competitionid, recorderData.Saved, 0, lastData._Power, lastData._Cadence, lastData.Ticks, (lastData._FrameRate??0),roomId: recorderData.RoomId);
|
||||
}
|
||||
else if (recorderData.EndDistance > 0)//没有骑,但是有初始位置的情况
|
||||
{
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
StartTime = DateTime.Now,//UIManager.Now.GetDateTime(),//DateTime.Now
|
||||
selectParam = param,
|
||||
RoomId = App.gameRoomDetail.RoomId,
|
||||
};
|
||||
|
||||
};
|
||||
App.gameRoomDetail = null;
|
||||
if (param != null)
|
||||
{
|
||||
recorderData.EndDistance = param.EndDistance;
|
||||
@@ -55,7 +55,7 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
{
|
||||
#region 获取当前路线在线用户
|
||||
riders.RemoveAll(r => r.IsSelf == false);
|
||||
var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id,App.gameRoomDetail.RoomId).Where(d => d.IsSelf == false)
|
||||
var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id, recorderData.RoomId).Where(d => d.IsSelf == false)
|
||||
.ToList();
|
||||
foreach (var item in onlineUsers)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,9 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
}
|
||||
public class ExtendInfo
|
||||
{
|
||||
public int TotalTicks { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
public int FrameRate { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public static ExtendInfo Parse(string s)
|
||||
{
|
||||
@@ -55,6 +57,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
{
|
||||
UserId = Convert.ToInt32(info[0]),
|
||||
RoomId = Convert.ToInt32(info[1]),
|
||||
FrameRate = Convert.ToInt32(info[2]),
|
||||
TotalTicks = Convert.ToInt32(info[3]),
|
||||
};
|
||||
return ex;
|
||||
}
|
||||
@@ -576,8 +580,10 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
|
||||
public string WatchIdList { get; set; }
|
||||
|
||||
public int? FrameRate { get; set; }
|
||||
public int FrameRate { get; set; }
|
||||
public int? RoomId { get; set; }
|
||||
|
||||
public int GameRoomTotal { get; set; }
|
||||
public List<GameRoomModel> RoomList { get; set; }
|
||||
public GameRoomModel RoomDetail { get; set; }
|
||||
|
||||
@@ -746,7 +752,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public int? FrameRate { get; set; }
|
||||
public int FrameRate { get; set; }
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
|
||||
public int? LastFrame { get; set; }
|
||||
|
||||
public int? RoomId { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否已经保存成功
|
||||
/// </summary>
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
AverageGrade = averageGrade,
|
||||
AltitudeGraph = altitudeGraph,
|
||||
FileName = fileName,
|
||||
FileUrl = fileUrl,
|
||||
FileUrl = "",//url下载的时候查询
|
||||
CommandType = 3,
|
||||
SubType = 0,
|
||||
V = 2,
|
||||
|
||||
@@ -201,14 +201,27 @@ namespace Assets.Scenes.Ride.Scripts.Network
|
||||
if (t.IndexOf('g') == 0)
|
||||
{
|
||||
var x = t.Replace("g{", "").Replace("}", "");
|
||||
//list[0,0,321313,30,5,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,213,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][0,0,2131,30,4,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,313,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][20,16652,3213,30,3,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 8:41:34:][19,16652,测试3d线路,30,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 1:39:57:][18,16652,测试,61,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/4/25 2:34:03:][17,16652,213,30,3,1217,翠屏山后山北向南,5.271609999999998,65.22760000000001,0.23308249282477278,False,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=1217,0,2022/4/25 2:20:13:]
|
||||
var li = GameRoomModel.Parse(x);
|
||||
foreach (var i in list)
|
||||
//l2[0,0,321313,30,5,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,213,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][0,0,2131,30,4,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,313,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,:][20,16652,3213,30,3,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 8:41:34:][19,16652,测试3d线路,30,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/5/6 1:39:57:][18,16652,测试,61,2,5492,福州化工路-鼓山峰爬坡线路,19.17906,815.9704000000002,4.0466336723489045,True,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=5492,0,2022/4/25 2:34:03:][17,16652,213,30,3,1217,翠屏山后山北向南,5.271609999999998,65.22760000000001,0.23308249282477278,False,False,True,,,,http://192.168.0.102:5082/Map/AltitudeGraph?id=1217,0,2022/4/25 2:20:13:]
|
||||
if (!string.IsNullOrEmpty(x))
|
||||
{
|
||||
i.RoomList = li;
|
||||
var index = x.IndexOf("l");
|
||||
var total = 0;
|
||||
if (index != -1)
|
||||
{
|
||||
var pageInfo = x.Substring(0, index);
|
||||
if (!string.IsNullOrEmpty(pageInfo))
|
||||
total = Convert.ToInt32(pageInfo);
|
||||
x = x.Substring(index);
|
||||
}
|
||||
var li = GameRoomModel.Parse(x);
|
||||
foreach (var i in list)
|
||||
{
|
||||
i.RoomList = li;
|
||||
i.GameRoomTotal = total;
|
||||
}
|
||||
}
|
||||
}
|
||||
//对战骑行场景中信息
|
||||
//附加信息
|
||||
if (t.IndexOf('e') == 0)
|
||||
{
|
||||
var g = t.Replace("e{", "").Replace("}", "");
|
||||
@@ -219,10 +232,11 @@ namespace Assets.Scenes.Ride.Scripts.Network
|
||||
if (string.IsNullOrEmpty(i))
|
||||
continue;
|
||||
var extendInfo = ExtendInfo.Parse(i);
|
||||
var owner = list.Where(c => c.MemberId == extendInfo.UserId).FirstOrDefault();
|
||||
var owner = list.Where(c => c.MemberId == extendInfo.UserId && c.TotoalTicks == extendInfo.TotalTicks).FirstOrDefault();
|
||||
if (owner != null)
|
||||
{
|
||||
owner.RoomId = extendInfo.RoomId;
|
||||
owner.FrameRate = extendInfo.FrameRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
protected override void CreateList()
|
||||
{
|
||||
var roomId = cyclingController.cyclingController == null ? 0 : (cyclingController.cyclingController.recorderData.RoomId ?? 0);
|
||||
var roomId = cyclingController.cyclingController == null ? 0 : cyclingController.cyclingController.recorderData.RoomId;
|
||||
OnlineUserNum.text = " "+ MapUDPService.GetNearRiderCount(roomId).ToString();
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(OnlineUserNum.rectTransform);
|
||||
var nearList = MapUDPService.GetNearRiderData(pageIndex, pageSize, new double[] { playerController.Currentlatlong.x, playerController.Currentlatlong.y },roomId);
|
||||
|
||||
@@ -68,10 +68,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
return;
|
||||
var totalDitance = manager.GetMapData().TotalDistance;
|
||||
var currentDistance = manager.CurrentPlayer.totalDistance;
|
||||
|
||||
//var currenList = FindObjectsOfType<ListItem>();//当前列表
|
||||
var currenList = GetComponentsInChildren<ListItem>(true);
|
||||
var list = MapUDPService.GetOnlineUsers(App.RouteIdParam);//最新列表
|
||||
var list = MapUDPService.GetOnlineUsers(App.RouteIdParam,manager.cyclingController.recorderData.RoomId);//最新列表
|
||||
var currentPlayerInfo = list.Where(c => c.Id.ToString() == manager.CurrentPlayer.UserId.ToString()).FirstOrDefault();
|
||||
list = list.Where(c => c.Id != App.CurrentUser.Id).ToList();
|
||||
if (currenList.Count() == 0 && list.Count() > 0)
|
||||
@@ -82,10 +80,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
_recyclableScrollRect.ReloadData();
|
||||
}
|
||||
}
|
||||
//var currenList = FindObjectsOfType<ListItem>();//当前列表
|
||||
//var list = MapUDPService.GetOnlineUsers(App.RouteIdParam);//最新列表
|
||||
|
||||
var currentPlayer = FindObjectOfType<VideoPlayer>();
|
||||
|
||||
|
||||
foreach (ListItem o in currenList)
|
||||
{
|
||||
|
||||
@@ -63,15 +63,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
private void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
#if UNITY_EDITOR
|
||||
App.RouteIdParam = 12353;
|
||||
//自动登录
|
||||
if (App.CurrentUser == null)
|
||||
{
|
||||
Login();
|
||||
UIManager.InitNow();//重置当前时间
|
||||
}
|
||||
#endif
|
||||
mediaPlayer = FindObjectOfType<MediaPlayer>();
|
||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||
var check = CheckAnt();//初始化蓝牙设备
|
||||
@@ -108,11 +99,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
};
|
||||
}
|
||||
endDistance = 0;
|
||||
////倒计时5s开始
|
||||
//SetCyclingModel(CyclingModel.Single);
|
||||
videoLoading = FindObjectOfType<VideoLoading>();
|
||||
|
||||
|
||||
}
|
||||
private IEnumerator Init()
|
||||
{
|
||||
@@ -483,7 +470,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
cyclingController.recorderData.ManufacturerName = ManufacturerName;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
cyclingController.recorderData.LastFrame = GetCurrentFrame();
|
||||
cyclingController.recorderData.RoomId = App.gameRoomDetail?.RoomId;//房间ID
|
||||
RankingId = cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using UnityEngine.EventSystems;
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Linq;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
|
||||
namespace Assets.Scripts.Scenes.VideoRide
|
||||
{
|
||||
@@ -222,7 +223,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
var ui = manager.GetCanvasTransform();
|
||||
canvasGroup.DOFade(0, 0).onComplete += () => {
|
||||
gameObject.SetActive(false);
|
||||
manager.SetCyclingModel(Assets.Scenes.Ride.Scripts.Model.CyclingModel.GameRoom);
|
||||
manager.SetCyclingModel(CyclingModel.GameRoom);
|
||||
manager.SetCurrentMode(VideoGameManager.ARMode.RIDE);
|
||||
ui.Find("Panel").gameObject.SetActive(true);
|
||||
};
|
||||
@@ -243,12 +244,12 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
, (p) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p)) {
|
||||
slider.value = 100;
|
||||
manager.SetMedia(p);
|
||||
Debug.LogError(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("");
|
||||
slider.value = 100;
|
||||
manager.SetMedia(p);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
public class PFUIPageButton : PFUIComponentBase
|
||||
{
|
||||
public Text pageIndexText;
|
||||
public GameObject clickImage;
|
||||
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
public void SetPageIndex(int pageIndex)
|
||||
{
|
||||
PageIndex = pageIndex;
|
||||
pageIndexText.text = $"{pageIndex + 1}";//pageIndex 从0开始
|
||||
}
|
||||
public void ShowLight()
|
||||
{
|
||||
clickImage.SetActive(true);
|
||||
}
|
||||
public void ShowShadow()
|
||||
{
|
||||
clickImage.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c114c143939361e41bd29f69f311e91c
|
||||
guid: c49931be379e5a448a6f107bb2bf94f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -8,36 +8,105 @@ namespace Assets.Scripts.UI.Control
|
||||
public class PFUIPageHelper : PFUIComponentBase
|
||||
{
|
||||
public Transform content;
|
||||
public GameObject preBtn;
|
||||
public GameObject nextBtn;
|
||||
public GameObject moreBtnPrefab;
|
||||
public GameObject preBtnPrefab;
|
||||
public GameObject nextBtnPrefab;
|
||||
public GameObject btnPrefab;
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; } = 6;
|
||||
public int Total { get; set; }
|
||||
|
||||
public int _pageMaxTotal = 9;
|
||||
|
||||
public int _pageSpace = 4;
|
||||
|
||||
private Action<int> CallBack { get; set; }
|
||||
|
||||
public void Register(Action<int> refresh)
|
||||
{
|
||||
CallBack = refresh;
|
||||
}
|
||||
public void Build()
|
||||
{
|
||||
Utils.DestroyChildren(content);
|
||||
|
||||
UIManager.AddEvent(preBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
RenderPreviousButton();
|
||||
|
||||
for (int i = 0; i < Total; i++)
|
||||
{
|
||||
Previous();
|
||||
if (PageIndex - 0 >= 4 && i < PageIndex)
|
||||
{
|
||||
if (i == 0 || PageIndex -1 == i || PageIndex -2 == i)
|
||||
{
|
||||
RenderPageButton(i);
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
RenderMoreButton();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Total -PageIndex-1 >= 4 && i >= PageIndex)
|
||||
{
|
||||
if (i == Total-1 || PageIndex == i || PageIndex + 1 == i || PageIndex + 2 == i)
|
||||
{
|
||||
RenderPageButton(i);
|
||||
}
|
||||
if (i == Total - 2)
|
||||
{
|
||||
RenderMoreButton();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
RenderPageButton(i);
|
||||
}
|
||||
RenderNextButton();
|
||||
}
|
||||
private void RenderMoreButton()
|
||||
{
|
||||
var moreBtn = Instantiate(moreBtnPrefab, content);
|
||||
moreBtn.SetActive(true);
|
||||
}
|
||||
private void RenderPageButton(int pageIndex)
|
||||
{
|
||||
var btn = Instantiate(btnPrefab, content);
|
||||
var script = btn.GetComponent<PFUIPageButton>();
|
||||
script.SetPageIndex(pageIndex);
|
||||
|
||||
if (pageIndex == PageIndex)
|
||||
{
|
||||
script.ShowLight();
|
||||
}
|
||||
else
|
||||
{
|
||||
script.ShowShadow();
|
||||
}
|
||||
|
||||
UIManager.AddEvent(btn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Redirect(pageIndex);
|
||||
});
|
||||
}
|
||||
private void RenderNextButton()
|
||||
{
|
||||
var nextBtn = Instantiate(nextBtnPrefab, content);
|
||||
nextBtn.SetActive(true);
|
||||
|
||||
UIManager.AddEvent(nextBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Next();
|
||||
});
|
||||
}
|
||||
public void Build()
|
||||
private void RenderPreviousButton()
|
||||
{
|
||||
Utils.DestroyChildren(content);
|
||||
for (int i = 1; i <= Total; i++)
|
||||
var preBtn = Instantiate(preBtnPrefab, content);
|
||||
preBtn.SetActive(true);
|
||||
|
||||
UIManager.AddEvent(preBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
var g = Instantiate(btnPrefab, content);
|
||||
g.transform.Find("Text").GetComponent<Text>().text = i.ToString();
|
||||
}
|
||||
Previous();
|
||||
});
|
||||
}
|
||||
//上一页
|
||||
private void Previous()
|
||||
@@ -48,6 +117,7 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
Build();
|
||||
}
|
||||
}
|
||||
//下一页
|
||||
@@ -59,13 +129,27 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
Build();
|
||||
}
|
||||
}
|
||||
//指定到第几页
|
||||
private void Redirect(int index)
|
||||
{
|
||||
var list = FindObjectsOfType<PFUIPageButton>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item.PageIndex == index)
|
||||
{
|
||||
item.ShowLight();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ShowShadow();
|
||||
}
|
||||
}
|
||||
PageIndex = index;
|
||||
CallBack?.Invoke(PageIndex);
|
||||
Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,63 +66,17 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
private GameRoomListController manager;
|
||||
private GameRoomModel gameRoom;
|
||||
|
||||
private bool Enable2d { get; set; }
|
||||
private bool Enable3d { get; set; }
|
||||
private bool EnableAR { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
manager = FindObjectOfType<GameRoomListController>();
|
||||
Scroll = GetComponentInParent<ScrollRect>();
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerEnter, (e) =>
|
||||
{
|
||||
LockL.SetActive(IsLock);
|
||||
Lock.SetActive(false);
|
||||
|
||||
D2.SetActive(false);
|
||||
D2L.SetActive(Enable2d);
|
||||
|
||||
D3.SetActive(false);
|
||||
D3L.SetActive(Enable3d);
|
||||
|
||||
AR.SetActive(false);
|
||||
ARL.SetActive(EnableAR);
|
||||
|
||||
|
||||
var list = GetComponentsInChildren<GameRoomHead>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.ShowLight();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
LockL.SetActive(false);
|
||||
Lock.SetActive(IsLock);
|
||||
|
||||
D2.SetActive(Enable2d);
|
||||
D2L.SetActive(false);
|
||||
|
||||
D3.SetActive(Enable3d);
|
||||
D3L.SetActive(false);
|
||||
|
||||
AR.SetActive(EnableAR);
|
||||
ARL.SetActive(false);
|
||||
|
||||
var list = GetComponentsInChildren<GameRoomHead>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.ShowShadow();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(JoinBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
manager.SelectRoom(gameRoom);
|
||||
if (IsLock)
|
||||
{
|
||||
manager.ShowPwdConfirm();
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerEnter,OnEnter);
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
UIManager.AddEvent(JoinBtn, EventTriggerType.PointerClick, JoinGameRoom);
|
||||
//对战正在进行
|
||||
UIManager.AddEvent(CycingBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
@@ -134,18 +88,59 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
manager.ShowDonePanel(gameRoom.RoomId);
|
||||
});
|
||||
}
|
||||
private float timer = 1f;
|
||||
private void Update()
|
||||
private void OnEnter(BaseEventData baseEventData)
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
LockL.SetActive(IsLock);
|
||||
Lock.SetActive(false);
|
||||
|
||||
D2.SetActive(false);
|
||||
D2L.SetActive(Enable2d);
|
||||
|
||||
D3.SetActive(false);
|
||||
D3L.SetActive(Enable3d);
|
||||
|
||||
AR.SetActive(false);
|
||||
ARL.SetActive(EnableAR);
|
||||
|
||||
|
||||
var list = GetComponentsInChildren<GameRoomHead>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
timer += 1f;
|
||||
item.ShowLight();
|
||||
}
|
||||
}
|
||||
private void OnExit(BaseEventData baseEventData)
|
||||
{
|
||||
LockL.SetActive(false);
|
||||
Lock.SetActive(IsLock);
|
||||
|
||||
D2.SetActive(Enable2d);
|
||||
D2L.SetActive(false);
|
||||
|
||||
D3.SetActive(Enable3d);
|
||||
D3L.SetActive(false);
|
||||
|
||||
AR.SetActive(EnableAR);
|
||||
ARL.SetActive(false);
|
||||
|
||||
var list = GetComponentsInChildren<GameRoomHead>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.ShowShadow();
|
||||
}
|
||||
}
|
||||
private void JoinGameRoom(BaseEventData baseEventData)
|
||||
{
|
||||
manager.SelectRoom(gameRoom);
|
||||
if (IsLock)
|
||||
{
|
||||
manager.ShowPwdConfirm();
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
}
|
||||
private bool Enable2d { get; set; }
|
||||
private bool Enable3d { get; set; }
|
||||
private bool EnableAR { get; set; }
|
||||
//This is called from the SetCell method in DataSource
|
||||
public void ConfigureCell(GameRoomModel cell, int cellIndex)
|
||||
{
|
||||
@@ -200,26 +195,18 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateItem(string name, string gender, string id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnBeginDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnEndDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnScroll(eventData);
|
||||
|
||||
@@ -43,14 +43,14 @@ class GameRoomDownLoad : MonoBehaviour
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
downLoadList.SetActive(true);
|
||||
var content = downLoadList.transform.Find("Scroll View/Viewport/Content");
|
||||
var content = downLoadList.transform.Find("Viewport/Content");
|
||||
var list = FindObjectsOfType<GameRoomDownloadTask>();
|
||||
//新增
|
||||
var obj = list.Where(c => c.RoomId == RoomId).FirstOrDefault();
|
||||
if (obj == null)
|
||||
{
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(RoomId, gameObject);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(RoomId, FileName);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,22 +96,47 @@ class GameRoomDownLoad : MonoBehaviour
|
||||
|
||||
step2.SetActive(true);
|
||||
|
||||
|
||||
//新增
|
||||
var content = downLoadList.transform.Find("Scroll View/Viewport/Content");
|
||||
var content = downLoadList.transform.Find("Viewport/Content");
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
var currentTask = newtask.GetComponent<GameRoomDownloadTask>();
|
||||
currentTask.Init(RoomId, gameObject);
|
||||
currentTask.Init(RoomId, fileName);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadVideo(fileName, url
|
||||
, (p, req) =>
|
||||
{
|
||||
downloadSlider.value = p;
|
||||
currentTask.UpdateProcess(p);
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
{
|
||||
Loom.DownLoadTaskList[FileName] = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
Loom.DownLoadTaskList.Add(FileName, p);
|
||||
}
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
currentTask.UpdateProcess(100f);
|
||||
downloadSlider.value = 100f;
|
||||
step3.SetActive(true);
|
||||
if (string.IsNullOrEmpty(p))
|
||||
{
|
||||
var process = 100f;
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
{
|
||||
Loom.DownLoadTaskList[FileName] = process;
|
||||
}
|
||||
else
|
||||
{
|
||||
Loom.DownLoadTaskList.Add(FileName, process);
|
||||
}
|
||||
currentTask.UpdateProcess(process);
|
||||
downloadSlider.value = process;
|
||||
step3.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, p);
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@@ -2,33 +2,48 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
class GameRoomDownloadTask : MonoBehaviour
|
||||
{
|
||||
public GameObject btn;
|
||||
public Slider slider;
|
||||
public GameObject icon;
|
||||
private GameObject modal;
|
||||
|
||||
public GameObject done;
|
||||
public GameObject doneTxt;
|
||||
public CanvasGroup canvasGroup;
|
||||
|
||||
private GameObject modal;
|
||||
private Text fileNameText;
|
||||
|
||||
public int RoomId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
modal.SetActive(true);
|
||||
transform.parent.parent.parent.parent.gameObject.SetActive(false);
|
||||
//TODO:
|
||||
transform.parent.parent.parent.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int roomId,GameObject parent)
|
||||
public void Init(int roomId,string fileName)
|
||||
{
|
||||
modal = FindObjectOfType<GameRoomDownLoad>().gameObject;
|
||||
fileNameText = transform.Find("Text").GetComponent<Text>();
|
||||
RoomId = roomId;
|
||||
modal = parent;
|
||||
fileNameText.text = fileName;
|
||||
FileName = fileName;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
||||
{
|
||||
UpdateProcess(Loom.DownLoadTaskList[FileName]);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateProcess(float process)
|
||||
@@ -39,7 +54,11 @@ class GameRoomDownloadTask : MonoBehaviour
|
||||
done.SetActive(true);
|
||||
doneTxt.SetActive(true);
|
||||
icon.SetActive(false);
|
||||
slider.gameObject.SetActive(false);
|
||||
canvasGroup.DOFade(0, 2).onComplete += () =>
|
||||
{
|
||||
slider.gameObject.SetActive(false);
|
||||
gameObject.Destroy();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomList : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
RectTransform _rectTransform;
|
||||
|
||||
[SerializeField]
|
||||
InputField _searchInputField;
|
||||
|
||||
[SerializeField]
|
||||
GameObject _searchBtn;
|
||||
|
||||
[SerializeField]
|
||||
private int _dataLength;
|
||||
private bool _isInit;
|
||||
|
||||
private GameObject RoomCell { get; set; }
|
||||
|
||||
//Dummy data List
|
||||
private List<GameRoomModel> _list = new List<GameRoomModel>();
|
||||
|
||||
private string seachName = "";
|
||||
PFUIPageHelper pageHelper;
|
||||
|
||||
//Recyclable scroll rect's data source must be assigned in Awake.
|
||||
private void Awake()
|
||||
{
|
||||
RoomCell = Resources.Load<GameObject>("UI/Prefab/GameRoom/Room");
|
||||
//分页
|
||||
pageHelper = FindObjectOfType<PFUIPageHelper>();
|
||||
pageHelper.PageIndex = 0;
|
||||
pageHelper.PageSize = 6;
|
||||
pageHelper.Register((e) =>
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
});
|
||||
|
||||
_ = GetDataAsync();
|
||||
_searchInputField.onValueChanged.AddListener((e) => { seachName = e; });
|
||||
_searchInputField.onEndEdit.AddListener((e) => {
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(_searchBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Refreash);
|
||||
}
|
||||
private void Refreash(BaseEventData data)
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
}
|
||||
private async Task GetDataAsync()
|
||||
{
|
||||
if (_list != null) _list.Clear();
|
||||
var result = await ConfigHelper.GameRoomApi.GetList(pageHelper.PageIndex, pageHelper.PageSize, seachName);
|
||||
if (result.result)
|
||||
{
|
||||
Utils.DestroyChildren(_rectTransform);
|
||||
_list = result.data.List;
|
||||
int index = 0;
|
||||
foreach (var item in _list)
|
||||
{
|
||||
index++;
|
||||
var g = Instantiate(RoomCell, _rectTransform);
|
||||
g.GetComponent<GameRoomCell>().ConfigureCell(item, index);
|
||||
}
|
||||
pageHelper.Total = result.data.Total;
|
||||
pageHelper.Build();
|
||||
}
|
||||
}
|
||||
float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,6 @@ class GameRoomLoadingItem : MonoBehaviour
|
||||
loadingIcon.SetActive(process < 100);
|
||||
doneIcon.SetActive(process >= 100);
|
||||
|
||||
nameMyself.text = Name;
|
||||
nameDone.text = Name;
|
||||
nameLoading.text = Name;
|
||||
|
||||
if (UserId == App.CurrentUser.Id)
|
||||
{
|
||||
nameMyself.gameObject.SetActive(true);
|
||||
@@ -48,12 +44,20 @@ class GameRoomLoadingItem : MonoBehaviour
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
public void Init(int userId,string name,int roomId,double process)
|
||||
public void Init(int userId,string name,string head,string country,int roomId,double process)
|
||||
{
|
||||
UserId = userId;
|
||||
Name = name;
|
||||
RoomId = roomId;
|
||||
Process = process;
|
||||
|
||||
nameMyself.text = Name;
|
||||
nameDone.text = Name;
|
||||
nameLoading.text = Name;
|
||||
|
||||
countryImage.texture = UIManager.Instance.loginRegOptions.GetCountryImage(country);
|
||||
Utils.DisplayHead(headImage, head);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,16 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
slider.value = 100f;
|
||||
ShowOutLine();
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(false);
|
||||
if (string.IsNullOrEmpty(p))
|
||||
{
|
||||
slider.value = 100f;
|
||||
ShowOutLine();
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, p);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public class GameRoomDetailController : PFUIPanel
|
||||
d3.SetActive(enable3d);
|
||||
ar.SetActive(GameRoom.EnableAR);
|
||||
|
||||
DataSourceChanged = true;
|
||||
//DataSourceChanged = true;
|
||||
MapUDPService.SendQueryGameRoomList(App.CurrentUser.Id, 0, 1, GameRoom.RoomId.ToString());
|
||||
readyBtn.SetActive(true);
|
||||
cancelBtn.SetActive(false);
|
||||
|
||||
@@ -90,6 +90,12 @@ public class GameRoomListController : PFUIPanel
|
||||
[SerializeField]
|
||||
GameObject _searchBtn;
|
||||
|
||||
[SerializeField]
|
||||
GameObject _noDataFound;
|
||||
|
||||
[SerializeField]
|
||||
GameObject _downLoadTask;
|
||||
|
||||
private GameObject RoomCell { get; set; }
|
||||
|
||||
//Dummy data List
|
||||
@@ -104,7 +110,6 @@ public class GameRoomListController : PFUIPanel
|
||||
{
|
||||
base.Awake();
|
||||
RoomRankItem = Resources.Load<GameObject>("UI/Prefab/GameRoom/RoomRankItem");
|
||||
|
||||
RoomCell = Resources.Load<GameObject>("UI/Prefab/GameRoom/Room");
|
||||
//分页
|
||||
pageHelper = FindObjectOfType<PFUIPageHelper>();
|
||||
@@ -112,26 +117,35 @@ public class GameRoomListController : PFUIPanel
|
||||
pageHelper.PageSize = 6;
|
||||
pageHelper.Register((e) =>
|
||||
{
|
||||
|
||||
Query();
|
||||
});
|
||||
|
||||
|
||||
_searchInputField.onValueChanged.AddListener((e) => { seachName = e; });
|
||||
_searchInputField.onEndEdit.AddListener((e) => {
|
||||
seachName = e;
|
||||
MapUDPService.SendQueryGameRoomList(App.CurrentUser.Id, pageHelper.PageIndex, pageHelper.PageSize, seachName);
|
||||
Query();
|
||||
});
|
||||
UIManager.AddEvent(_searchBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Search);
|
||||
UIManager.AddEvent(_searchBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, SearchBtn_Click);
|
||||
}
|
||||
private void Search(BaseEventData data)
|
||||
private void SearchBtn_Click(BaseEventData data)
|
||||
{
|
||||
pageHelper.PageIndex = 0;
|
||||
Query();
|
||||
}
|
||||
private void Query()
|
||||
{
|
||||
MapUDPService.SendQueryGameRoomList(App.CurrentUser.Id, pageHelper.PageIndex, pageHelper.PageSize, seachName);
|
||||
}
|
||||
private void Refreash()
|
||||
{
|
||||
Utils.DestroyChildren(_rectTransform);
|
||||
pageHelper.Total = Total;
|
||||
pageHelper.Build();
|
||||
if (list == null)
|
||||
{
|
||||
_noDataFound.SetActive(true);
|
||||
return;
|
||||
}
|
||||
_noDataFound.SetActive(false);
|
||||
int index = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
@@ -139,23 +153,33 @@ public class GameRoomListController : PFUIPanel
|
||||
var g = Instantiate(RoomCell, _rectTransform);
|
||||
g.GetComponent<GameRoomCell>().ConfigureCell(item, index);
|
||||
}
|
||||
pageHelper.Total = 10;
|
||||
pageHelper.Build();
|
||||
|
||||
}
|
||||
List<GameRoomModel> list;
|
||||
private int Total { get; set; }
|
||||
private bool CreateClicked { get; set; }
|
||||
private void ListenerHandler(List<ReceiveMsgModel> message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (message.Count > 1)
|
||||
return;
|
||||
//查询列表
|
||||
var roomList = message.Where(c => c.RoomList != null).FirstOrDefault();
|
||||
if (roomList != null)
|
||||
{
|
||||
list = roomList.RoomList;
|
||||
Total = roomList.GameRoomTotal;
|
||||
ListChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = null;
|
||||
Total = 0;
|
||||
ListChanged = true;
|
||||
}
|
||||
//查询自己当前创建的房间信息并进入
|
||||
var info = message.Where(c => c.RoomList.Where(o => o.UserId == App.CurrentUser.Id).Any()).FirstOrDefault();
|
||||
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)
|
||||
{
|
||||
GameRoom = info.RoomList[0];
|
||||
@@ -186,33 +210,69 @@ public class GameRoomListController : PFUIPanel
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
|
||||
//LOOM中取数据渲染下载当前下载进度
|
||||
var downLoadList = transform.Find("DownLoadList").gameObject;
|
||||
var downloadPanel = transform.Find("DownloadPanel").gameObject;
|
||||
if (!downLoadList.activeSelf && !downloadPanel.activeSelf)
|
||||
{
|
||||
foreach (var item in Loom.DownLoadTaskList)
|
||||
{
|
||||
var content = downLoadList.transform.Find("Viewport/Content");
|
||||
var newtask = Instantiate(_downLoadTask, content);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(0, item.Key);
|
||||
}
|
||||
}
|
||||
App.Model = "GameRoom";
|
||||
MapUDPService.MessageListener = ListenerHandler;
|
||||
MapUDPService.SendQueryGameRoomList(App.CurrentUser.Id, pageHelper.PageIndex, pageHelper.PageSize, seachName);
|
||||
}
|
||||
float timer = 1f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
//房间已经进行骑行时间
|
||||
if (cycingRoomModal.gameObject.activeSelf)
|
||||
{
|
||||
var s = UIManager.Now.GetDateTime() - modelGameRoom.StartTime.Value.ToLocalTime();
|
||||
CyclingTimer.text = Helper.FormatTicks((int)s.TotalSeconds);
|
||||
}
|
||||
while (timer < 0)
|
||||
#region 搜索面板的滚轮监听
|
||||
if (scroll != null)
|
||||
{
|
||||
if (ListChanged)
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
Refreash();
|
||||
ListChanged = false;
|
||||
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
if (CreateRoomSuccessed & CreateClicked)
|
||||
else
|
||||
{
|
||||
CreateRoomSuccessed = false;
|
||||
CreateClicked = false;
|
||||
UIManager.ShowGameRoomDetailPanel();
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
timer += 1f;
|
||||
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
onEndEdit();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (ListChanged)
|
||||
{
|
||||
Refreash();
|
||||
ListChanged = false;
|
||||
}
|
||||
//对战房间创建事件监听
|
||||
if (CreateRoomSuccessed & CreateClicked)
|
||||
{
|
||||
CreateRoomSuccessed = false;
|
||||
CreateClicked = false;
|
||||
UIManager.ShowGameRoomDetailPanel();
|
||||
}
|
||||
}
|
||||
private void InitStep1()
|
||||
@@ -416,11 +476,6 @@ public class GameRoomListController : PFUIPanel
|
||||
CreateClicked = true;
|
||||
});
|
||||
}
|
||||
private bool CreateClicked { get; set; }
|
||||
private void ResetMapList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void InitStep2()
|
||||
{
|
||||
@@ -603,20 +658,23 @@ public class GameRoomListController : PFUIPanel
|
||||
var download = transform.Find("DownloadPanel").gameObject;
|
||||
if (GameRoom.EnableAR && !File.Exists(filepath))
|
||||
{
|
||||
//查询fileUrl
|
||||
GameRoom.FileUrl = ConfigHelper.GameRoomApi.GetMapVideoURL(GameRoom.MapRouteId).data;
|
||||
download.SetActive(true);
|
||||
download.GetComponent<GameRoomDownLoad>().Init(RoomId, GameRoom.FileName, GameRoom.FileUrl, this);
|
||||
}
|
||||
GetInRoom();
|
||||
else
|
||||
{
|
||||
GetInRoom();
|
||||
}
|
||||
}
|
||||
|
||||
private GameRoomModel modelGameRoom { get; set; }
|
||||
//private GameRoomModel modelGameRoom { get; set; }
|
||||
private Text CyclingTimer { get; set; }
|
||||
public void ShowCycingPanel(GameRoomModel gameRoomModel)
|
||||
{
|
||||
ShowStatusModal(cycingRoomModal, gameRoomModel);
|
||||
//倒计时
|
||||
modelGameRoom = gameRoomModel;
|
||||
modelGameRoom = gameRoomModel; //倒计时
|
||||
CyclingTimer = cycingRoomModal.Find("Modal/Timer").GetComponent<Text>();
|
||||
}
|
||||
public void ShowDonePanel(int roomId)
|
||||
@@ -651,21 +709,20 @@ public class GameRoomListController : PFUIPanel
|
||||
var bestHead = tr.Find("Modal/BestTab/Head").GetComponent<RawImage>();
|
||||
var bestName = tr.Find("Modal/BestTab/NickName").GetComponent<Text>();
|
||||
var bestTimer = tr.Find("Modal/BestTab/Timer").GetComponent<Text>();
|
||||
|
||||
bestName.text = data.BestNickName;
|
||||
bestTimer.text = data.BestTotalTime;
|
||||
|
||||
//查询某线路最佳
|
||||
var result = ConfigHelper.mapApi.GetMapBestInfo(data.MapRouteId);
|
||||
if (result.result && !string.IsNullOrEmpty(result.data.BestNickName))
|
||||
{
|
||||
bestName.text = result.data.BestNickName;
|
||||
bestTimer.text = result.data.BestTotalTime;
|
||||
Utils.DisplayImage(bestHead, result.data.BestWxHeadImg);
|
||||
}
|
||||
Utils.DisplayImage(graph, data.AltitudeGraph);
|
||||
Utils.DisplayImage(bestHead, data.BestWxHeadImg);
|
||||
tr.Find("Modal/Props/DistanceText").GetComponent<Text>().text = data.Distance.ToString("f1") + "KM";
|
||||
tr.Find("Modal/Props/EleText").GetComponent<Text>().text = data.TotalClimb.ToString("f0") + "M";
|
||||
tr.Find("Modal/Props/SlopeText").GetComponent<Text>().text = data.AverageGrade.ToString("f1") + "%";
|
||||
tr.Find("Modal/StartTime").GetComponent<Text>().text = data.StartTime.Value.ToLocalTime().ToString();
|
||||
//var timegap = data.StartTime.Value.ToLocalTime() - UIManager.Now.GetDateTime();
|
||||
//if (timegap.Ticks > 0)
|
||||
//{
|
||||
// tr.Find("Modal/StartTime").GetComponent<Text>().text = Helper.FormatTicks((int)timegap.Ticks);
|
||||
//}
|
||||
|
||||
var close = tr.Find("Modal/Close").gameObject;
|
||||
var quit = tr.Find("Modal/Quit").gameObject;
|
||||
UIManager.AddEvent(close, EventTriggerType.PointerClick, (e) => { tr.gameObject.SetActive(false); });
|
||||
|
||||
@@ -47,7 +47,6 @@ public class GameRoomLoadingController : PFUIPanel
|
||||
videoLoading = FindObjectOfType<VideoLoading>();
|
||||
playerLoading = FindObjectOfType<LoadingController>();
|
||||
videoManager = FindObjectOfType<VideoGameManager>();
|
||||
videoManager?.SetCyclingModel(Assets.Scenes.Ride.Scripts.Model.CyclingModel.GameRoom);
|
||||
}
|
||||
private bool DataSourceChanged { get; set; }
|
||||
private void ListenerHandler(List<ReceiveMsgModel> message)
|
||||
@@ -103,7 +102,7 @@ public class GameRoomLoadingController : PFUIPanel
|
||||
{
|
||||
var detail = Instantiate(prefab, content);
|
||||
roomDetail = detail.GetComponent<GameRoomLoadingItem>();
|
||||
roomDetail.Init(item.UserId, item.WxHeadImage, item.RoomId, item.Process);
|
||||
roomDetail.Init(item.UserId, item.Name, item.WxHeadImage,item.Country,item.RoomId, item.Process);
|
||||
}
|
||||
}
|
||||
//判断是否进入骑行场景
|
||||
|
||||
@@ -40,7 +40,7 @@ public class HomeController : PFUIPanel
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
var BtnContainer = transform.Find("MainFuncContainer");
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
|
||||
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 });
|
||||
@@ -61,12 +61,12 @@ public class HomeController : PFUIPanel
|
||||
{
|
||||
UIManager.ShowChangePlayerPanel();
|
||||
});
|
||||
BtnBattle = transform.Find("MainFuncContainer/BtnBattle");
|
||||
BtnBattle = BtnContainer.Find("BtnBattle");
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerClick, GoGameRoom);
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
#endif
|
||||
var BtnContainer = transform.Find("MainFuncContainer");
|
||||
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerClick, GoRide);
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
@@ -130,7 +130,12 @@ public class HomeController : PFUIPanel
|
||||
}
|
||||
private void GoGameRoom(BaseEventData e)
|
||||
{
|
||||
#if UNITY_STANDALONE_WIN
|
||||
var pe = (PointerEventData)e;
|
||||
var parent = pe.pointerEnter.transform.parent;
|
||||
UIManager.ShowGameRoomListPanel();
|
||||
OnExit(e);
|
||||
#endif
|
||||
}
|
||||
private void GoRide(BaseEventData e)
|
||||
{
|
||||
@@ -207,6 +212,10 @@ public class HomeController : PFUIPanel
|
||||
//parent.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
parent.DOScale(new Vector3(1.05f, 1.05f, 0), 0.3f);
|
||||
//parent.GetComponent<RectTransform>().localScale = ;
|
||||
|
||||
#if UNITY_STANDALONE_WIN
|
||||
parent.Find("ImageL").gameObject.SetActive(true);
|
||||
#endif
|
||||
}
|
||||
private void OnExit(BaseEventData e)
|
||||
{
|
||||
@@ -220,6 +229,9 @@ public class HomeController : PFUIPanel
|
||||
}
|
||||
parent.DOScale(new Vector3(1f, 1f, 0), 0.3f);
|
||||
//parent.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 0);
|
||||
#if UNITY_STANDALONE_WIN
|
||||
parent.Find("ImageL").gameObject.SetActive(false);
|
||||
#endif
|
||||
}
|
||||
void MoreFunc()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,8 @@ 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
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Networking;
|
||||
@@ -465,19 +466,14 @@ namespace Assets.Scripts
|
||||
//下载video
|
||||
public static IEnumerator DownloadVideo(string fileName,string url, UnityAction<float, UnityWebRequest> onProcessing = null, UnityAction<string> onCompleted = null)
|
||||
{
|
||||
string local = "";
|
||||
string error = "";
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + $"/{fileName}";
|
||||
//根据id读取本地文件
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
var filepath= path+$"/{fileName}";
|
||||
if (File.Exists(filepath))
|
||||
{
|
||||
local = filepath;
|
||||
|
||||
}
|
||||
//本地文件读取不到读取网络文件
|
||||
else
|
||||
{
|
||||
@@ -493,21 +489,24 @@ namespace Assets.Scripts
|
||||
}
|
||||
if (request.isNetworkError || request.isHttpError)
|
||||
{
|
||||
error = request.error;
|
||||
Debug.Log(request.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fs = File.Create(filepath);
|
||||
fs.Write(request.downloadHandler.data, 0, request.downloadHandler.data.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
fs = null;
|
||||
local = filepath;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var fs = File.Create(filepath);
|
||||
fs.Write(request.downloadHandler.data, 0, request.downloadHandler.data.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
fs = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (onCompleted != null)
|
||||
{
|
||||
onCompleted.Invoke(local);
|
||||
onCompleted.Invoke(error);
|
||||
}
|
||||
}
|
||||
static IEnumerator DownloadImage(MaskableGraphic img,string MediaUrl, Action<Texture> action = null,UnityAction<byte[]> callback = null)
|
||||
|
||||
Reference in new issue
Block a user