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
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Networking.Server;
using Networking;
using TMPro;
using UnityEngine.SceneManagement;
public class ScoreBoard : MonoBehaviour
{
public ClientList clientDataList;
public List<ClientData> ConnectedClients;
public GameObject[] players = new GameObject[4];
public GameObject[] scores = new GameObject[4];
public string nextScene;
public GameObject MainScoreboard;
private void Awake()
{
MainScoreboard.SetActive(false);
}
IEnumerator displayforSeconds(GameObject display, float time)
{
display.SetActive (true);
yield return new WaitForSeconds(time);
SceneManager.LoadScene("ServerTestScene");
}
public void endGame()
{
ConnectedClients = clientDataList.ConnectedClients;
ConnectedClients.Sort((a, b) => b.Score.CompareTo(a.Score));
for (int i = 0; i < ConnectedClients.Count; i++)
{
players[i].GetComponent<TextMeshProUGUI>().text = ConnectedClients[i].Name;
scores[i].GetComponent<TextMeshProUGUI>().text = ConnectedClients[i].Score.ToString();
}
StartCoroutine(displayforSeconds(MainScoreboard, 5.0f));
}
}