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.

45 lines
928 B

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