You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
865 B

  1. using System.Linq;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using Networking.Server;
  5. public class LeadPlayerUI : MonoBehaviour
  6. {
  7. [SerializeField]
  8. private ClientList Clients;
  9. [SerializeField]
  10. private TMPro.TextMeshProUGUI ScoreText;
  11. [SerializeField]
  12. private Image ColorImage;
  13. private void Awake()
  14. {
  15. UpdateScore();
  16. }
  17. public void UpdateScore()
  18. {
  19. if (Clients.Count() == 0)
  20. {
  21. ScoreText.gameObject.SetActive(false);
  22. ColorImage.gameObject.SetActive(false);
  23. return;
  24. }
  25. else
  26. {
  27. ScoreText.gameObject.SetActive(true);
  28. ColorImage.gameObject.SetActive(true);
  29. }
  30. ClientData lead = Clients.maxBy(p => p.Lives);
  31. ScoreText.text = lead.Lives.ToString();
  32. ColorImage.color = lead.Color;
  33. }
  34. }