You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Net;
|
|
using TMPro;
|
|
using Unity.Services.Authentication;
|
|
using Unity.Services.Lobbies.Models;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace LobbyScripts
|
|
{
|
|
public class LobbyPlayerData : MonoBehaviour
|
|
{
|
|
[SerializeField] private TextMeshProUGUI _playerName;
|
|
[SerializeField] private Button _kick;
|
|
|
|
public string PlayerName { private set; get; }
|
|
public string PlayerID { private set; get; }
|
|
|
|
private Player _playerData;
|
|
|
|
public void Start()
|
|
{
|
|
_kick.onClick.AddListener(() =>
|
|
{
|
|
GameLobby.GameLobbyInstance.KickAPlayer(_playerData);
|
|
});
|
|
}
|
|
|
|
public void SetPlayerData(Player playerData, Lobby lobby, bool isHost)
|
|
{
|
|
_playerData = playerData;
|
|
PlayerID = playerData.Id;
|
|
PlayerName = playerData.Data["PlayerName"].Value;
|
|
_playerName.SetText($"{PlayerName}");
|
|
var currentPlayer = AuthenticationService.Instance.PlayerId;
|
|
_kick.gameObject.SetActive(!isHost && currentPlayer == lobby.HostId);
|
|
}
|
|
|
|
}
|
|
}
|