public void onCloseNewGameButton() { newGameCanvas.SetActive(false); foreach (GameObject friend in friends) { LoadFriendPFData script = friend.GetComponent <LoadFriendPFData>(); script.InviteButtonDisappearance(); } }
public void onNewGameButton() { Player1Text.text = "Player 1: " + currentUserUsername; newGameCanvas.SetActive(true); foreach (GameObject friend in friends) { LoadFriendPFData script = friend.GetComponent <LoadFriendPFData>(); script.InviteButtonAppearance(); } }
void FillFriendList() { RectTransform parent = content.GetComponent <RectTransform>(); foreach (ArrayList array in dbFriendRequests) { GameObject friend = Instantiate(FriendsPF, parent.transform, true); LoadFriendPFData script = friend.GetComponent <LoadFriendPFData>(); //print("Array 0: " + array[0]); //print("Array 1: " + array[1]); //print("Array 2: " + array[2]); script.AssignData(array[1].ToString(), array[0].ToString(), currentUserId); script.ChangeUsernameText(); if (array[2].ToString() == "FRIENDS") { script.HideButtons(); friends.Add(friend); } } }
IEnumerator CheckLobbyInvitations() { for (int i = 0; i < dbFriendRequests.Count; i++) { print(dbFriendRequests.Count); ArrayList sublista = (ArrayList)dbFriendRequests[i]; sendNot("Nueva Partida!", sublista[0] + " te ha invitado a una partida!"); if (sublista[2].ToString() == "FRIENDS") { WWWForm form = new WWWForm(); form.AddField("user1_id", currentUserId); form.AddField("user2_id", int.Parse(sublista[1].ToString())); using (UnityWebRequest www = UnityWebRequest.Post("https://afternoon-spire-83789.herokuapp.com/lobbyrequestUsers", form)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { if (www.downloadHandler.text.Length == 2) { Debug.Log("No Invitations ;("); yield break; } if (www.downloadHandler.isDone) { string temp = www.downloadHandler.text.Substring(1, www.downloadHandler.text.Length - 2); int temp5 = Regex.Matches(temp, "user1_id").Count; if (temp5 > 1) { string[] splitArray = temp.Split(new string[] { "},{" }, StringSplitOptions.None); for (int j = 0; j < splitArray.Length; j++) { string temp2; string temp3; if (j == 0) { temp2 = splitArray[j].Insert(splitArray[j].Length, "}"); } else if (j == splitArray.Length - 1) { temp2 = splitArray[j].Insert(0, "{"); } else { temp3 = splitArray[j].Insert(splitArray[j].Length, "}"); temp2 = temp3.Insert(0, "{"); } print(temp2); invitations.Add(temp2); } foreach (string asd in invitations) { lobbyInvite = JsonUtility.FromJson <LobbyInvite>(asd); /*print(friendship.friend_status); * print(friendship.user1_id); * print(friendship.user2_id);*/ lobbyInvites.Add(lobbyInvite); } } else if (temp5 == 1) { lobbyInvite = JsonUtility.FromJson <LobbyInvite>(temp); lobbyInvites.Add(lobbyInvite); } invitations.Clear(); } /*if (www.downloadHandler.isDone) * { * string temp = www.downloadHandler.text.Substring(1, www.downloadHandler.text.Length-2); * print(temp); * if (temp == "") * { * break; * } * lobbyInvite = JsonUtility.FromJson<LobbyInvite>(temp); * lobbyInvites.Add(lobbyInvite); * * }*/ } } } } foreach (GameObject friend in friends) { LoadFriendPFData script = friend.GetComponent <LoadFriendPFData>(); Transform transformId = friend.gameObject.transform.GetChild(1); Transform transformNombre = friend.gameObject.transform.GetChild(0); Text idText = transformId.GetComponent <Text>(); Text usernameText = transformNombre.GetComponent <Text>(); for (int i = 0; i < lobbyInvites.Count; i++) { LobbyInvite li = (LobbyInvite)lobbyInvites[i]; if (li.user1_id == idText.text && li.user2_id == currentUserId.ToString() && li.lobbystatus == "STANDBY") { script.AcceptInviteButtonAppearance(); } } } }