对战AR
This commit is contained in:
1 parent
509c309252
commit
11b131b24a
60 files changed
+2505
-632
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c114c143939361e41bd29f69f311e91c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user