private IEnumerator WaitForServerResponse() { while (!handShakeSuccessful.HasValue) { handshakeTimeoutWait -= Time.deltaTime; if (handshakeTimeoutWait < 0) { break; } yield return(null); } if (handShakeSuccessful.HasValue) { if ((bool)handShakeSuccessful) { Data.CHARACTER_ON_LOGIN = characterEntering; loginServerConnection.SendDisconnectPacket(); SceneManager.LoadScene("test", LoadSceneMode.Single); //load world instantly } else { Debug.Log("Received response but couldn't authenticate you with login server"); //make status box with message saying something messed up } } else { genericBoxHandler.DestroyMessageOnlyStatusBox(); statusBoxHandler.InstantiatePrefab(MenuPrefabs.StatusBox, "Connection to server timed out"); } }
private IEnumerator WaitForServerResponse() { while (!handShakeSuccessful.HasValue) { countDown -= Time.deltaTime; if (countDown < 0) { break; } yield return(null); } countDown = TIMEOUT_DURATION; //reset coutdown; if (handShakeSuccessful.HasValue) { if ((bool)handShakeSuccessful) { Debug.Log("Load World"); SceneManager.LoadScene("test", LoadSceneMode.Single); //load world instantly } else { Debug.Log("Received response but couldn't authenticate you with login server"); //make status box with message saying something messed up } } else { genericBoxHandler.DestroyMessageOnlyStatusBox(); statusBoxHandler.InstantiatePrefab(MenuPrefabs.StatusBox, "Connection to server timed out"); } }
//split this up into two methods, one for registering and one for logging in public void SubmitAccount(string findUser, string findPass, MenuLink ml, bool registering) { GameObject passwordGameObj = GameObject.Find(findPass); InputField passwordInput = passwordGameObj.GetComponent <InputField>(); GameObject userGameObj = GameObject.Find(findUser); InputField usernameInput = userGameObj.GetComponent <InputField>(); string password = passwordInput.text; string userName = usernameInput.text; //problem with this line as registering shouldn't go into CharacterMenu statusBoxHandler.InstantiatePrefab(Menus.CharacterMenu, MenuPrefabs.StatusBox); try { CheckInputs(userName, password); AccountPacket ap = new AccountPacket(); byte[] data = ap.GetDataBytes(userName, password); SubPacket subPacket = new SubPacket(registering, (ushort)userName.Length, (ushort)password.Length, 0, 0, data, SubPacketTypes.Account); BasePacket packetToSend = BasePacket.CreatePacket(subPacket, false, false); Utils.SetAccountName(userName); packetProcessor = GameObject.FindGameObjectWithTag("PacketProcessor").GetComponent <PacketProcessor>(); packetProcessor.LoginOrRegister(packetToSend); } catch (AccountException e) { StatusBoxHandler.statusText = e.Message; StatusBoxHandler.readyToClose = true; } }