protected override void OnMenuGUI() { Screen.lockCursor = false; Cursor.visible = true; GUIStyle centeredStyle = new GUIStyle(GUI.skin.label); centeredStyle.alignment = TextAnchor.MiddleCenter; centeredStyle.normal.textColor = Color.red; if (loginFailed && Time.time - lastLoginFailed < 5f) { GUILayout.Label(failedMessage, centeredStyle, GUILayout.Width(490)); } else if (Time.time - lastLoginFailed >= 5f) { loginFailed = false; } if (!internetConnection) { failedMessage = "No internet connection"; loginFailed = true; if (GUILayout.Button("Play offline", GUILayout.Width(490))) { SwitchTo <MainMenu>(); } } else { if (disconnected) { disconnected = false; OnDisconnected(); } else if (GameStateManager.loggedIn) { SwitchTo <MainMenu>(); } GUILayout.BeginHorizontal(GUILayout.Width(490)); GUILayout.Label("Login: "******"Password: "******"Signup", GUILayout.ExpandWidth(true))) { SwitchTo <Signup>(); } if (GameStateManager.Password != "" && GameStateManager.Login != "") { if (GUILayout.Button("Login", GUILayout.Width(245))) { confirm = true; } if (confirm) { RegexUtilities rg = new RegexUtilities(); confirm = false; using (WebClient wb = new WebClient()) { string hashString = GameStateManager.Password; if (hashString != startPassword) { isHashNeeded = true; } NameValueCollection data = new NameValueCollection(); if (isHashNeeded) { hashString = Signup.HashString(GameStateManager.Password); } data["id"] = GameStateManager.Login; data["psw"] = hashString; data["mode"] = "in"; byte[] response = wb.UploadValues(MainMenu.url, "POST", data); using (MD5 md5Hash = MD5.Create()) { if (!Signup.VerifyMd5Hash(md5Hash, "no", System.Text.Encoding.UTF8.GetString(response))) { GameStateManager.connectionID = System.Text.Encoding.UTF8.GetString(response); GameStateManager.loggedIn = true; GameStateManager.Password = hashString; GameStateManager.startProcess = true; GameStateManager.version = checkVersion(); PlayerLogs pl = new PlayerLogs(); pl.Login = GameStateManager.Login; pl.Password = GameStateManager.Password; pl.SerializeLogs(); SwitchTo <MainMenu>(); } else { loginFailed = true; failedMessage = "Login failed"; lastLoginFailed = Time.time; } } } } } GUILayout.EndHorizontal(); } }