|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
using Networking.Server;
|
|
using Networking;
|
|
using TMPro;
|
|
|
|
public class ScoreBoard : MonoBehaviour
|
|
{
|
|
public ClientList clientDataList;
|
|
public List<ClientData> 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<TextMeshProUGUI>().text = ConnectedClients[0].Name;
|
|
FirstPlaceScore.GetComponent<TextMeshProUGUI>().text = ConnectedClients[0].Score.ToString();
|
|
SecondPlaceName.GetComponent<TextMeshProUGUI>().text = ConnectedClients[1].Name;
|
|
SecondPlaceScore.GetComponent<TextMeshProUGUI>().text = ConnectedClients[1].Score.ToString();
|
|
ThirdPlaceName.GetComponent<TextMeshProUGUI>().text = ConnectedClients[2].Name;
|
|
ThirdPlaceScore.GetComponent<TextMeshProUGUI>().text = ConnectedClients[2].Score.ToString();
|
|
FourthPlaceName.GetComponent<TextMeshProUGUI>().text = ConnectedClients[3].Name;
|
|
FourthPlaceScore.GetComponent<TextMeshProUGUI>().text = ConnectedClients[3].Score.ToString();
|
|
}
|
|
//after 10 seconds load next scene/game
|
|
}
|