加入房间,踢人,准备等tcp命令
This commit is contained in:
1 parent
de8dd933e8
commit
06582201fa
101 files changed
+246552
-565
No files matched your search
@@ -49,18 +49,44 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
public GameObject IconOwnerLight;
|
||||
|
||||
public GameObject JoinBtn;
|
||||
public GameObject Lock;
|
||||
public GameObject LockL;
|
||||
private ScrollRect Scroll;
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Rank { get; set; }
|
||||
public string Name { get; set; }
|
||||
private bool IsLock;
|
||||
|
||||
private int Id;
|
||||
|
||||
private string FileName;
|
||||
|
||||
private GameRoomListController manager;
|
||||
private GameRoomModel gameRoom;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
manager = FindObjectOfType<GameRoomListController>();
|
||||
Scroll = GetComponentInParent<ScrollRect>();
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerEnter, (e) =>
|
||||
{
|
||||
LockL.SetActive(IsLock);
|
||||
Lock.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
LockL.SetActive(false);
|
||||
Lock.SetActive(IsLock);
|
||||
});
|
||||
UIManager.AddEvent(JoinBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
|
||||
manager.SelectRoom(gameRoom);
|
||||
if (IsLock)
|
||||
{
|
||||
manager.ShowPwdConfirm();
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
});
|
||||
}
|
||||
private float timer = 1f;
|
||||
@@ -76,8 +102,9 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
//This is called from the SetCell method in DataSource
|
||||
public void ConfigureCell(GameRoomModel cell, int cellIndex)
|
||||
{
|
||||
gameRoom = cell;
|
||||
RoomNameTxt.text = cell.Name;
|
||||
|
||||
FileName = cell.FileName;
|
||||
var gradeText = $"{Math.Round(cell.AverageGrade,2)}%";
|
||||
GradeLightTxt.text = gradeText;
|
||||
GradeTxt.text = gradeText;
|
||||
@@ -94,6 +121,11 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
RouteNameLightTxt.text = cell.MapRouteName;
|
||||
IdTxt.text = cell.Id.ToString().PadLeft(7,'0');
|
||||
|
||||
IsLock = cell.IsLock;
|
||||
Id = cell.Id;
|
||||
|
||||
Lock.SetActive(IsLock);
|
||||
LockL.SetActive(false);
|
||||
Utils.DisplayImage(AltitudeGraphImg, cell.AltitudeGraph);
|
||||
Utils.DisplayImage(Owner, cell.WxHeadImg);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomDownLoad : MonoBehaviour
|
||||
{
|
||||
public GameObject step1;
|
||||
public GameObject step2;
|
||||
public GameObject step3;
|
||||
|
||||
public GameObject downloadBtn;
|
||||
public GameObject backBtn;
|
||||
|
||||
public Slider downloadSlider;
|
||||
public GameObject runInbackBtn;
|
||||
|
||||
public GameObject enterBtn;
|
||||
public GameObject cancelBtn;
|
||||
|
||||
public GameObject downLoadList;
|
||||
public GameObject downLoadTask;
|
||||
|
||||
private GameRoomListController manager;
|
||||
private int RoomId { get; set; }
|
||||
private string FileName { get; set; }
|
||||
private string FileUrl { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, DownloadClick);
|
||||
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick);
|
||||
|
||||
UIManager.AddEvent(runInbackBtn, EventTriggerType.PointerClick, (d) =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
downLoadList.SetActive(true);
|
||||
var content = downLoadList.transform.Find("Scroll View/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);
|
||||
}
|
||||
});
|
||||
|
||||
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, (ee) =>
|
||||
{
|
||||
manager.GetInRoom();
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(cancelBtn, EventTriggerType.PointerClick, (ee) =>
|
||||
{
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int Id,string fileName,string url, GameRoomListController gameRoomListController)
|
||||
{
|
||||
RoomId = Id;
|
||||
FileName = fileName;
|
||||
FileUrl = url;
|
||||
manager = gameRoomListController;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
step2.SetActive(false);
|
||||
step3.SetActive(false);
|
||||
downloadSlider.value = 0f;
|
||||
}
|
||||
private void CancelClick(BaseEventData data)
|
||||
{
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void DownloadClick(BaseEventData baseEventData)
|
||||
{
|
||||
var fileName = FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
var url = FileUrl;
|
||||
|
||||
step2.SetActive(true);
|
||||
|
||||
//新增
|
||||
var content = downLoadList.transform.Find("Scroll View/Viewport/Content");
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
var currentTask = newtask.GetComponent<GameRoomDownloadTask>();
|
||||
currentTask.Init(RoomId, gameObject);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadVideo(fileName, url
|
||||
, (p, req) =>
|
||||
{
|
||||
downloadSlider.value = p;
|
||||
currentTask.UpdateProcess(p);
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
currentTask.UpdateProcess(100f);
|
||||
downloadSlider.value = 100f;
|
||||
step3.SetActive(true);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 339fd75283bc4ae4caf3d8a4b00b6cad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomDownloadTask : MonoBehaviour
|
||||
{
|
||||
public GameObject btn;
|
||||
public Slider slider;
|
||||
public GameObject icon;
|
||||
private GameObject modal;
|
||||
|
||||
public GameObject done;
|
||||
public GameObject doneTxt;
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
modal.SetActive(true);
|
||||
transform.parent.parent.parent.parent.gameObject.SetActive(false);
|
||||
//TODO:
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int roomId,GameObject parent)
|
||||
{
|
||||
RoomId = roomId;
|
||||
modal = parent;
|
||||
}
|
||||
|
||||
public void UpdateProcess(float process)
|
||||
{
|
||||
slider.value = process;
|
||||
if (process >= 100)
|
||||
{
|
||||
done.SetActive(true);
|
||||
doneTxt.SetActive(true);
|
||||
icon.SetActive(false);
|
||||
slider.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e49b4427b935aa42b1c477c08b61661
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,6 +5,7 @@ using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -60,6 +61,32 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
transform.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
transform.GetComponent<Button>().onClick.AddListener(Ride);
|
||||
}
|
||||
var downloadBtn = transform.Find("DownLoadModal/DownLoad").gameObject;
|
||||
var downloading = transform.Find("DownLoadModal/Downloading").gameObject;
|
||||
var downloadTxt = transform.Find("DownLoadModal/Text").gameObject;
|
||||
var slider = transform.Find("DownLoadModal/Slider").GetComponent<Slider>();
|
||||
|
||||
var fileName = map.FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(map.EnableAR && !File.Exists(filepath));
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
downloadBtn.SetActive(false);
|
||||
downloading.SetActive(true);
|
||||
downloadTxt.SetActive(false);
|
||||
slider.gameObject.SetActive(true);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadVideo(map.FileName, map.Url, (p, req) =>
|
||||
{
|
||||
slider.value = p;
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
slider.value = 100f;
|
||||
ShowOutLine();
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(false);
|
||||
}));
|
||||
});
|
||||
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
|
||||
@@ -104,13 +131,19 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
|
||||
private void Ride()
|
||||
{
|
||||
var list = FindObjectsOfType<GameRoomMapItem>();
|
||||
foreach (var item in list)
|
||||
var fileName = map.FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
if ((map.EnableAR && !File.Exists(filepath) )|| !map.EnableAR)
|
||||
{
|
||||
item.HiddenOutLine();
|
||||
var list = FindObjectsOfType<GameRoomMapItem>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.HiddenOutLine();
|
||||
}
|
||||
ShowOutLine();
|
||||
listController.Select(map);
|
||||
}
|
||||
ShowOutLine();
|
||||
listController.Select(map);
|
||||
}
|
||||
|
||||
public void ShowOutLine()
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomPassword : MonoBehaviour
|
||||
{
|
||||
public GameObject enterBtn;
|
||||
public GameObject backBtn;
|
||||
public InputField passwordInput;
|
||||
|
||||
public GameRoomListController manager;
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
passwordInput.onValueChanged.AddListener((e) =>
|
||||
{
|
||||
Password = e;
|
||||
});
|
||||
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, ConfirmClick); //确定
|
||||
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick); //取消
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
passwordInput.text = "";
|
||||
}
|
||||
|
||||
private async void ConfirmClick(BaseEventData baseEventData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Password))
|
||||
{
|
||||
Utils.showToast(gameObject, App.GetLocalString("room password can not be empty"));
|
||||
return;
|
||||
}
|
||||
var RoomId = manager.GetRoomId();
|
||||
var result = await ConfigHelper.GameRoomApi.ConfirmRoomPwd(RoomId, Password);
|
||||
if (!result.result)
|
||||
{
|
||||
Utils.showToast(gameObject, result.errMsg);
|
||||
return;
|
||||
}
|
||||
Refresh();
|
||||
gameObject.SetActive(false);
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
private void CancelClick(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea7f659ae39c16b46b8449abf56f3fea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomPlayerPanel : MonoBehaviour
|
||||
{
|
||||
public Text userNametxt;
|
||||
public Text weigthTxt;
|
||||
public Text ftpTxt;
|
||||
public RawImage head;
|
||||
|
||||
|
||||
public GameObject owner;
|
||||
public GameObject playerModal;
|
||||
public GameObject notInUseModal;
|
||||
public GameObject inviteModal;
|
||||
public GameObject kickModal;
|
||||
public GameObject me;
|
||||
public GameObject ready;
|
||||
|
||||
public GameObject kickBtn;
|
||||
public GameObject cancelBtn;
|
||||
|
||||
public int sort;
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var manager = FindObjectOfType<GameRoomDetailController>();
|
||||
var inviteBtn = inviteModal.transform.Find("InviteBtn").gameObject;
|
||||
UIManager.AddEvent(inviteBtn,EventTriggerType.PointerClick,(e)=> {
|
||||
Utils.CopyToClipboard($"GameRoom/{manager.GameRoom.Id}");
|
||||
Utils.showToast(transform.parent.gameObject, App.GetLocalString("copy to clipboard successfully!"));
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
kickModal.SetActive(true);
|
||||
});
|
||||
UIManager.AddEvent(cancelBtn, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
kickModal.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(kickBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
MapUDPService.SendGameRoomKick(App.gameRoomDetail.Id, UserId, App.CurrentUser.Id);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int userId, string userName,string headUrl,double weight, float ftp,bool isOwner,int Status)
|
||||
{
|
||||
UserId = userId;
|
||||
inviteModal.SetActive(false);
|
||||
notInUseModal.SetActive(false);
|
||||
Utils.DisplayHead(head, headUrl);
|
||||
|
||||
userNametxt.text = userName;
|
||||
weigthTxt.text = weight.ToString();
|
||||
ftpTxt.text = ftp.ToString();
|
||||
me.SetActive(App.CurrentUser.Id == userId);
|
||||
owner.SetActive(isOwner);
|
||||
//Show ready
|
||||
ready.SetActive(!isOwner && Status == 1);
|
||||
}
|
||||
|
||||
public void UpdatePlayer(int userId, string userName, string headUrl, double weight, float ftp, bool isOwner, int Status)
|
||||
{
|
||||
UserId = userId;
|
||||
inviteModal.SetActive(false);
|
||||
notInUseModal.SetActive(false);
|
||||
userNametxt.text = userName;
|
||||
weigthTxt.text = weight.ToString();
|
||||
ftpTxt.text = ftp.ToString();
|
||||
me.SetActive(App.CurrentUser.Id == userId);
|
||||
owner.SetActive(isOwner);
|
||||
ready.SetActive(!isOwner && Status == 1);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Ready()
|
||||
{
|
||||
ready.SetActive(true);
|
||||
}
|
||||
public void UnReady()
|
||||
{
|
||||
ready.SetActive(false);
|
||||
}
|
||||
public void ForceQuit()
|
||||
{
|
||||
//TODO:踢人
|
||||
NotInUse();
|
||||
}
|
||||
public void ShowQuitModal()
|
||||
{
|
||||
kickModal.SetActive(true);
|
||||
}
|
||||
public void ShowInviteModal()
|
||||
{
|
||||
UserId = 0;
|
||||
inviteModal.SetActive(true);
|
||||
}
|
||||
public void NotInUse()
|
||||
{
|
||||
UserId = 0;
|
||||
notInUseModal.SetActive(true);
|
||||
}
|
||||
|
||||
public void Me()
|
||||
{
|
||||
me.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fabe7328397c8f468d2fb938ca70f48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user