对战AR
This commit is contained in:
1 parent
509c309252
commit
11b131b24a
60 files changed
+2505
-632
No files matched your search
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user