|
@ -6,6 +6,9 @@ using TMPro; |
|
|
|
|
|
|
|
|
public class LoginUIManager : MonoBehaviour |
|
|
public class LoginUIManager : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
|
|
|
public int conn; |
|
|
|
|
|
public int maxPlayers = 2; |
|
|
|
|
|
ConnectedClients clients; |
|
|
[Header("References")] |
|
|
[Header("References")] |
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
private ClientLoginManager clientManager; |
|
|
private ClientLoginManager clientManager; |
|
@ -34,6 +37,9 @@ public class LoginUIManager : MonoBehaviour |
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
private GameObject WaitObject; |
|
|
private GameObject WaitObject; |
|
|
|
|
|
|
|
|
|
|
|
[Header("TooManyPlayerDetails")] |
|
|
|
|
|
[SerializeField] |
|
|
|
|
|
private GameObject tooManyObject; |
|
|
|
|
|
|
|
|
private string serverAddress; |
|
|
private string serverAddress; |
|
|
private int serverPort; |
|
|
private int serverPort; |
|
@ -44,8 +50,11 @@ public class LoginUIManager : MonoBehaviour |
|
|
bool animalSelected = false; |
|
|
bool animalSelected = false; |
|
|
bool colorSelected = false; |
|
|
bool colorSelected = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Unity Functions
|
|
|
#region Unity Functions
|
|
|
|
|
|
private void Update() |
|
|
|
|
|
{ |
|
|
|
|
|
conn = GetComponent<animalSelection>().count; |
|
|
|
|
|
} |
|
|
private void OnEnable() |
|
|
private void OnEnable() |
|
|
{ |
|
|
{ |
|
|
clientManager.OnConnectedToServer += OnConnect; |
|
|
clientManager.OnConnectedToServer += OnConnect; |
|
@ -74,10 +83,16 @@ public class LoginUIManager : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Event Functions
|
|
|
#region Event Functions
|
|
|
|
|
|
IEnumerator DisplayTooManyCoroutine() |
|
|
|
|
|
{ |
|
|
|
|
|
tooManyObject.SetActive(true); |
|
|
|
|
|
yield return new WaitForSeconds(5.0f); |
|
|
|
|
|
tooManyObject.SetActive(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void OnConnect() |
|
|
public void OnConnect() |
|
|
{ |
|
|
{ |
|
|
Title.text = DetailsTitle; |
|
|
Title.text = DetailsTitle; |
|
|
|
|
|
|
|
|
CloseAll(); |
|
|
CloseAll(); |
|
|
DetailsObject.SetActive(true); |
|
|
DetailsObject.SetActive(true); |
|
|
} |
|
|
} |
|
@ -89,10 +104,18 @@ public class LoginUIManager : MonoBehaviour |
|
|
WaitObject.SetActive(true); |
|
|
WaitObject.SetActive(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void OnLoginFail() |
|
|
|
|
|
|
|
|
public void OnLoginFail2Many() |
|
|
{ |
|
|
{ |
|
|
Title.text = ConnectionTitle; |
|
|
Title.text = ConnectionTitle; |
|
|
|
|
|
CloseAll(); |
|
|
|
|
|
StartCoroutine(DisplayTooManyCoroutine()); |
|
|
|
|
|
ConnectionObject.SetActive(true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void OnLoginFail() |
|
|
|
|
|
{ |
|
|
|
|
|
Title.text = ConnectionTitle; |
|
|
|
|
|
Debug.Log("Failure"); |
|
|
CloseAll(); |
|
|
CloseAll(); |
|
|
ConnectionObject.SetActive(true); |
|
|
ConnectionObject.SetActive(true); |
|
|
} |
|
|
} |
|
@ -124,10 +147,18 @@ public class LoginUIManager : MonoBehaviour |
|
|
|
|
|
|
|
|
public void OnClick_Done() |
|
|
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) |
|
|
public void OnClick_Animal(string playerAnimal) |
|
|