131 lines
3.7 KiB
C#
131 lines
3.7 KiB
C#
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; }
|
|
|
|
public bool NotUse { get; private set; }
|
|
|
|
public bool IsOwner { get; private set; }
|
|
|
|
private void Start()
|
|
{
|
|
var manager = FindObjectOfType<GameRoomDetailController>();
|
|
var inviteBtn = inviteModal.transform.Find("InviteBtn").gameObject;
|
|
UIManager.AddEvent(inviteBtn,EventTriggerType.PointerClick,(e)=> {
|
|
var encryptCode = EncrypHelper.Encrypt($"GameRoom/{App.CurrentUser.Nickname}/{manager.GameRoom.Name}/{manager.GameRoom.RoomId}");
|
|
Utils.CopyToClipboard(encryptCode);
|
|
Utils.showToast(transform.parent.gameObject, App.GetLocalString("copy to clipboard successfully!"));
|
|
});
|
|
|
|
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, (e) =>
|
|
{
|
|
if (App.gameRoomDetail.UserId != App.CurrentUser.Id)
|
|
return;
|
|
kickModal.SetActive(true);
|
|
});
|
|
UIManager.AddEvent(cancelBtn, EventTriggerType.PointerClick, (e) =>
|
|
{
|
|
if (App.gameRoomDetail.UserId != App.CurrentUser.Id)
|
|
return;
|
|
kickModal.SetActive(false);
|
|
});
|
|
UIManager.AddEvent(kickBtn, EventTriggerType.PointerClick, (e) =>
|
|
{
|
|
if (App.gameRoomDetail.UserId != App.CurrentUser.Id)
|
|
return;
|
|
MapUDPService.SendGameRoomKick(App.gameRoomDetail.RoomId, UserId, App.CurrentUser.Id);
|
|
});
|
|
}
|
|
|
|
public void Init(int userId, string userName,string headUrl,double weight, float ftp,bool isOwner,int Status,int sex)
|
|
{
|
|
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);
|
|
IsOwner = isOwner;
|
|
ready.SetActive(!isOwner && Status == 1);
|
|
}
|
|
|
|
public void UpdatePlayer(int userId, string userName, string headUrl, double weight, float ftp, bool isOwner, int Status,int sex)
|
|
{
|
|
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);
|
|
IsOwner = isOwner;
|
|
ready.SetActive(!isOwner && Status == 1);
|
|
}
|
|
|
|
public void Ready()
|
|
{
|
|
ready.SetActive(true);
|
|
}
|
|
public void UnReady()
|
|
{
|
|
ready.SetActive(false);
|
|
}
|
|
public void ShowQuitModal()
|
|
{
|
|
kickModal.SetActive(true);
|
|
}
|
|
public void ShowInviteModal()
|
|
{
|
|
NotUse = false;
|
|
UserId = 0;
|
|
notInUseModal.SetActive(false);
|
|
inviteModal.SetActive(true);
|
|
}
|
|
public void NotInUse()
|
|
{
|
|
NotUse = true;
|
|
UserId = 0;
|
|
notInUseModal.SetActive(true);
|
|
}
|
|
|
|
public void Me()
|
|
{
|
|
me.SetActive(true);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
ShowInviteModal();
|
|
}
|
|
}
|
|
|