using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Networking.Server;
|
|
|
|
public class LeadPlayerUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private ClientList Clients;
|
|
|
|
[SerializeField]
|
|
private TMPro.TextMeshProUGUI ScoreText;
|
|
|
|
[SerializeField]
|
|
private Image ColorImage;
|
|
|
|
private void Awake()
|
|
{
|
|
UpdateScore();
|
|
}
|
|
|
|
public void UpdateScore()
|
|
{
|
|
if (Clients.Count() == 0)
|
|
{
|
|
ScoreText.gameObject.SetActive(false);
|
|
ColorImage.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
ScoreText.gameObject.SetActive(true);
|
|
ColorImage.gameObject.SetActive(true);
|
|
}
|
|
|
|
ClientData lead = Clients.maxBy(p => p.Lives);
|
|
ScoreText.text = lead.Lives.ToString();
|
|
ColorImage.color = lead.Color;
|
|
}
|
|
}
|