diff --git a/Assets/Scenes/Client Scenes/ClientScene.unity b/Assets/Scenes/Client Scenes/ClientScene.unity index c968957..40601eb 100644 --- a/Assets/Scenes/Client Scenes/ClientScene.unity +++ b/Assets/Scenes/Client Scenes/ClientScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:824989afec58d87eca7cbb86d0bde0964ff74810bdcb82ef1b018fb45def1c32 -size 14609 +oid sha256:18d4101b77a4debce58be4d79cde998867da2e07e181f9e819dae5d4830b4545 +size 14794 diff --git a/Assets/Scenes/Client Scenes/LoginScreen.unity b/Assets/Scenes/Client Scenes/LoginScreen.unity index 71765f3..6bbc340 100644 --- a/Assets/Scenes/Client Scenes/LoginScreen.unity +++ b/Assets/Scenes/Client Scenes/LoginScreen.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b7d072ed5fffb0afdf3ee9090c2b01468dba1779c7c97d3a8d961897c5b8f1f1 -size 259079 +oid sha256:d62fbbd19c357e8a8f7dc643cb14fd4912694dcb56997edb1736298346b4bf9a +size 260483 diff --git a/Assets/Scripts/UI/Client/LoginUIManager.cs b/Assets/Scripts/UI/Client/LoginUIManager.cs index 8f74c8c..79e76d0 100644 --- a/Assets/Scripts/UI/Client/LoginUIManager.cs +++ b/Assets/Scripts/UI/Client/LoginUIManager.cs @@ -6,6 +6,9 @@ using TMPro; public class LoginUIManager : MonoBehaviour { + public int conn; + public int maxPlayers = 2; + ConnectedClients clients; [Header("References")] [SerializeField] private ClientLoginManager clientManager; @@ -34,6 +37,9 @@ public class LoginUIManager : MonoBehaviour [SerializeField] private GameObject WaitObject; + [Header("TooManyPlayerDetails")] + [SerializeField] + private GameObject tooManyObject; private string serverAddress; private int serverPort; @@ -44,8 +50,11 @@ public class LoginUIManager : MonoBehaviour bool animalSelected = false; bool colorSelected = false; - #region Unity Functions + private void Update() + { + conn = GetComponent().count; + } private void OnEnable() { clientManager.OnConnectedToServer += OnConnect; @@ -74,10 +83,16 @@ public class LoginUIManager : MonoBehaviour #region Event Functions + IEnumerator DisplayTooManyCoroutine() + { + tooManyObject.SetActive(true); + yield return new WaitForSeconds(5.0f); + tooManyObject.SetActive(false); + } + public void OnConnect() { Title.text = DetailsTitle; - CloseAll(); DetailsObject.SetActive(true); } @@ -89,10 +104,18 @@ public class LoginUIManager : MonoBehaviour WaitObject.SetActive(true); } - public void OnLoginFail() + public void OnLoginFail2Many() { Title.text = ConnectionTitle; + CloseAll(); + StartCoroutine(DisplayTooManyCoroutine()); + ConnectionObject.SetActive(true); + } + public void OnLoginFail() + { + Title.text = ConnectionTitle; + Debug.Log("Failure"); CloseAll(); ConnectionObject.SetActive(true); } @@ -124,10 +147,18 @@ public class LoginUIManager : MonoBehaviour public void OnClick_Done() { - if(colorSelected == true && animalSelected == true && playerName != ""){ - clientManager.SendPlayerDetails(playerName, playerColor, playerAnimal); - PlayerPrefs.SetString("LastUsedName", playerName); - } + if(conn <= maxPlayers) + { + if (colorSelected == true && animalSelected == true && playerName != "") + { + clientManager.SendPlayerDetails(playerName, playerColor, playerAnimal); + PlayerPrefs.SetString("LastUsedName", playerName); + } + } + else + { + OnLoginFail2Many(); + } } public void OnClick_Animal(string playerAnimal) diff --git a/Assets/Scripts/animalSelection.cs b/Assets/Scripts/animalSelection.cs index efa01b9..8fbfb72 100644 --- a/Assets/Scripts/animalSelection.cs +++ b/Assets/Scripts/animalSelection.cs @@ -8,6 +8,7 @@ public class animalSelection : MonoBehaviour { public ConnectedClients Clients; public List Animals; + public int count; //private void OnEnable() //{ @@ -22,7 +23,7 @@ public class animalSelection : MonoBehaviour public void Update() { - + count = Clients.AllClients.Count; if (Clients.AllClients.Count > 0) { for (int i = 0; i < Clients.AllClients.Count; i++)