public void AttemptAccountCreation(string username, string password) { if (!isConnected) { Debug.Log("[Notice] User not connected to server; aborting operation."); if (consoleRef) { consoleRef.UpdateChat("[Console] Cannot create account; user is not connected to server."); } return; } string msgJson; LoginMsg acctCreateMsg; Byte[] sendBytes; Debug.Log("[Notice] Sending registration info to server..."); acctCreateMsg = new LoginMsg(Flag.CREATE_ACCOUNT); acctCreateMsg.version = GameVersion.GetVersion(); acctCreateMsg.username = username; acctCreateMsg.password = password; msgJson = JsonUtility.ToJson(acctCreateMsg); sendBytes = Encoding.ASCII.GetBytes(msgJson); udp.Send(sendBytes, sendBytes.Length); }
public void AttemptLogin(string username, string password) { if (!isConnected) { Debug.Log("[Notice] User not connected to server; aborting operation."); if (consoleRef) { consoleRef.UpdateChat("[Console] Cannot log in; user is not connected to server."); } return; } if (!profileMgrRef) { if (GameObject.Find("ProfileManager")) { profileMgrRef = GameObject.Find("ProfileManager").GetComponent <ProfileMgr>(); profileMgrRef.SetProfile(username, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); //TODO TEMP clientUsername = username; } } else { profileMgrRef.SetProfile(username, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); //TODO TEMP clientUsername = username; } string msgJson; LoginMsg acctCreateMsg; Byte[] sendBytes; Debug.Log("[Notice] Sending login info to server..."); acctCreateMsg = new LoginMsg(Flag.LOGIN_ACCOUNT); acctCreateMsg.version = GameVersion.GetVersion(); acctCreateMsg.username = username; acctCreateMsg.password = password; msgJson = JsonUtility.ToJson(acctCreateMsg); sendBytes = Encoding.ASCII.GetBytes(msgJson); udp.Send(sendBytes, sendBytes.Length); }