//Function which show the response from a challenge. public IEnumerator displayChallengeResultPanel(string str) { var chlidren = SingletonUI.Instance.ScrollViewContent.GetComponentsInChildren <UserListItemScript>(); foreach (UserListItemScript user in chlidren) { Text text = user.GetComponentInChildren <Text>(); if (text.text == Message) { user.transform.GetComponent <Image>().sprite = SingletonUI.Instance.OnlineSprite; var prefabImageChildren = user.GetComponentsInChildren <Image>(); foreach (Image img in prefabImageChildren) { if (img.name == "ChallengeImage") { img.enabled = true; break; } } break; } } Singleton.Singleton.Instance.UsersLoggedList.Single(p => p.Username == Message).IsChallenged = false; MainSceneScript.displayResponsePanel(str); yield return(null); }
public IEnumerator backToLobby() { Singleton.Singleton.Instance.UsersLoggedList.Clear(); Singleton.Singleton.Instance.Me.InGame = false; if (Message != "") { string[] splits = Message.Split('|'); foreach (string s in splits) { if (s == "") { continue; } string[] users = s.Split(':'); User user = new User(); user.Username = users[0]; if (users[1] == "true" || users[1] == "True") { user.IsChallenged = true; } else { user.IsChallenged = false; } if (users[2] == "true" || users[2] == "True") { user.InGame = true; } else { user.InGame = false; } Singleton.Singleton.Instance.UsersLoggedList.Add(user); } Singleton.Singleton.Instance.UsersLoggedList.Sort((x, y) => string.Compare(x.Username, y.Username)); } SingletonGame.Instance.GameSceneCanvas.SetActive(false); SceneManager.LoadScene("MainScene"); SingletonUI.Instance.MainSceneCanvas.SetActive(true); SingletonGame.Instance.prepareForNewGame(); MainSceneScript.deleteAllUsersFromScrolViewContent(); MainSceneScript.addUsersToScrollViewContent(); //Destroy every restult challenge panel (if exists) var list = SingletonUI.Instance.Helper.GetComponentsInChildren <ChallengeResultScript>(); foreach (ChallengeResultScript x in list) { x.destroyMyself(); } //SingletonGame.Instance.GameOverPanel.SetActive(false); yield return(null); }