using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using Networking.Server; using Networking; using TMPro; public class ScoreBoard : MonoBehaviour { public ConnectionHandler clientDataList; public List ConnectedClients; public bool endOfGame = false; public GameObject FirstPlaceName; public GameObject FirstPlaceScore; public GameObject SecondPlaceName; public GameObject SecondPlaceScore; public GameObject ThirdPlaceName; public GameObject ThirdPlaceScore; public GameObject FourthPlaceName; public GameObject FourthPlaceScore; void Update() { if (Input.GetKeyDown("m")){ endGame(); } } public void endGame() { ConnectedClients = clientDataList.ConnectedClients; ConnectedClients.Sort((a, b) => b.Score.CompareTo(a.Score)); FirstPlaceName.GetComponent().text = ConnectedClients[0].Name; FirstPlaceScore.GetComponent().text = ConnectedClients[0].Score.ToString(); SecondPlaceName.GetComponent().text = ConnectedClients[1].Name; SecondPlaceScore.GetComponent().text = ConnectedClients[1].Score.ToString(); ThirdPlaceName.GetComponent().text = ConnectedClients[2].Name; ThirdPlaceScore.GetComponent().text = ConnectedClients[2].Score.ToString(); FourthPlaceName.GetComponent().text = ConnectedClients[3].Name; FourthPlaceScore.GetComponent().text = ConnectedClients[3].Score.ToString(); } //after 10 seconds load next scene/game }