public IEnumerator uploadScoreData() { Debug.Log("Attempting to Upload Score Data"); WWWForm form = new WWWForm(); form.AddField("score", GameController.MyScore.CurrentScore); form.AddField("gamerID", UserData.GamerID); using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError || www.error != null) { Debug.Log(www.error); ErrorPanel.ShowError("ERROR: " + www.error); } else { var response = JSON.Parse(www.downloadHandler.text); if (response["code"].AsInt == 200) { Debug.Log("Upload Successfull"); } else { ErrorPanel.ShowError("Upload Unsuccessfull. Reason: " + response["message"]); } } ButtonHelper.ResetClick(); } }
public IEnumerator Login() { Debug.Log("Attempting Login"); WWWForm form = new WWWForm(); form.AddField("email", UserData.EmailID); form.AddField("password", UserData.Password); using (UnityWebRequest www = UnityWebRequest.Post(AuthenticateURL, form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError || www.error != null) { Debug.Log(www.error); ErrorPanel.ShowError("ERROR: " + www.error); } else { var response = JSON.Parse(www.downloadHandler.text); Debug.Log("Sign In Successfull"); UserData.GamerID = response["gamerID"]; GameController.MyScore.CurrentScore = 0; GameController.MyScore.HighScore = 0; StartCoroutine(fetchGameData()); Debug.Log(response["message"]); } } ButtonHelper.ResetClick(); }
/** * The Create Game button has been pushed */ public void CreateGame() { if (uCreateGameRoomName == "") { mErrorPanel.ShowError("You must choose a room name"); } else { mLoadingPanel.ShowAlert("Creating Game..."); Action serverStarted = () => { mLoadingPanel.HideAlert(); mNetworkManager.LoadLevel("Lobby"); }; mNetworkManager.StartServer(uCreateGameRoomName, serverStarted); } }
public void ReportCancelled() { if (InvokeRequired) { Invoke(new Action(ReportCancelled)); return; } ErrorPanel.ShowError(this, "Report was cancelled", null); }
public void ShowError(string message) { if (InvokeRequired) { Invoke(new Action <string>(ShowError), message); return; } ErrorPanel.ShowError(this, message, null); }
private void UpdateActive(bool forceClear) { EnableButtons(false); _treeViewInvalidated = true; try { ViewModel.UpdateActive(forceClear); } catch (Exception ex) { ErrorPanel.ShowError(this, ex.Message, CloseCallback); } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbName.Text)) { ErrorPanel.ShowError(this, "You must enter a Name", null); return; } Model.Item.Name = tbName.Text; ViewModel.SavePattern(Model); Close(); }
public void ACTION_REGISTER() { ButtonHelper.Clicked(); string name = register.transform.Find("name").GetComponent <InputField>().text; string email = register.transform.Find("email").GetComponent <InputField>().text; string password = register.transform.Find("password").GetComponent <InputField>().text; string gamerID = register.transform.Find("gamerID").GetComponent <InputField>().text; string validEmail = FormValidation.ValidEmail(email); string validName = FormValidation.ValidName(name); string validPassword = FormValidation.ValidPassword(password); string validGamerID = FormValidation.ValidGamerID(gamerID); if (validName != null) { ErrorPanel.ShowError(validName); ButtonHelper.ResetClick(); } else if (validGamerID != null) { ErrorPanel.ShowError(validGamerID); ButtonHelper.ResetClick(); } else if (validEmail != null) { ErrorPanel.ShowError(validEmail); ButtonHelper.ResetClick(); } else if (validPassword != null) { ErrorPanel.ShowError(validPassword); ButtonHelper.ResetClick(); } else { OnlineManager.UserData.Name = name; OnlineManager.UserData.EmailID = email; OnlineManager.UserData.Password = password; OnlineManager.UserData.GamerID = gamerID; StartCoroutine(onlineManager.Register()); } }
private IEnumerator wakeUp() { Debug.Log("Attempting WakeUp"); WWWForm form = new WWWForm(); form.AddField("dummy", "dummy"); using (UnityWebRequest www = UnityWebRequest.Post(URL + "/dummy/", form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> dict in www.GetResponseHeaders()) { sb.Append(dict.Key).Append(": \t[").Append(dict.Value).Append("]\n"); } if (www.GetResponseHeader("code") != null) { if (count > 10) { ErrorPanel.ShowError("Fatal Error. Server Not Responding"); count = 0; } else { count++; Debug.Log("Continuing"); StartCoroutine(wakeUp()); } } else { Debug.Log("Success Awake!"); count = 0; } } } }
private void UpdateSelectedGroup(bool forceClear) { if (tvFiles.SelectedNode == null) { return; } EnableButtons(false); _treeViewInvalidated = true; try { ViewModel.UpdateSelectedGroup(tvFiles.SelectedNode, forceClear); } catch (Exception ex) { ErrorPanel.ShowError(this, ex.Message, CloseCallback); } }
/** * Start hosting the server and accepting connections */ public void StartServer(string pRoomName, Action pStartServerCallback) { mStartServerCallback = pStartServerCallback; NetworkConnectionError e = Network.InitializeServer(mGame.uStations.Count - 2, SERVER_PORT, !Network.HavePublicAddress()); // -1 is for Random, another is because I dunno but it adds up - TODO: Come back to this if (e != NetworkConnectionError.NoError) { mErrorPanel.ShowError(e.ToString()); ReturnToMainMenu(); return; } uRoomName = pRoomName; StopGame(); // This registers everything with hte server - we're accepting new people }
public IEnumerator downloadScoreData() { Debug.Log("Attempting to download LeaderBoard Data"); WWWForm form = new WWWForm(); using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError || www.error != null) { Debug.Log(www.error); ErrorPanel.ShowError("ERROR: " + www.error); } else { var response = JSON.Parse(www.downloadHandler.text); if (response["code"].AsInt == 200) { Debug.Log("Download Successfull"); var data = response["leaderBoardData"].AsArray; List <string> gamerIDs = new List <string>(); List <string> scores = new List <string>(); foreach (JSONObject obj in data) { var key = obj.GetKeys()[0] as string; gamerIDs.Add(key); scores.Add(obj[key]); } uiManager.showLeaderboardData(gamerIDs, scores); uiManager.SwitchPage(UIManager.Page.HighScore); } else { ErrorPanel.ShowError("Fetch Unsuccessfull. Reason: " + response["description"]); } } } ButtonHelper.ResetClick(); }
public IEnumerator fetchGameData() { Debug.Log("Attempting to Fetch Game Data"); WWWForm form = new WWWForm(); form.AddField("gamerID", UserData.GamerID ?? "__no__"); form.AddField("gamePlatform", GameController.GameData.gamePlatform + "_" + GameController.GameData.gameBuildType + "_" + GameController.GameData.gameVersion); using (UnityWebRequest www = UnityWebRequest.Post(URL, form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError || www.error != null) { Debug.Log(www.error); ErrorPanel.ShowError("ERROR: " + www.error); } else { var response = JSON.Parse(www.downloadHandler.text); if (response["code"].AsInt == 200) { Debug.Log("Fetch Successfull"); Word_Server.Words = response["words"]; WordManager.Initialize(); GameController.GameData.enabled = response["enabled"]; uiManager.SwitchPage(UIManager.Page.MainMenu); } else if (response["code"].AsInt == 100) { ErrorPanel.ShowError("Error: " + response["message"]); //StartCoroutine(downloadFile()); } else { ErrorPanel.ShowError("Fetch Unsuccessfull. Reason: " + response["message"]); } } } ButtonHelper.ResetClick(); }
IEnumerator DownloadFile(string URL) { Debug.Log("Downloading...."); var www = new WWW("URL"); yield return(www); while (!www.isDone) { } if (www.error == null) { File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/" + "Words", www.bytes); Debug.Log("Download Complete" + www.bytes.ToString()); ErrorPanel.ShowError("Download Complete.\nLaunch Latest Version From Desktop."); Application.Quit(); } else { Debug.Log("Download Failed."); ErrorPanel.ShowError("Download Failed: " + www.error.ToString()); } }