using Networking.Server;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

public class winnerscene : MonoBehaviour
{
    public ClientList clientDataList;
    public ServerObject serverObj;
    public GameObject winname;
    public Transform characterPosition;

    private void Awake()
    {
        //GameObject character = Resources.Load<>
        GameObject prefab = Resources.Load<GameObject>(GlobalVariables.winneranimal);
        GameObject character = Instantiate(prefab, characterPosition);
        character.transform.rotation = Quaternion.Euler(0, 152.775f, 0);

        winname.GetComponent<TextMeshProUGUI>().text = GlobalVariables.winnername;
        StartCoroutine(displayforSeconds());
    }

    IEnumerator displayforSeconds()
    {
        clientDataList.server.DisconnectAllConnections();
        yield return new WaitForSeconds(10.0f);
        serverObj.ServerClose();
        SceneManager.LoadScene("MainMenu Server");
    }
}
