/// <summary> /// Updates the overview of the lobby and receives the signal to start the level per remote. /// /// CALLBACK FUNCTION FOR TCP-Request. /// </summary> /// <param name="response">Response.</param> private void UpdateView(string[][] response) { headline.text = "Wait for Players in Session " + UserStatics.SessionId.ToString(); string ret = ""; foreach (string[] pair in response) { if (pair [0].Equals("playerInSession")) { ret += pair [1]; } string pattern = @"//"; string[] usernames = Regex.Split(ret, pattern); for (int i = 0; i < usernames.Length; i++) { users [i].text = usernames [i]; users [i].fontStyle = FontStyle.Bold; if (UserStatics.GetUserName(UserStatics.IdSelf).Equals(usernames [i])) { users [i].color = Constants.userColor; } else if (usernames[i].Equals(Constants.noUser)) { users [i].text = Constants.freeUser; users [i].fontStyle = FontStyle.Normal; users [i].color = Constants.textColor; } else { users [i].color = Constants.textColor; } } if (pair [0].Equals(Constants.sfLevelindex)) { int levelindex = 0; int.TryParse(pair [1], out levelindex); currentLevelIndex = levelindex; AssignLevel(LevelConstants.GetLevel(levelindex)); } // Check if the session is ment to be started. if (pair [0].Equals(Constants.sfState) && pair [1].Equals(Constants.sfStarting)) { // Start the session. gameObject.GetComponent <StartSession> ().StartTheSession(); } } }
/// <summary> /// Updates the overview of the lobby and receives the signal to start the level per remote. /// </summary> /// <param name="response">Response.</param> private void UpdateView(string[][] response) { headline.text = "Wait for Players in Session " + UserStatics.SessionId.ToString(); //headline.text ="Wait for Players in Session " + GameObject.Find(Constants.softwareModel).GetComponent<SoftwareModel>().UserHandler.ThisUser.SsId.ToString(); string ret = ""; foreach (string[] pair in response) { if (pair [0].Equals("playerInSession")) { ret += pair [1]; } string pattern = @"//"; string[] usernames = Regex.Split(ret, pattern); for (int i = 0; i < usernames.Length; i++) { users [i].text = usernames [i]; users [i].fontStyle = FontStyle.Bold; if (UserStatics.GetUserName(UserStatics.IdSelf).Equals(usernames [i])) { users [i].color = Constants.userColor; } else if (usernames[i].Equals(Constants.noUser)) { users [i].text = Constants.freeUser; users [i].fontStyle = FontStyle.Normal; } else { users [i].color = Constants.defaultColor; } } // Check if the session is ment to be started. if (pair [0].Equals(Constants.sfState) && pair [1].Equals(Constants.sfStarting)) { // Start the session. gameObject.GetComponent <StartSession> ().LoadNewScene(); } } }
/// <summary> /// Resets the information of one self when leaving a session. /// /// CALLBACK FUNCTION FOR TCP-Request. /// </summary> /// <param name="response">Response.</param> private void ResetUserInfo(string[][] response) { UserStatics.SetUserInfo(0, UserStatics.IdSelf, UserStatics.GetUserName(UserStatics.IdSelf), ""); }